1) Doubly linked lists contain nodes with pointers to both the previous and next nodes, allowing traversal in either direction.
2) Common operations on doubly linked lists include insertion and deletion at the beginning, end, or within the list by node value.
3) Insertion and deletion have some special cases to handle when the target node is the first, last, or only node in the list.
Doubly Linked List || Operations || AlgorithmsShubham Sharma
ย
Doubly linked list and operations on it. Insertion, Deletion, Traversing at all locations- First, Last, Middle.
Basic definitions and structured example.
Algorithms for all the operations.
The document describes a doubly linked list data structure. Each node in a doubly linked list contains pointers to both the next and previous nodes, allowing traversal in either direction. Common operations on doubly linked lists include inserting and deleting nodes at the beginning, end, or anywhere in the list. Pseudocode algorithms are provided to demonstrate how to implement these operations by updating the pointer references between nodes.
This document discusses doubly linked lists. A doubly linked list is a list where each node contains a pointer to the next node and previous node. This allows traversal in both directions. The document explains how to implement a doubly linked list using a struct with next and previous pointers. It covers insertion, deletion, searching, and printing nodes in a doubly linked list by traversing forwards and backwards. Key operations like adding a node to the beginning, middle or end of the list are demonstrated along with deleting nodes and freeing memory.
The document discusses various types of linked lists including circular linked lists, linked implementation of stacks and queues, and applications of linked lists. Circular linked lists form a closed loop where the last node points to the first node. Linked stacks and queues can be implemented using linked lists which allows dynamic memory allocation instead of fixed size arrays. Applications of linked lists include representing polynomials for arithmetic operations, adding long integers, and non-integer/heterogeneous lists.
A singly linked list is a data structure consisting of nodes where each node stores an element and a link to the next node. The document describes algorithms for inserting nodes at the head, tail, and between two nodes of a singly linked list. It also describes doubly linked lists which allow traversing the list in both directions by including a link to the previous node as well as the next node in each node. Linked lists are useful when the number of elements is unknown or varies, and for operations like inserting or removing elements in the middle of the list without shifting other elements.
Linked lists are linear data structures where each node contains a data field and a pointer to the next node. There are two types: singly linked lists where each node has a single next pointer, and doubly linked lists where each node has next and previous pointers. Common operations on linked lists include insertion and deletion which have O(1) time complexity for singly linked lists but require changing multiple pointers for doubly linked lists. Linked lists are useful when the number of elements is dynamic as they allow efficient insertions and deletions without shifting elements unlike arrays.
This document discusses linked lists and their implementation. It begins by defining a list as a sequence of zero or more elements of a given type that can be linearly ordered. Linked lists are introduced as a flexible data structure that uses nodes connected by pointers to dynamically allocate elements in memory. The key operations on linked lists are described, including appending, traversing, inserting, deleting nodes. Code examples are provided to implement these operations using a ListNode struct containing a data element and pointer to the next node. Functions like appendNode and displayList are demonstrated, with appendNode adding to the end of the list and displayList traversing the list to output each element.
Doubly Linked List || Operations || AlgorithmsShubham Sharma
ย
Doubly linked list and operations on it. Insertion, Deletion, Traversing at all locations- First, Last, Middle.
Basic definitions and structured example.
Algorithms for all the operations.
The document describes a doubly linked list data structure. Each node in a doubly linked list contains pointers to both the next and previous nodes, allowing traversal in either direction. Common operations on doubly linked lists include inserting and deleting nodes at the beginning, end, or anywhere in the list. Pseudocode algorithms are provided to demonstrate how to implement these operations by updating the pointer references between nodes.
This document discusses doubly linked lists. A doubly linked list is a list where each node contains a pointer to the next node and previous node. This allows traversal in both directions. The document explains how to implement a doubly linked list using a struct with next and previous pointers. It covers insertion, deletion, searching, and printing nodes in a doubly linked list by traversing forwards and backwards. Key operations like adding a node to the beginning, middle or end of the list are demonstrated along with deleting nodes and freeing memory.
The document discusses various types of linked lists including circular linked lists, linked implementation of stacks and queues, and applications of linked lists. Circular linked lists form a closed loop where the last node points to the first node. Linked stacks and queues can be implemented using linked lists which allows dynamic memory allocation instead of fixed size arrays. Applications of linked lists include representing polynomials for arithmetic operations, adding long integers, and non-integer/heterogeneous lists.
A singly linked list is a data structure consisting of nodes where each node stores an element and a link to the next node. The document describes algorithms for inserting nodes at the head, tail, and between two nodes of a singly linked list. It also describes doubly linked lists which allow traversing the list in both directions by including a link to the previous node as well as the next node in each node. Linked lists are useful when the number of elements is unknown or varies, and for operations like inserting or removing elements in the middle of the list without shifting other elements.
Linked lists are linear data structures where each node contains a data field and a pointer to the next node. There are two types: singly linked lists where each node has a single next pointer, and doubly linked lists where each node has next and previous pointers. Common operations on linked lists include insertion and deletion which have O(1) time complexity for singly linked lists but require changing multiple pointers for doubly linked lists. Linked lists are useful when the number of elements is dynamic as they allow efficient insertions and deletions without shifting elements unlike arrays.
This document discusses linked lists and their implementation. It begins by defining a list as a sequence of zero or more elements of a given type that can be linearly ordered. Linked lists are introduced as a flexible data structure that uses nodes connected by pointers to dynamically allocate elements in memory. The key operations on linked lists are described, including appending, traversing, inserting, deleting nodes. Code examples are provided to implement these operations using a ListNode struct containing a data element and pointer to the next node. Functions like appendNode and displayList are demonstrated, with appendNode adding to the end of the list and displayList traversing the list to output each element.
Linked lists are a linear data structure composed of nodes where each node contains data and a link to the next node. There are several types of linked lists including single and double linked lists. Basic operations on linked lists include creation, insertion, deletion, traversal, and searching. Insertion can be done at the beginning, end, or after a particular node. Deletion can remove the first, last, or intermediate nodes. Linked lists allow dynamic memory allocation and efficient insertion/deletion compared to arrays. However, linked lists use more storage space than arrays. Linked lists are used in many data structures and applications like polynomial manipulation and representing trees, stacks and queues.
This document provides an overview of linked lists in C++. It discusses how to represent a linked list node using a struct with a data field and pointer to the next node. It demonstrates how to traverse a linked list by accessing the data and next fields of each node. Several examples are provided for linked list operations like inserting and deleting nodes at different positions within the list.
A linked list is a data structure where each node contains a data field and a reference to the next node. The head node points to the first node, and nodes are connected through next references. Linked lists allow for efficient insertions and deletions compared to arrays. Common types include singly linked, doubly linked, circular singly linked, and circular doubly linked lists. Operations on linked lists include insertion, deletion, and searching.
A linked list is a linear data structure consisting of nodes that are connected to each other through pointers. Each node contains a data field and a pointer to the next node. Linked lists allow for efficient insertion and removal of nodes and are more flexible than arrays in terms of memory allocation. Common types of linked lists include singly linked lists, doubly linked lists, circular linked lists, and header linked lists.
The document discusses lists and linked lists. It begins by defining a list as a homogeneous collection of elements with a linear relationship between elements that can be ordered or unordered. Lists can be implemented using arrays or linked lists. The document then discusses implementing lists using arrays and linked lists. It covers linked list definitions, representations, and common operations like traversing, searching, inserting and deleting elements. It also discusses different types of linked lists like linear linked lists, doubly linked lists, and their implementations.
Linked List Static and Dynamic Memory AllocationProf Ansari
ย
Static variables are declared and named while writing the program. (Space for them exists as long as the program, in which they are declared, is running.) Static variables cannot be created or destroyed during execution of the program in which they are declared.
Dynamic variables are created (and may be destroyed) during program execution since dynamic variables do not exist while the program is compiled, but only when it is run, they cannot be assigned names while it is being written. The only way to access dynamic variables is by using pointers. Once it is created, however, a dynamic variable does contain data and must have a type like any other variable. If a dynamic variable is created in a function, then it can continue to exist even after the function terminates.
Linked Linear List
We saw in previous chapters how static representation of linear ordered list through Array leads to wastage of memory and in some cases overflows. Now we don't want to assign memory to any linear list in advance instead we want to allocate memory to elements as they are inserted in list. This requires Dynamic Allocation of memory and it can be achieved by using malloc() or calloc() function.
But memory assigned to elements will not be contiguous, which is a requirement for linear ordered list, and was provided by array representation. How we could achieve this?
This document discusses different types of linked lists including singly linked lists, circular linked lists, and doubly linked lists. It provides details on representing stacks and queues using linked lists. Key advantages of linked lists over arrays are that linked lists can dynamically grow in size as needed, elements can be inserted and deleted without shifting other elements, and there is no memory wastage. Operations like insertion, deletion, traversal, and searching are described for singly linked lists along with sample C code to implement a linked list, stack, and queue.
The document discusses linked lists and their advantages over arrays. It defines a linked list as a linear data structure composed of nodes, where each node contains data and a pointer to the next node. The key points are:
- Linked lists have dynamic sizes while arrays are fixed. Inserting and deleting from linked lists is more efficient as it doesn't require shifting elements.
- Linked lists don't allow random access so operations like sorting are less efficient, while arrays don't waste space if fully filled.
- The document then describes the basic operations on a singly linked list like creation, insertion, deletion and searching and provides algorithms to implement these operations.
Array implementation and linked list as datat structureTushar Aneyrao
ย
The document discusses arrays and linked lists. It defines arrays as collections of elements of the same data type stored in contiguous memory. Linked lists store elements in memory locations that are not contiguous. Each element of a linked list contains a data field and a pointer to the next node. This allows for efficient insertion and deletion of nodes compared to arrays. The document provides examples of implementing common linked list operations like insertion at the head, tail, and deletion.
This presentations gives an introduction to the data structure linked-lists. I discuss the implementation of header-based linked-lists in C. The presentation runs through the code and provides the visualization of the code w.r.t pointers.
The document discusses sorting algorithms, abstract data types (ADTs), and linked lists. It describes selection sort and insertion sort algorithms for sorting arrays. It then explains that linked lists are a more flexible data structure than arrays and defines a singly linked list as an ADT with nodes that point to the next node in the list. Functions for typical linked list operations like insertion, deletion, checking if empty, and printing the list are discussed.
This document discusses linked lists and polynomials represented as linked lists. It provides details on singly linked lists, including how to implement insertion and deletion of nodes. It also describes how to represent stacks and queues as dynamically linked lists. Finally, it discusses representing polynomials using arrays or linked lists, and how to perform addition and multiplication of polynomials in each representation.
The document discusses double and circular linked lists. It covers inserting and deleting nodes from doubly linked lists and circular linked lists. Specifically, it describes how to insert nodes at different positions in a doubly linked list, such as at the front, after a given node, at the end, and before a given node. It also explains how to delete nodes from a doubly linked list. For circular linked lists, it outlines how to insert nodes in an empty list, at the beginning, at the end, and between nodes. It also provides the steps to delete nodes from a circular linked list.
This document discusses singly linked lists and circular linked lists. It begins with an introduction to linked lists and their advantages over arrays. It then covers the basic concepts of singly linked lists including their structure, basic operations like creation, insertion, deletion and traversal. It also discusses circular linked lists, their structure and how operations on them are similar to singly linked lists. It lists some applications of linked lists and concludes with discussing the disadvantages of linked lists.
The document discusses linked lists and their implementation. It covers:
- The basic structure of linked lists and how they allow elements to be connected through pointers and dynamically grow/shrink in size.
- Common linked list operations like insertion, deletion, and traversal require modifying the pointers between nodes.
- Different types of linked lists include singly linked, circular, and doubly linked lists.
- Linked lists are suitable when the number of elements is unknown or sequential access is required, while arrays are better for random access.
- Code examples are provided to demonstrate creating a linked list, traversing it, and inserting/deleting nodes.
Data structure doubly linked list programsiCreateWorld
ย
The document contains C code to perform various operations on doubly linked lists (DLLs). Specifically, it includes functions to:
1. Insert a node at the beginning of a DLL, mimicking a stack.
2. Delete a node from the beginning of a DLL, again mimicking a stack.
3. Display the contents of a DLL.
4. Insert a node at the end of a DLL.
5. Delete a node from the end of a DLL.
6. Search for a node with a given data value and delete it if found, or display a message if not found.
7. Insert a node to the right or left of a given node, and delete a node
The document discusses linked lists as an alternative to arrays for storing data in memory. Linked lists allow for easy insertion and removal of nodes anywhere in the list by using pointers to link nodes together rather than storing them in contiguous memory blocks. The key aspects of linked lists covered are the node structure containing data and a pointer to the next node, initializing an empty list, traversing the list, and common operations like insertion and deletion at different positions. Different types of linked lists are also introduced.
Revisiting a data structures in detail with linked list stack and queuessuser7319f8
ย
This document discusses various data structures including arrays, stacks, queues, and linked lists. It provides code examples for creating and manipulating each type of data structure. Specifically, it shows code for inserting and deleting elements from arrays and linked lists. It also includes algorithms and code for common stack and queue operations like push, pop, enqueue, and dequeue. The document provides a detailed overview of linear and non-linear data structures.
The document discusses linked lists and their implementation. It covers topics like:
- Types of linked lists including singly linked, doubly linked, circular linked lists
- Operations on linked lists like traversal, insertion, deletion
- Header linked lists that use a header node for simplifying operations
- Two-way or doubly linked lists that allow traversal in both directions
- Algorithms for common linked list operations like insertion, deletion at different positions
Linked lists are a linear data structure composed of nodes where each node contains data and a link to the next node. There are several types of linked lists including single and double linked lists. Basic operations on linked lists include creation, insertion, deletion, traversal, and searching. Insertion can be done at the beginning, end, or after a particular node. Deletion can remove the first, last, or intermediate nodes. Linked lists allow dynamic memory allocation and efficient insertion/deletion compared to arrays. However, linked lists use more storage space than arrays. Linked lists are used in many data structures and applications like polynomial manipulation and representing trees, stacks and queues.
This document provides an overview of linked lists in C++. It discusses how to represent a linked list node using a struct with a data field and pointer to the next node. It demonstrates how to traverse a linked list by accessing the data and next fields of each node. Several examples are provided for linked list operations like inserting and deleting nodes at different positions within the list.
A linked list is a data structure where each node contains a data field and a reference to the next node. The head node points to the first node, and nodes are connected through next references. Linked lists allow for efficient insertions and deletions compared to arrays. Common types include singly linked, doubly linked, circular singly linked, and circular doubly linked lists. Operations on linked lists include insertion, deletion, and searching.
A linked list is a linear data structure consisting of nodes that are connected to each other through pointers. Each node contains a data field and a pointer to the next node. Linked lists allow for efficient insertion and removal of nodes and are more flexible than arrays in terms of memory allocation. Common types of linked lists include singly linked lists, doubly linked lists, circular linked lists, and header linked lists.
The document discusses lists and linked lists. It begins by defining a list as a homogeneous collection of elements with a linear relationship between elements that can be ordered or unordered. Lists can be implemented using arrays or linked lists. The document then discusses implementing lists using arrays and linked lists. It covers linked list definitions, representations, and common operations like traversing, searching, inserting and deleting elements. It also discusses different types of linked lists like linear linked lists, doubly linked lists, and their implementations.
Linked List Static and Dynamic Memory AllocationProf Ansari
ย
Static variables are declared and named while writing the program. (Space for them exists as long as the program, in which they are declared, is running.) Static variables cannot be created or destroyed during execution of the program in which they are declared.
Dynamic variables are created (and may be destroyed) during program execution since dynamic variables do not exist while the program is compiled, but only when it is run, they cannot be assigned names while it is being written. The only way to access dynamic variables is by using pointers. Once it is created, however, a dynamic variable does contain data and must have a type like any other variable. If a dynamic variable is created in a function, then it can continue to exist even after the function terminates.
Linked Linear List
We saw in previous chapters how static representation of linear ordered list through Array leads to wastage of memory and in some cases overflows. Now we don't want to assign memory to any linear list in advance instead we want to allocate memory to elements as they are inserted in list. This requires Dynamic Allocation of memory and it can be achieved by using malloc() or calloc() function.
But memory assigned to elements will not be contiguous, which is a requirement for linear ordered list, and was provided by array representation. How we could achieve this?
This document discusses different types of linked lists including singly linked lists, circular linked lists, and doubly linked lists. It provides details on representing stacks and queues using linked lists. Key advantages of linked lists over arrays are that linked lists can dynamically grow in size as needed, elements can be inserted and deleted without shifting other elements, and there is no memory wastage. Operations like insertion, deletion, traversal, and searching are described for singly linked lists along with sample C code to implement a linked list, stack, and queue.
The document discusses linked lists and their advantages over arrays. It defines a linked list as a linear data structure composed of nodes, where each node contains data and a pointer to the next node. The key points are:
- Linked lists have dynamic sizes while arrays are fixed. Inserting and deleting from linked lists is more efficient as it doesn't require shifting elements.
- Linked lists don't allow random access so operations like sorting are less efficient, while arrays don't waste space if fully filled.
- The document then describes the basic operations on a singly linked list like creation, insertion, deletion and searching and provides algorithms to implement these operations.
Array implementation and linked list as datat structureTushar Aneyrao
ย
The document discusses arrays and linked lists. It defines arrays as collections of elements of the same data type stored in contiguous memory. Linked lists store elements in memory locations that are not contiguous. Each element of a linked list contains a data field and a pointer to the next node. This allows for efficient insertion and deletion of nodes compared to arrays. The document provides examples of implementing common linked list operations like insertion at the head, tail, and deletion.
This presentations gives an introduction to the data structure linked-lists. I discuss the implementation of header-based linked-lists in C. The presentation runs through the code and provides the visualization of the code w.r.t pointers.
The document discusses sorting algorithms, abstract data types (ADTs), and linked lists. It describes selection sort and insertion sort algorithms for sorting arrays. It then explains that linked lists are a more flexible data structure than arrays and defines a singly linked list as an ADT with nodes that point to the next node in the list. Functions for typical linked list operations like insertion, deletion, checking if empty, and printing the list are discussed.
This document discusses linked lists and polynomials represented as linked lists. It provides details on singly linked lists, including how to implement insertion and deletion of nodes. It also describes how to represent stacks and queues as dynamically linked lists. Finally, it discusses representing polynomials using arrays or linked lists, and how to perform addition and multiplication of polynomials in each representation.
The document discusses double and circular linked lists. It covers inserting and deleting nodes from doubly linked lists and circular linked lists. Specifically, it describes how to insert nodes at different positions in a doubly linked list, such as at the front, after a given node, at the end, and before a given node. It also explains how to delete nodes from a doubly linked list. For circular linked lists, it outlines how to insert nodes in an empty list, at the beginning, at the end, and between nodes. It also provides the steps to delete nodes from a circular linked list.
This document discusses singly linked lists and circular linked lists. It begins with an introduction to linked lists and their advantages over arrays. It then covers the basic concepts of singly linked lists including their structure, basic operations like creation, insertion, deletion and traversal. It also discusses circular linked lists, their structure and how operations on them are similar to singly linked lists. It lists some applications of linked lists and concludes with discussing the disadvantages of linked lists.
The document discusses linked lists and their implementation. It covers:
- The basic structure of linked lists and how they allow elements to be connected through pointers and dynamically grow/shrink in size.
- Common linked list operations like insertion, deletion, and traversal require modifying the pointers between nodes.
- Different types of linked lists include singly linked, circular, and doubly linked lists.
- Linked lists are suitable when the number of elements is unknown or sequential access is required, while arrays are better for random access.
- Code examples are provided to demonstrate creating a linked list, traversing it, and inserting/deleting nodes.
Data structure doubly linked list programsiCreateWorld
ย
The document contains C code to perform various operations on doubly linked lists (DLLs). Specifically, it includes functions to:
1. Insert a node at the beginning of a DLL, mimicking a stack.
2. Delete a node from the beginning of a DLL, again mimicking a stack.
3. Display the contents of a DLL.
4. Insert a node at the end of a DLL.
5. Delete a node from the end of a DLL.
6. Search for a node with a given data value and delete it if found, or display a message if not found.
7. Insert a node to the right or left of a given node, and delete a node
The document discusses linked lists as an alternative to arrays for storing data in memory. Linked lists allow for easy insertion and removal of nodes anywhere in the list by using pointers to link nodes together rather than storing them in contiguous memory blocks. The key aspects of linked lists covered are the node structure containing data and a pointer to the next node, initializing an empty list, traversing the list, and common operations like insertion and deletion at different positions. Different types of linked lists are also introduced.
Revisiting a data structures in detail with linked list stack and queuessuser7319f8
ย
This document discusses various data structures including arrays, stacks, queues, and linked lists. It provides code examples for creating and manipulating each type of data structure. Specifically, it shows code for inserting and deleting elements from arrays and linked lists. It also includes algorithms and code for common stack and queue operations like push, pop, enqueue, and dequeue. The document provides a detailed overview of linear and non-linear data structures.
The document discusses linked lists and their implementation. It covers topics like:
- Types of linked lists including singly linked, doubly linked, circular linked lists
- Operations on linked lists like traversal, insertion, deletion
- Header linked lists that use a header node for simplifying operations
- Two-way or doubly linked lists that allow traversal in both directions
- Algorithms for common linked list operations like insertion, deletion at different positions
The document discusses stacks and queues as data structures. Stacks follow LIFO (Last In First Out) and allow insertion and deletion from one end only. Queues follow FIFO (First In First Out) and allow insertion from one end and deletion from the other. Both can be implemented using arrays or linked lists. Common operations on stacks are push and pop, while common operations on queues are insert and delete.
The document discusses stacks and queues as data structures. Stacks follow LIFO (Last In First Out) and involve push and pop operations on an array or linked list. Queues follow FIFO (First In First Out) and involve insert and delete operations, with insertion at the rear and deletion at the front. The document provides examples of implementing stacks and queues using arrays and linked lists, and describes the basic operations like creation, insertion, deletion, checking for empty/full.
The document discusses stacks and queues as linear data structures. It defines stacks and queues, describes their common operations like push, pop, insert and delete, and ways to implement them using arrays and linked lists. Array implementation of stacks and queues is shown along with diagrams. Linked list implementation of stacks and queues is also discussed with diagrams showing the insertion and deletion of nodes. Sample programs to implement stacks and queues using arrays and linked lists are mentioned.
The document discusses stacks and queues as linear data structures. It defines stacks and queues, describes their common operations like push, pop, insert and delete, and ways to implement them using arrays and linked lists. Array implementation of stacks and queues is shown along with diagrams. Linked list implementation of stacks and queues is also discussed with diagrams showing the insertion and deletion of nodes. Sample programs to implement stacks and queues using both arrays and linked lists are mentioned.
This document provides an overview of linked lists and their implementation. It begins with definitions of linked lists and their advantages over arrays. It then describes different types of linked lists including singly linked lists, circular linked lists, and doubly linked lists. Basic linked list operations like creation, traversal, insertion, and deletion are covered. Implementation examples in C using structures and pointers are provided for creating a linked list, traversing it, inserting a node, and deleting a node. The document also compares array and linked list implementations of stacks and queues.
- Data structures allow for efficient handling of large volumes of data through logical organization and relationships between data elements. Common linear data structures include arrays, lists, stacks, and queues, while trees and graphs are examples of non-linear data structures.
- Abstract data types (ADTs) define a set of complex data objects and operations that can be performed on those objects without specifying their implementation. Data structures provide a way to implement the logical relationships and operations defined in an ADT.
- Linked lists provide an alternative to arrays for storing data by linking each data element to the next using pointers, rather than requiring contiguous memory locations. This allows for more flexible insertion and deletion compared to arrays.
Data structures linked list introduction.pptxKalpana Mohan
ย
Linked lists are dynamic data structures that store data in scattered locations in memory. Each data item in a linked list is called a node, which contains a data field for storing the data and a pointer field linking to the next node. The basic operations on linked lists are insertion, deletion, and traversal. To insert a new node, the algorithm locates the proper position by traversing the list and comparing data, then links the new node between existing nodes. To delete a node, the algorithm locates the target node by traversing and comparing data, then establishes links between the previous and next nodes before deleting the target node.
In computer science, a linked list is a linear collection of data elements, whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence.
The document discusses different types of queues including linear queues, circular queues, priority queues, and deques. It provides details on the basic operations for each type of queue including insert and delete operations. For linear queues, it describes how elements are added to the rear and removed from the front in FIFO order. Circular queues are described as improving on linear queues by making the queue circular to avoid overflow. Priority queues are defined as having elements with assigned priorities and removing the highest priority element first. Finally, deques are introduced as allowing insertions and deletions from either end.
The document discusses different types of queues including their representations, operations, and applications. It describes queues as linear data structures that follow a first-in, first-out principle. Common queue operations are insertion at the rear and deletion at the front. Queues can be represented using arrays or linked lists. Circular queues and priority queues are also described as variants that address limitations of standard queues. Real-world and technical applications of queues include CPU scheduling, cashier lines, and data transfer between processes.
This document discusses linked lists and representing stacks and queues using linked lists. It provides information on different types of linked lists including singly, doubly, and circular linked lists. It describes inserting, deleting, and traversing nodes in a singly linked list. It also provides a C program example to implement a stack using a linked list with functions for push, pop, and display operations. The document discusses how linked lists are dynamic data structures that can grow and shrink in size as needed, unlike arrays.
Linked lists are a data structure made up of connected nodes, where each node contains data and a pointer to the next node. The three basic operations on linked lists are insertion, deletion, and traversal of nodes. There are variations like circular linked lists where the last node points to the first, and doubly linked lists where each node points to both the next and previous nodes. Linked lists have advantages over arrays in that they are dynamically sized and nodes can be easily inserted and deleted without moving other elements.
This document presents information on doubly linked lists including their representation, initialization, node creation, and various operations like insertion, deletion, and traversal. It discusses inserting and deleting nodes at the beginning or end of the list, as well as inserting before or after a specified node. Code examples are provided for initializing a doubly linked list and performing each operation.
This document discusses linked lists as a solution to problems with arrays. It provides definitions and examples of linked lists, including:
- Each node contains a data element and a pointer to the next node
- A linked list is a series of connected nodes with a head pointer pointing to the first node
- Operations like insertion, deletion, and searching have linear time complexity of O(n) in the worst case
- Variations include circular and doubly linked lists
The document provides information on various data structures and algorithms related to linked lists. It discusses topics like list traversal, searching, insertion, deletion, header linked lists, circular linked lists, and two-way linked lists. Algorithms are provided for traversing, searching, inserting and deleting nodes from singly linked lists, circular linked lists, and two-way linked lists. Applications of linked lists in representing polynomials and sparse matrices are also covered.
The document discusses linked lists as an alternative to arrays for storing data. It provides 3 key points:
1. Linked lists store data in nodes that are linked together using pointers, rather than in a fixed contiguous block of memory like arrays. Each node contains a data field and a pointer to the next node.
2. Common linked list operations like insertion, deletion, and searching have time complexities of O(1) or O(n) depending on the position in the list, which can be more efficient than arrays that require shifting elements.
3. The document presents a simple C++ implementation of a linked list using Node and List classes to demonstrate how to implement basic linked list functions like insertion, deletion
The document discusses different types of linked lists including:
- Singly linked lists that can only be traversed in one direction.
- Doubly linked lists that allow traversal in both directions using forward and backward pointers.
- Circular linked lists where the last node points back to the first node allowing continuous traversal.
- Header linked lists that include a header node at the beginning for simplified insertion and deletion. Header lists can be grounded where the last node contains a null pointer or circular where the last node points to the header.
- Two-way or doubly linked lists where each node contains a forward and backward pointer allowing bidirectional traversal through the list.
Heap memory is a common pool of dynamic memory used for allocating objects and data structures during program execution. It is part of RAM and allows for longer-lived allocations compared to stack memory. When the heap is full, garbage collection clears unused objects to free up space. Linked lists are linear data structures composed of nodes containing a data field and a pointer to the next node. They allow for dynamic sizes and efficient insertions/deletions unlike arrays. Doubly linked lists include pointers to both the next and previous nodes, allowing traversal in both directions but requiring more space.
Gender and Mental Health - Counselling and Family Therapy Applications and In...PsychoTech Services
ย
A proprietary approach developed by bringing together the best of learning theories from Psychology, design principles from the world of visualization, and pedagogical methods from over a decade of training experience, that enables you to: Learn better, faster!
Information and Communication Technology in EducationMJDuyan
ย
(๐๐๐ ๐๐๐) (๐๐๐ฌ๐ฌ๐จ๐ง 2)-๐๐ซ๐๐ฅ๐ข๐ฆ๐ฌ
๐๐ฑ๐ฉ๐ฅ๐๐ข๐ง ๐ญ๐ก๐ ๐๐๐ ๐ข๐ง ๐๐๐ฎ๐๐๐ญ๐ข๐จ๐ง:
Students will be able to explain the role and impact of Information and Communication Technology (ICT) in education. They will understand how ICT tools, such as computers, the internet, and educational software, enhance learning and teaching processes. By exploring various ICT applications, students will recognize how these technologies facilitate access to information, improve communication, support collaboration, and enable personalized learning experiences.
๐๐ข๐ฌ๐๐ฎ๐ฌ๐ฌ ๐ญ๐ก๐ ๐ซ๐๐ฅ๐ข๐๐๐ฅ๐ ๐ฌ๐จ๐ฎ๐ซ๐๐๐ฌ ๐จ๐ง ๐ญ๐ก๐ ๐ข๐ง๐ญ๐๐ซ๐ง๐๐ญ:
-Students will be able to discuss what constitutes reliable sources on the internet. They will learn to identify key characteristics of trustworthy information, such as credibility, accuracy, and authority. By examining different types of online sources, students will develop skills to evaluate the reliability of websites and content, ensuring they can distinguish between reputable information and misinformation.
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxOH TEIK BIN
ย
(A Free eBook comprising 3 Sets of Presentation of a selection of Puzzles, Brain Teasers and Thinking Problems to exercise both the mind and the Right and Left Brain. To help keep the mind and brain fit and healthy. Good for both the young and old alike.
Answers are given for all the puzzles and problems.)
With Metta,
Bro. Oh Teik Bin ๐๐ค๐ค๐ฅฐ
2. TOPICS:
โข linked lists
โข doubly linked list
โข Creation and traversing of doubly linked list
โข Insertion and deletion on doubly linked list
โข complexity of insertion and deletion
โข Advantages and disadvantages of doubly linked list
3. LINKED LIST
๏ Like arrays, Linked List is a linear data structure
๏ Unlike arrays, linked list elements are not stored at contiguous
location
๏ the elements are linked using pointers
๏ does not have any index
5. WHY WE USE LINKED LIST
Arrays can be used to store linear data of similar
types, but arrays have following limitations..
1) The size of the arrays is fixed .
2) Inserting a new element in an array of elements is expensive, because room
has to be created for the new elements and to create room existing elements
have to shifted.
6. DOUBLY LINKED LIST
โข A Doubly Linked List (DLL) contains an extra pointer, typically called previous
pointer, together with next pointer and data which are there in singly linked
list.
โข Every nodes in the doubly linked list has three fields:
1. Left Pointer (prev)
2. Right Pointer (next)
3. Data (info)
7. DOUBLY LINKED LIST
โข Prev - address of the previous node
โข Next - address of the next node
โข Info - information of the node
โข head - address of the first node
Prev Info Next
node
8. CREATION OF DOUBLY LINKED LIST
Steps-
1: Head := NULL (as global)
2: New Node (Ptr)
// set data and prev , next to NULL
3: If Head = NULL
๏ Head := ptr
๏ temp := ptr
4. If not
๏ temp โ next := ptr
๏ Ptr โ prev := temp
๏ temp := ptr
9. CREATION OF DOUBLY LINKED LIST
NULL data1 NULL
0x80
0x80 data2 NULLNULL data1 0x81
0x810x80
0x80 data2 0x81NULL data1 0x81 0x81 data3 NULL
0x80 0x81 0x82
No element inserted
Third element inserted:
Second element inserted:
First element inserted:
Empty list
Head
temp
Head
temp
Head
temp
10. TRAVERSING
0x80 9 0x82NULL 8 0x81 0x81 10 NULL
Head Srt
Steps:
Set srt := head
while ( srt->next != NULL)
print srt->info // 8
srt := srt->next
if (srt->next == NULL)
print srt->info
end of traversing
0x80 0x81 0x82
False
Not Executed
Output:
8
Srt
0x80
0x81
Srt
11. TRAVERSING
0x80 9 0x82NULL 8 0x81 0x81 10 NULL
Head Srt
Steps:
Set srt := head
while ( srt->next != NULL)
print srt->info // 9
srt := srt->next
if (srt->next = NULL)
print srt->info
end of traversing
0x80 0x81 0x82
True
Output:
8
9
10
Srt
0x80
0x81
0x82
Srt
12. OPERATIONS ON DOUBLY LINKED LIST
Insertion
โข Insert an element at first
โข Insert an element at last
โข Insert before a given element
โข Insert after a given element
Deletion
โข Delete first element
โข Delete last element
โข Delete a given element
โข Delete before a given element
โข Delete after a given element
13. INSERT AN ELEMENT AT FIRST
prev info NULLprev info nextNULL info next
Head
Steps-
1. New node (Ptr)
prev info next
Ptr
14. INSERT AN ELEMENT AT FIRST
prev info NULLprev info nextinfo next
Head
data
Steps-
1. New node (Ptr)
2. Ptr โ info := data
3. Ptr โ prev := NULL
4. Ptr โ next := NULL
Ptr
NULL
NULL
NULL
15. INSERT AN ELEMENT AT FIRST
prev info NULLprev info nextinfo next
Head
NULL data
Steps-
1. New node (Ptr)
2. Ptr โ Info := data
3. Ptr โ prev := NULL
4. Ptr โ next := NULL
5. Head โ prev := ptr
6. Ptr โ next := head
7. Head := Ptr
Ptr
NULL
NULL
Head
16. EXAMPLE OF FIRST INSERTION:
This is a doubly linked list โฆ.
0x81 8 XX 1 0x81 0x80 5 0x82
Inserting 45 at the first of the list
0x820x810x80
0x81 8 XX 1 0x81 0x80 5 0x82
0x820x810x80
X 45 X
0x90
0X900X80
17. INSERT AN ELEMENT AT LAST
prev info NULLprev info nextNULL info next
prev info next
srt
Ptr
Steps-
1. New node (Ptr)
Head
18. INSERT AN ELEMENT AT LAST
prev info NULLprev info nextNULL info next
info data next
srt
Ptr
Steps-
1. New node (Ptr)
2. Ptr โ Info := data
Head
19. INSERT AN ELEMENT AT LAST
prev infoprev info nextNULL info next
data
srt
Ptr
Steps-
1. New node (Ptr)
2. Ptr โ Info := data
3. Ptr โ prev := NULL
4. Ptr โ next := NULL
5. srt โ next := ptr
6. Ptr โ prev := srt
NULL NULL
NULL
Head
20. EXAMPLE OF LAST INSERTION:
This is a doubly linked list โฆ. Insert 45 at the last of the list
0x81 8 XX 1 0x81 0x80 5 0x82
After insertion 45 at lastโฆ.
0x820x810x80
0x81 8 XX 1 0x81 0x80 5 0x82
0x820x810x80
X 45 X
0x90
0X820X90
21. INSERT BEFORE A GIVEN ELEMENT
prev info NULLprev info nextprev info next
Steps-
1. New Node(Ptr)
2. ptr โinfo = data
NULL info next
data
given element
Ptr
srttemp
Head
22. INSERT BEFORE A GIVEN ELEMENT
prev info NULLprev info nextinfo next
Steps-
1. New Node(Ptr)
2. ptr โinfo = data
3. srt โprev := Ptr
4. temp โnext := Ptr
5. ptr โprev := temp
6. ptr โnext := srt
NULL info
data
given element
Ptr
srttemp
next prev
Head
23. EXAMPLE INSERT BEFORE A GIVEN ELEMENT:
0x81 8 XX 1 0x81 0x80 5 0x82
0x820x810x80
X 36 X
0x90
0x81 8 XX 1 0x81 0x80 5 0x82
0x820x810x80
0x90
Inserting 36 before 5โฆ
24. EXAMPLE INSERT BEFORE A GIVEN ELEMENT:
0x81 8 XX 1 0x81 0x80 5 0x82
0x820x810x80
X 36 X
0x90
0x81 8 XX 1 0x80 5 0x82
0x820x810x80
0x90
Inserting 36 before 5โฆ
0x90
25. EXAMPLE INSERT BEFORE A GIVEN ELEMENT:
0x81 8 XX 1 0x81 0x80 5 0x82
0x820x810x80
X 36 X
0x90
0x81 8 XX 1 5 0x82
0x820x810x80
0x90
Inserting 36 before 5โฆ
0x90 0x90
0X80 0X81
26. SPECIAL CASE: (IF GIVEN ELEMENT IS THE FIRST NODE
OF THE LIST)
prev info NULLprev info nextprev info nextNULL info next
Given element
๏ถ When Head โinfo = given
element
๏ In this case it is similar to first
insertion โฆ.
Head
27. INSERT AFTER A GIVEN ELEMENT
prev info NULLprev info nextprev info nextNULL info next
data
given element
srt
Head
Steps-
1. New Node (Ptr)
2. Ptr โ info := data
Ptr
28. INSERT AFTER A GIVEN ELEMENT
prev info NULLinfo nextprev infoNULL info next
data
given element
srt
Head
Steps-
1. New Node (Ptr)
2. Ptr โ info := data
3. Ptr โ prev := srt
4. Ptr โ next := srt โ next
5. srt โ next โprev := Ptr
6. srt โ next := Ptr
Ptr
next prev
29. EXAMPLE INSERT AFTER A GIVEN ELEMENT:
0x81 8 XX 1 0x81 0x80 5 0x82
0x820x810x80
X 10 X
0x90
0x81 8 XX 1 0x81 0x80 5 0x82
0x820x810x80
Inserting 10 after 5โฆ
0X820X81
30. EXAMPLE INSERT AFTER A GIVEN ELEMENT:
0x81 8 XX 1 0x81 0x80 5 0x82
0x820x810x80
X 10 X
0x90
0x81 8 XX 1 0x81 0x80 5
0x820x810x80
Inserting 10 after 5โฆ
0X820X81
0x90
31. EXAMPLE INSERT AFTER A GIVEN ELEMENT:
0x81 8 XX 1 0x81 0x80 5 0x82
0x820x810x80
X 10 X
0x90
8 XX 1 0x81 0x80 5
0x820x810x80
Inserting 10 after 5โฆ
0X820X81
0x90 0x90
32. SPECIAL CASE: (IF GIVEN ELEMENT IS THE LAST NODE
OF THE LIST)
prev info NULLprev info nextprev info nextNULL info next
Given element
๏ถ When srt โ next = NULL
๏ In this case it is similar to last
insertion โฆ.
Head
srt
34. DELETE AN ELEMENT AT FIRST
Prev Info NextPrev Info NextNULL Info Next Prev Info NULL
Steps-
1. Set head := head->next
2. Set head->prev := NULL
Head
Head
35. DELETE AN ELEMENT AT FIRST
Prev Info NextInfo NextNULL Info Next Prev Info NULL
Steps-
1. Set head := head->next
2. Set head->prev := NULL
Head
NULL
36. EXAMPLE OF FIRST DELETION:
This is a doubly linked list โฆ. Delete the first node..
0x820x810x80
0x81 8 0x83NULL 1 0x81 0x80 5 0x82 0x82 45 NULL
0x83
Head Head
37. EXAMPLE OF FIRST DELETION:
After deleting first node
0x820x81
0x81 8 0x83NULL 1 0x81 5 0x82 0x82 45 NULL
0x83
Head
NULL
0x80
38. DELETE AN ELEMENT AT LAST
Prev Info NextPrev Info NextNULL Info Next Prev Info NULL
Steps-
When srt->next := NULL
1. Set temp->next := NULL
Head
Temp Srt
39. DELETE AN ELEMENT AT LAST
Prev InfoPrev Info NextNULL Info Next Prev Info NULL
Steps-
When srt->next := NULL
1. Set temp->next := NULL
Head
Temp Srt
NULL
40. EXAMPLE OF LAST DELETION:
This is a doubly linked list โฆ. Delete the last node..
0x820x810x80
0x81 8 0x83NULL 1 0x81 0x80 5 0x82 0x82 45 NULL
0x83
Head Temp Srt
41. EXAMPLE OF LAST DELETION:
This is a doubly linked list โฆ. Delete the last node..
0x820x810x80
0x81 8NULL 1 0x81 0x80 5 0x82 0x82 45 NULL
0x83
Head Temp Srt
NULL
42. DELETE A NODE OF GIVEN ELEMENT
Prev Info NextPrev info NextNULL Info Next Prev Info NULL
Head
Steps-
when srt->info := item
srt->next->prev := srt->prev
srt->prev->next := srt->next
Srt
43. EXAMPLE OF DELETION OF A GIVEN ELEMENT:
This is a doubly linked list โฆ. Delete the particular node.. Suppose the item is 8
0x820x810x80
0x81 5 0x83NULL 1 0x81 0x80 5 0x82 0x82 45 NULL
0x83
8
Head Srt
44. EXAMPLE OF DELETION OF A GIVEN ELEMENT:
This is a doubly linked list โฆ. Delete the particular node.. Suppose the item is 8
0x820x810x80
0x80 5 0x83NULL 1 0x81 0x80 5 0x82 0x82 45 NULL
0x83
8
Head Srt
45. EXAMPLE OF DELETION OF A GIVEN ELEMENT:
After deleting the particular node
0x820x810x80
0x80 5 0x83NULL 1 0x80 5 0x82 0x82 45 NULL
0x83
8
Head
0x82
Srt
46. SPECIAL CASES: FOR DELETION OF GIVEN ELEMENT
I) If the given element is in the first node, it will be as same as first
element delete.
II) If the given element is in the last node, it will be as same as last
element delete.
47. DELETE A NODE AFTER GIVEN ELEMENT
Prev Info NextPrev Info NextNULL Info Next Prev Info NULL
Steps-
when srt->info := item
Set srt->next->next->prev := srt
srt->next=srt->next->next
Head Srt
48. EXAMPLE OF DELETION AFTER A GIVEN ELEMENT:
This is a doubly linked list โฆ. Delete the particular node.. Suppose the item is 1
0x820x810x80
0x81 8 0x83NULL 0x81 0x80 5 0x82 0x82 45 NULL
0x83
Head
1
Srt
49. EXAMPLE OF DELETION AFTER A GIVEN ELEMENT:
This is a doubly linked list โฆ. Delete the particular node.. Suppose the item is 1
0x820x810x80
0x80 8 0x83NULL 0x81 0x80 5 0x82 0x82 45 NULL
0x83
Head
1
Srt
50. EXAMPLE OF DELETION AFTER A GIVEN ELEMENT:
Deleting the particular node after the given element
0x820x810x80
0x80 8 0x83NULL 0x80 5 0x82 0x82 45 NULL
0x83
Head
0x821
Srt
51. SPECIAL CASES: FOR DELETION AFTER GIVEN ELEMENT
I) If the given element is before the last node , it will be as same as last element
delete.
II) If the given element is in the last node, it will not be possible. As the
next of last node is NULL , it will not delete anything
52. DELETE A NODE BEFORE GIVEN ELEMENT
Prev Info NextPrev Info NextNULL Info Next Prev Info NULL
Steps-
when srt->info := item
Set srt->prev->prev->next := srt
srt->prev:= srt-> prev->prev
Head Srt
53. EXAMPLE OF DELETION BEFORE A GIVEN ELEMENT:
This is a doubly linked list โฆ. Delete the particular node before a given item.. Suppose the item is 9
0x820x810x80
0x81 8 0x83NULL 1 0x81 0x80 5 0x82 0x82 NULL
0x83
Head
9
Srt
54. EXAMPLE OF DELETION BEFORE A GIVEN ELEMENT:
This is a doubly linked list โฆ. Delete the particular node before a given item.. Suppose the item is 9
0x820x810x80
0x81 8 0x83NULL 1 0x81 0x80 5 0x83 0x82 NULL
0x83
Head
9
Srt
55. EXAMPLE OF DELETION BEFORE A GIVEN ELEMENT:
After Deleting The Node Before A Given Element
0x820x810x80
0x81 8 0x83NULL 1 0x81 0x80 5 0x83 NULL
0x83
Head
90x81
Srt
56. SPECIAL CASES: FOR DELETION AFTER GIVEN ELEMENT
I) If the given element is after the first node , it will be as same as first element
delete.
II) If the given element is in the first node, it will not be possible. As the
next of first node is NULL , it will not delete anything
57. COMPLEXITY โ FIRST / LAST INSERTION
prev info NULLprev info nextNULL info next
Head
First insertion
Last insertion
Last
61. COMPLEXITY OF DOUBLY LINKED LIST
โข Inserting based on the value ( e.g. inserting in a sorted list )- will be O(n). If it
is being inserted after or before an existing known node is O(1).
โข Deleting an arbitrary value (rather than a node) will indeed be O(n) as it will
need to find the value. Deleting a node (when the node is known ) is O(1).
โข Inserting to the first or last of the list will always be O(1) - because those are
just special cases of the above.
62. ADVANTAGES OF DOUBLY LINKED LIST
๏ง Dynamic size
๏ง Ease of insertion/deletion
๏ง A DLL can be traversed in both forward and backward direction.
๏ง The delete operation in DLL is more efficient if pointer to the node to be
deleted is given.
In singly linked list, to delete a node, pointer to the previous node is needed.
To get this previous node, sometimes the list is traversed. In DLL, we can get
the previous node using previous pointer.
63. DISADVANTAGES OF DOUBLY LINKED LIST
๏ฑ Every node of DLL Require extra space for an previous pointer.
๏ฑ All operations require an extra pointer previous to be maintained. For
example, in insertion, we need to modify previous pointers together with next
pointers.
Hello good afternoonโฆ..
I am ..... I am here to make a presentation on doubly linked list
These are some parts of this presentation
at first I am going to talk about linked listโฆ
What is a linked list??
Why we need to use linked list??
I will tell you something behind the figureโฆ.
Variables or pointers addresses of a node are contiguous
Bt every nodeโs starting address is randomโฆ.not sequential.
Nowโฆ look at the memory allocation of arrayโฆ. The addresses are contiguous.
So thatโs the difference
Why linked list??
Well, we can increase the size of the list
Bt we can not increase the size of an initialized sized array โฆ.
If it is attempted , then index wont be found and cause overflow
A double way or two way linked list a linked list that every element is linked with its previous and next element through pointers
To create a doubly linked list..
Firstly a pointer of node type is declared globally โฆ. Say it is โheadโ. And initialized to null, as it points to nothing.
Now each time a new element is inserted, a new node is created (here denoted by ptr).
Data is stored in the info section of ptr
And prev and next pointer initialized to null
Now for the first nodeโฆ.
Head needs to point the first nodeโฆ.
Also for the next insertion the previous node address needs to be storedโฆ
Thatโs why temp is used to store the address.
Then for all other insertion โฆ
We set the next pointer of temp to ptr;
And prev pointer of ptr to temp;
Update temp to ptr to keep track of the previous node.
For traversing we start from the head and continue till the next pointer of a node equals to null...
And