DS Unit - 1
DS Unit - 1
📊 DATA STRUCTURES
📚 UNIT – 1
Examples include:
Integer - Whole numbers (positive, negative, zero)
Categories include:
Linear Data Structures - Elements arranged in sequential manner
Arrays, Linked Lists, Stacks, Queues
Characteristics:
Characteristics:
🟦 Array Representation:
Contiguous Memory - Elements stored in consecutive memory
addresses
🔹 Array Operations:
🎯 INSERTION:
At Beginning - Shift all existing elements to the right
🎯 DELETION:
From Beginning - Shift all remaining elements to the left
🎯 TRAVERSAL:
Sequential Access - Visit each element in order
Traversal Process:
🟢 Advantages of Arrays:
Fast Access - O(1) time complexity for element access
🔴 Disadvantages of Arrays:
Fixed Size - Cannot change size during runtime
Node Components:
🎯 DELETION:
From Beginning - Update head to second node, deallocate first node
🎯 DELETION OPERATIONS:
Bidirectional Deletion - Can delete from both directions
Efficient Removal - No need to traverse to find previous node
🎯 TRAVERSAL OPERATIONS:
Forward Traversal - From head to tail using next pointers
Backward Traversal - From tail to head using previous pointers
Bidirectional Search - Search from both ends simultaneously
Enhanced Navigation - More flexible movement through the list
At End - New node points to head, previous end points to new node
🎯 DELETION OPERATIONS:
From Beginning - Update last node to point to new first node
From End - Update second-last node to point to head
Preserve Structure - Maintain circular linking after deletion
🎯 TRAVERSAL OPERATIONS:
Controlled Traversal - Use counter or marker to avoid infinite loops
Starting Point - Begin from any node and return to the same node
Termination Condition - Stop when reaching the starting node again
One
🔸 Singly
Dynamic/Scattered O(n) O(1) at head pointer per
Linked List
node
🔸 Two
Doubly Dynamic/Scattered O(n) O(1) at both ends pointers
Linked List per node
🔸 One/Two
O(1) with proper
Circular Dynamic/Scattered O(n) pointers
reference
Linked List per node