Data Structures — Quick Notes
Computer Knowledge Section — Competitive Exam Preparation
What is a Data Structure?
A way of organizing and storing data so it can be accessed and used efficiently.
Types: Linear vs Non-Linear
• Linear: elements arranged sequentially — Array, Linked List, Stack, Queue
• Non-Linear: elements arranged hierarchically / interconnected — Tree, Graph
Key Structures
Array
• Fixed-size, contiguous memory, same data type
• Access by index — O(1) access time
• Insertion/deletion costly (shifting elements)
Linked List
• Nodes connected via pointers (data + address of next node)
• Types: Singly, Doubly, Circular
• Easy insertion/deletion, no random access (must traverse)
Stack
• LIFO (Last In First Out)
• Operations: push (insert), pop (remove)
• Uses: function calls, undo operations, expression evaluation, backtracking
Queue
• FIFO (First In First Out)
• Operations: enqueue (insert), dequeue (remove)
• Types: Simple, Circular, Priority Queue, Deque
• Uses: scheduling, buffering
Tree
• Hierarchical, node-based, starts from a root
• Binary Tree: each node has max 2 children
• Binary Search Tree (BST): left child < root < right child
• Uses: hierarchical data, searching (faster than linked list)
Graph
• Set of vertices (nodes) connected by edges
• Types: Directed/Undirected, Weighted/Unweighted
• Uses: networks, maps, social connections
Searching Algorithms
• Linear Search: checks each element — O(n)
• Binary Search: works on sorted data, divide and conquer — O(log n)
Sorting Algorithms (Commonly Asked)
Algorithm Best Case Worst Case
Bubble Sort O(n) O(n²)
Selection Sort O(n²) O(n²)
Insertion Sort O(n) O(n²)
Merge Sort O(n log n) O(n log n)
Quick Sort O(n log n) O(n²)
Commonly Asked Exam Points
• Stack follows LIFO, Queue follows FIFO — frequently confused in exams
• Array has fixed size; Linked List is dynamic
• Tree with n nodes has n − 1 edges
• Time complexity of accessing an array element: O(1)