Data structure
Presented By
SWAPNIL SAHA
Linked list
• A linked list is a linear data structure
• A collection of nodes with various fields
• It contains data field and Address field
DATA Address /
Pointer
Linked List Types
• SINGLY LINKED LIST
• CIRCULAR SINGLY LINKED LIST
• DOUBLY LINKED LISTS
• CIRCULAR DOUBLY LINKED LISTS
Singly Linked List
• Each node has only one link part
• Each link part contains the address of the next node in the list
X 100 Y 200 Z NULL
Head
Inserting the node in a SLL
Insertion at the
beginning
Inserting at the end
Inserting after an element
Deleting a node in SLL
Deleting the first node
Deleting the last node
Deleting a particular node
● Stack - linearly ordered set of elements having the last-in,
first-out (LIFO) discipline
● Operations are done on top of the stack only and we have
no access to other elements
● Basic operations: push and pop
● Representation: sequential or linked
Stack
Examples of Stacks
● Insertion of new element onto the stack (push)
● Deletion of the top element from the stack (pop)
● Getting the size of stack
● Checking for empty stack
● Getting the top element without deleting it f
Operations
Top Operation
Types of Notations
 Infix expressions
 An operator appears between its operands
Example: a + b
 Prefix expressions
 An operator appears before its operands
Example: + a b
 Postfix expressions
 An operator appears after its operands
Example: a b +
Queue
● It is linear data structure
● It is collection of items – List
● Queue means line of items waiting for their turn
● Queue has two ends
 Elements are added at one end.
 Elements are removed from the other end
 First element inserted in list, will be the
first to be removed - FIFO
Insertion
Deletion
Representation Of Queues
1.Using an array
2.Using linked list
Implementation using Array
Cyclic Array
when item inserted to rair, tails’s pointer moves upwards
when item deleted, head’s pointer moves downwards
● It is collection of elements where elements are
stored according to the their priority levels
● Inserting and removing of elements from queue
is decided by the priority of the elements
● The two fundamental methods of a priority
queue P:
○ insertItem(k,e): Insert an element e with key k into P
○ removeMin(): Return and remove from P an element
with the smallest key.
Priority Queue
Deque
Data structure

Data structure

  • 1.
  • 2.
  • 3.
    Linked list • Alinked list is a linear data structure • A collection of nodes with various fields • It contains data field and Address field DATA Address / Pointer
  • 4.
    Linked List Types •SINGLY LINKED LIST • CIRCULAR SINGLY LINKED LIST • DOUBLY LINKED LISTS • CIRCULAR DOUBLY LINKED LISTS
  • 5.
    Singly Linked List •Each node has only one link part • Each link part contains the address of the next node in the list X 100 Y 200 Z NULL Head
  • 6.
    Inserting the nodein a SLL Insertion at the beginning
  • 7.
  • 8.
  • 9.
    Deleting a nodein SLL Deleting the first node Deleting the last node
  • 10.
  • 11.
    ● Stack -linearly ordered set of elements having the last-in, first-out (LIFO) discipline ● Operations are done on top of the stack only and we have no access to other elements ● Basic operations: push and pop ● Representation: sequential or linked Stack
  • 12.
  • 13.
    ● Insertion ofnew element onto the stack (push) ● Deletion of the top element from the stack (pop) ● Getting the size of stack ● Checking for empty stack ● Getting the top element without deleting it f Operations
  • 16.
  • 17.
    Types of Notations Infix expressions  An operator appears between its operands Example: a + b  Prefix expressions  An operator appears before its operands Example: + a b  Postfix expressions  An operator appears after its operands Example: a b +
  • 18.
    Queue ● It islinear data structure ● It is collection of items – List ● Queue means line of items waiting for their turn ● Queue has two ends  Elements are added at one end.  Elements are removed from the other end  First element inserted in list, will be the first to be removed - FIFO
  • 19.
  • 20.
    Representation Of Queues 1.Usingan array 2.Using linked list
  • 21.
  • 22.
    Cyclic Array when iteminserted to rair, tails’s pointer moves upwards when item deleted, head’s pointer moves downwards
  • 23.
    ● It iscollection of elements where elements are stored according to the their priority levels ● Inserting and removing of elements from queue is decided by the priority of the elements ● The two fundamental methods of a priority queue P: ○ insertItem(k,e): Insert an element e with key k into P ○ removeMin(): Return and remove from P an element with the smallest key. Priority Queue
  • 24.