Current Affairs

IGNOU MCS-208 (Data Structures and Algorithms)

Read the important current affairs of 15 July 2026 for SSC, Banking, UPSC, Railway and all competitive exams.

2 Sep 2025 5 Min Read Quizer Team 83 Views

02

September 2025


Q1. What is a data structure? Explain its types with examples.

Answer:
A data structure is a way of organizing, managing, and storing data so that it can be used efficiently. It defines the relationship between data elements and the operations that can be performed on them.

Types of Data Structures:

  1. Primitive Data Structures: Basic types like int, float, char, boolean. Example: int age = 25;.

  2. Non-Primitive Data Structures:

    • Linear: Data arranged sequentially. Examples: Arrays, Linked Lists, Stacks, Queues.

    • Non-Linear: Data organized hierarchically. Examples: Trees, Graphs.

Efficient use of data structures improves program performance in terms of time complexity and memory utilization.


Q2. Differentiate between linear and non-linear data structures.

Answer:

  • Linear Data Structures:

    • Elements are arranged sequentially.

    • Easy to traverse.

    • Examples: Arrays, Linked Lists, Queues, Stacks.

  • Non-Linear Data Structures:

    • Elements are connected hierarchically or through relationships.

    • Traversal is complex.

    • Examples: Trees, Graphs.

Comparison: In an array, elements are accessed in order, but in a tree, you access nodes based on hierarchy (parent → child).


Q3. Explain the concept of time complexity and space complexity.

Answer:

  • Time Complexity: The computational complexity that describes the amount of time an algorithm takes as a function of input size n.

    • Common notations: O(1) (constant), O(n) (linear), O(log n) (logarithmic), O(n²) (quadratic).

  • Space Complexity: Amount of memory an algorithm requires. Includes:

    • Fixed part (instructions, constants).

    • Variable part (dynamic memory allocation, recursion stack).

Example: Binary search has O(log n) time and O(1) space complexity.


Q4. What is an array? What are its advantages and disadvantages?

Answer:
An array is a collection of elements of the same type stored in contiguous memory locations.

  • Advantages:

    1. Direct access using index.

    2. Simple implementation.

    3. Efficient traversal.

  • Disadvantages:

    1. Fixed size – cannot grow dynamically.

    2. Insertion/Deletion costly (shifting needed).

    3. Wastage of memory if size is large but few elements used.

Example: int marks[5] = {90, 85, 78, 92, 88};.


Q5. Explain linked list and its types.

Answer:
A linked list is a collection of nodes where each node contains data and a pointer to the next node. Unlike arrays, linked lists are dynamic.

Types:

  1. Singly Linked List: Each node points to the next.

  2. Doubly Linked List: Each node has pointers to both previous and next nodes.

  3. Circular Linked List: Last node points back to the first.

Advantage: Dynamic size.
Disadvantage: Sequential access only, uses extra memory for pointers.


Q6. Compare arrays and linked lists.

Answer:

  • Memory: Arrays use contiguous memory, linked lists use scattered memory.

  • Size: Arrays are fixed, linked lists are dynamic.

  • Access: Arrays allow direct access by index; linked lists require traversal.

  • Insertion/Deletion: Costly in arrays (shifting), easier in linked lists (pointer update).

Example: For implementing a queue, linked lists are more efficient than arrays.


Q7. What is a stack? Explain its applications.

Answer:
A stack is a linear data structure that follows LIFO (Last In First Out) principle.

Operations:

  • push(x) → Insert element.

  • pop() → Remove top element.

  • peek() → View top element.

Applications:

  1. Expression evaluation (postfix, prefix).

  2. Undo operation in editors.

  3. Backtracking (maze solving).

  4. Function call management (recursion stack).

Example: Browser back button uses stack.


Q8. Explain queue and its types.

Answer:
A queue is a linear data structure that follows FIFO (First In First Out) principle.

Types:

  1. Simple Queue: Insert at rear, delete at front.

  2. Circular Queue: Last position connects to the first to optimize memory.

  3. Priority Queue: Each element has a priority, higher priority served first.

  4. Deque (Double-Ended Queue): Insertion and deletion allowed at both ends.

Example: Printer queue, OS process scheduling.


Q9. Explain binary tree and its types.

Answer:
A binary tree is a hierarchical structure where each node has at most two children (left and right).

Types:

  1. Full Binary Tree: Every node has 0 or 2 children.

  2. Complete Binary Tree: All levels filled except possibly last.

  3. Perfect Binary Tree: All levels fully filled.

  4. Binary Search Tree (BST): Left child < root>

Example: A BST allows efficient searching in O(log n).


Q10. Explain graph representation methods.

Answer:
A graph consists of vertices (nodes) and edges (connections).

Representation:

  1. Adjacency Matrix:

    • 2D array representation.

    • matrix[i][j] = 1 if edge exists, else 0.

    • Easy but uses O(n²) space.

  2. Adjacency List:

    • Array of linked lists.

    • Efficient for sparse graphs.

Example: Social networks use graph representation where users = nodes, friendships = edges.


Q11. Explain recursion with examples. What are its advantages and disadvantages?

Answer:
Recursion is a programming technique where a function calls itself directly or indirectly to solve a problem.

Example: Factorial calculation.

int factorial(int n) { if (n == 0) return 1; return n * factorial(n-1); }

Advantages:

  1. Reduces code complexity (shorter code).

  2. Naturally fits problems like tree traversal, Fibonacci, Tower of Hanoi.

Disadvantages:

  1. High memory usage (stack overhead).

  2. Slower due to multiple function calls.

  3. May cause stack overflow for deep recursion.


Q12. Differentiate between recursion and iteration.

Answer:

  • Recursion: Function calls itself until base condition is met. Uses function call stack.

  • Iteration: Repetition of steps using loops (for, while).

Example:

  • Recursion for factorial: factorial(n) = n * factorial(n-1)

  • Iteration for factorial:

fact = 1; for (i=1; i<=n; i++) fact *= i;

Comparison:

  • Recursion is elegant but costly in memory.

  • Iteration is faster and memory-efficient but sometimes less intuitive.


Q13. What is a binary search tree (BST)? Explain operations on BST.

Answer:
A BST is a binary tree where:

  • Left child < Parent>

  • Right child > Parent

Operations:

  1. Insertion: Traverse tree and place node at correct position.

  2. Searching: Compare key with root; go left if smaller, right if larger.

  3. Deletion:

    • Node with no child → Delete directly.

    • Node with one child → Replace with child.

    • Node with two children → Replace with inorder successor/predecessor.

Time Complexity: Average O(log n), Worst O(n) (skewed tree).


Q14. What are tree traversal methods? Explain with examples.

Answer:
Tree traversal means visiting all nodes systematically.

Types:

  1. Inorder (Left, Root, Right): Produces sorted order in BST.

  2. Preorder (Root, Left, Right): Used for copying trees.

  3. Postorder (Left, Right, Root): Used for deleting/freeing trees.

  4. Level Order: BFS using queue.

Example (Inorder for BST [5, 3, 7, 2, 4]): → Output: 2, 3, 4, 5, 7.


Q15. What is hashing? Explain collision resolution techniques.

Answer:
Hashing maps keys to positions in a table using a hash function h(k).

Problem: Collisions (two keys hash to same slot).

Collision Resolution:

  1. Chaining: Each slot holds a linked list of keys.

  2. Open Addressing:

    • Linear Probing: Next empty slot (h(k)+i) mod m.

    • Quadratic Probing: (h(k)+i²) mod m.

    • Double Hashing: Use second hash function.

Example: Storing employee IDs in hash table.


Q16. Explain bubble sort with algorithm and complexity.

Answer:
Bubble Sort: Repeatedly swaps adjacent elements if they are in wrong order.

Algorithm:

for i = 0 to n-1 for j = 0 to n-i-1 if arr[j] > arr[j+1] swap(arr[j], arr[j+1])

Complexity:

  • Best Case (sorted): O(n)

  • Worst Case: O(n²)

  • Space: O(1)

Use: Small datasets, educational purposes.


Q17. Explain quick sort algorithm with example.

Answer:
Quick Sort: Divide & Conquer technique.

Steps:

  1. Select pivot element.

  2. Partition array into left (≤ pivot) and right (> pivot).

  3. Recursively apply on subarrays.

Example:
Array [9, 3, 7, 1] → Pivot=9 → Partition → [3,1,7] | [9] → Sorted recursively → [1,3,7,9].

Complexity:

  • Average: O(n log n)

  • Worst (if array sorted & bad pivot): O(n²)

  • Space: O(log n) (recursion).


Q18. Explain merge sort algorithm with complexity.

Answer:
Merge Sort: Divide & Conquer.

Steps:

  1. Divide array into two halves.

  2. Recursively sort both halves.

  3. Merge sorted halves.

Example: [8,4,2,6] → [8,4] & [2,6] → [4,8] & [2,6] → [2,4,6,8].

Complexity:

  • Best, Average, Worst: O(n log n)

  • Space: O(n) (auxiliary arrays).

Use: Stable sort, good for linked lists.


Q19. Compare quick sort and merge sort.

Answer:

  • Quick Sort:

    • In-place (less memory).

    • Fast average case (O(n log n)).

    • Worst-case O(n²).

    • Not stable.

  • Merge Sort:

    • Requires O(n) extra memory.

    • Always O(n log n).

    • Stable.

    • Better for linked lists and external sorting.

Conclusion: Quick sort is faster in practice for arrays, merge sort better for stability and large datasets.


Q20. What is graph traversal? Explain BFS and DFS.

Answer:
Graph traversal = Visiting all nodes systematically.

  • BFS (Breadth First Search):

    • Uses queue.

    • Visits level by level.

    • Example: Social network friend suggestions.

  • DFS (Depth First Search):

    • Uses stack (recursion).

    • Goes deep before backtracking.

    • Example: Maze solving.

Complexity: O(V+E), where V=vertices, E=edges.


Q21. Explain Dijkstra’s algorithm for shortest path.

Answer:
Dijkstra’s Algorithm finds the shortest path from a source node to all other nodes in a weighted graph (with non-negative edges).

Steps:

  1. Assign distance 0 to source, ∞ to all others.

  2. Mark source as visited.

  3. For each neighbor, update distance if smaller.

  4. Pick the unvisited node with smallest distance.

  5. Repeat until all nodes visited.

Example:
Graph: A→B(4), A→C(2), C→B(1).
Shortest path A→B = 3 via C.

Complexity: O(V²) using adjacency matrix, O((V+E) log V) with min-heap.


Q22. Explain Prim’s algorithm for minimum spanning tree (MST).

Answer:
Prim’s Algorithm builds MST by growing one edge at a time.

Steps:

  1. Start with any node.

  2. Select the smallest weight edge connecting tree to a new node.

  3. Repeat until all nodes are included.

Example:
Graph with edges (A-B:2, B-C:3, A-C:1).
MST = edges (A-C:1, C-B:3).

Complexity: O(V²) (adjacency matrix), O((V+E) log V) (priority queue).


Q23. Differentiate between Prim’s and Kruskal’s algorithm.

Answer:

  • Prim’s Algorithm:

    • Starts from a node, grows tree.

    • Uses priority queue for edge selection.

    • Works well with dense graphs.

  • Kruskal’s Algorithm:

    • Sorts edges by weight, adds if no cycle (using Union-Find).

    • Works well with sparse graphs.

Both produce MST but differ in approach.


Q24. What is a heap? Explain heap operations.

Answer:
A Heap is a complete binary tree with heap property:

  • Max Heap: Parent ≥ Children.

  • Min Heap: Parent ≤ Children.

Operations:

  1. Insertion: Add at bottom, bubble up. O(log n).

  2. Deletion (root): Replace with last element, bubble down. O(log n).

  3. Heapify: Adjust nodes to maintain heap.

Use: Priority Queue, Heap Sort.


Q25. Explain Heap Sort algorithm.

Answer:
Steps:

  1. Build Max Heap from array.

  2. Swap root with last element.

  3. Reduce heap size, heapify root.

  4. Repeat until sorted.

Example: [4,10,3,5] → Max Heap [10,5,3,4] → swap → [4,5,3,10] → sorted [3,4,5,10].

Complexity:

  • Build Heap: O(n)

  • Each deletion: O(log n)

  • Overall: O(n log n)

  • In-place, not stable.


Q26. What is a B-Tree? Why is it used in databases?

Answer:
A B-Tree is a balanced multi-way search tree used for indexing in databases.

Properties:

  • Each node has multiple keys and children.

  • Keys are stored in sorted order.

  • All leaves are at the same level.

  • Height is log(n), ensuring efficiency.

Use in Databases:

  • Efficient disk access (large nodes fit blocks).

  • Good for range queries and indexing.


Q27. What is an AVL tree? Explain rotations.

Answer:
AVL Tree = Self-balancing BST. For each node:
Balance Factor = height(left) – height(right) ∈ {-1,0,1}.

Rotations to balance:

  1. LL Rotation: Right rotation.

  2. RR Rotation: Left rotation.

  3. LR Rotation: Left then Right.

  4. RL Rotation: Right then Left.

Time Complexity: O(log n) for search, insert, delete.


Q28. Differentiate between AVL Tree and Red-Black Tree.

Answer:

  • AVL Tree:

    • Strictly balanced (BF ∈ {-1,0,1}).

    • Faster search O(log n).

    • More rotations → slower insert/delete.

  • Red-Black Tree:

    • Loosely balanced (height ≤ 2*log n).

    • Faster insert/delete.

    • Used in libraries (C++ STL map/set, Java TreeMap).


Q29. Explain the Floyd-Warshall algorithm.

Answer:
Floyd-Warshall finds shortest paths between all pairs of vertices.

Steps:

  • Initialize distance matrix with edge weights.

  • For each vertex k, update dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]).

Example:
Graph with A→B=3, B→C=2, A→C=10.
Result: A→C = 5 (via B).

Complexity: O(V³).
Use: Dense graphs, all-pairs shortest paths.


Q30. Differentiate between Greedy and Dynamic Programming approaches.

Answer:

  • Greedy:

    • Makes local optimum choice at each step.

    • Example: Kruskal’s MST, Huffman coding.

    • Faster but may fail for some problems.

  • Dynamic Programming (DP):

    • Breaks into subproblems, stores solutions (memoization).

    • Example: Fibonacci, shortest path (Bellman-Ford).

    • Always optimal but requires more memory.


      Q31. What is Divide and Conquer? Give examples.

      Answer:
      Divide and Conquer is an algorithmic paradigm:

    • Divide → Break problem into subproblems.

    • Conquer → Solve subproblems recursively.

    • Combine → Merge results to form solution.

    Examples:

  • Merge Sort (divide array, sort halves, merge).

  • Quick Sort (choose pivot, partition, recurse).

  • Binary Search (divide search space).

Advantages: Efficient for recursive problems, parallelizable.
Complexity: Usually O(n log n).


Q32. Explain the Master Theorem in algorithm analysis.

Answer:
For recurrence:
T(n) = aT(n/b) + f(n)

Where:

  • a = number of subproblems,

  • n/b = subproblem size,

  • f(n) = cost of work outside recursion.

Cases:

  1. If f(n) = O(n^log_b(a) - ε) → T(n) = Θ(n^log_b(a))

  2. If f(n) = Θ(n^log_b(a)) → T(n) = Θ(n^log_b(a) log n)

  3. If f(n) = Ω(n^log_b(a) + ε) → T(n) = Θ(f(n))

Example: Merge Sort: T(n)=2T(n/2)+O(n) → O(n log n).


Q33. Differentiate between iterative and recursive solutions.

Answer:

  • Iterative:

    • Uses loops.

    • Saves memory (no call stack).

    • Example: factorial with for loop.

  • Recursive:

    • Function calls itself.

    • More intuitive for tree/graph problems.

    • Example: factorial(n) = n * factorial(n-1).

Trade-off: Recursion is easier to implement, but iteration is faster in terms of memory.


Q34. Explain Binary Search with example.

Answer:
Binary Search finds an element in sorted array.

Steps:

  1. Set low=0, high=n-1.

  2. Find mid = (low+high)/2.

  3. If key=arr[mid], return mid.

  4. If key < arr>

  5. Else search right.

Example: Search 25 in [10,20,25,30,40].

  • mid=25 → found at index 2.

Complexity: O(log n).


Q35. What is Hashing? Explain different collision resolution techniques.

Answer:
Hashing: Maps keys to positions in hash table using hash function h(k).

Collisions occur when two keys map to same index.

Collision resolution methods:

  1. Chaining: Store multiple values at same index (linked list).

  2. Open Addressing:

    • Linear probing: h(k)+i.

    • Quadratic probing: h(k)+i².

    • Double hashing: h1(k)+i*h2(k).

Complexity: O(1) average for search/insert/delete.


Q36. Differentiate between Hash Table and Binary Search Tree (BST).

Answer:

  • Hash Table:

    • Average O(1) search.

    • Unordered, no range queries.

    • Efficient for lookup by key.

  • BST:

    • O(log n) search (balanced).

    • Maintains sorted order.

    • Good for range queries.

Choice: Use hash table for exact search, BST for ordered data.


Q37. What is a Graph Traversal? Explain BFS.

Answer:
Graph Traversal = visiting nodes systematically.

BFS (Breadth-First Search):

  • Uses Queue.

  • Start from source, visit neighbors level by level.

Example:
Graph: A-B, A-C, B-D, C-E.
BFS order from A: A → B → C → D → E.

Complexity: O(V+E).
Use: Shortest path in unweighted graph.


Q38. Explain Depth-First Search (DFS) with example.

Answer:
DFS:

  • Uses Stack (or recursion).

  • Explore as far as possible along one path before backtracking.

Example:
Graph: A-B, A-C, B-D, C-E.
DFS from A: A → B → D → C → E.

Complexity: O(V+E).
Use: Detect cycles, topological sort, connected components.


Q39. Differentiate between BFS and DFS.

Answer:

  • BFS:

      Why This Content Matters

      This content is prepared to help students and competitive-exam aspirants understand important topics, revise key information, and strengthen their exam preparation.

      • Quickly revise important facts and concepts
      • Improve General Knowledge and exam awareness
      • Support preparation for competitive and government exams
      • Build a consistent and effective study routine
      Quizer Team
      About the Author

      Quizer Team

      The Quizer Team creates exam-focused educational content, current affairs, general knowledge, study notes, and preparation resources to help students and competitive-exam aspirants learn, practice, and stay updated.

      Educational Content Exam Focused Learning Resources

Related Post

Current Affairs
24 Sep 2026 153
Read More
Current Affairs
3 Sep 2026 323
Read More
Current Affairs
27 Aug 2026 560
Read More