Short Quens
Short Quens
DATA STRUCTURE
(BCS301 )
(Important Short-Answer Questions (2 Marks))
Topic
Data Structures Basics
Q1. Define the term Data Structure. List some linear and non-linear
data structures with applications.
Ans:
A data structure is a way of organizing and storing data so that it can be
accessed and modified efficiently.
Linear Data Structures: Arrays, Linked Lists, Stacks, Queues (used in memory
management, scheduling).
Non-Linear Data Structures: Trees, Graphs (used in hierarchical databases,
network routing).
Q2. Define Time-Space trade-off.
Ans:
The Time-Space Trade-off is a concept in computing where you sacrifice
one resource (time or space) to improve the other.
• If you use more memory (space), you can often make a program run faster.
• If you use less memory, the program may take more time to execute.
Q3. What are the advantages and disadvantages of arrays over linked
lists?
Ans:
Advantages: Fast access using index, better cache locality.
Disadvantages: Fixed size, costly insertions and deletions.
Q4. Differentiate between an Array and a Linked List.
Ans:
Array: Fixed size, contiguous memory, random access.
Linked List: Dynamic size, non-contiguous memory, sequential access.
Q5. What are the various asymptotic notations?
Ans:
Ans:
Sequential Search: Searches one-by-one, O(n) time complexity.
Binary Search: Works on sorted data, divides array in half, O(log n) time
complexity.
Q14. Differentiate between internal and external sorting.
Ans:
Sequential Search: Searches one-by-one, O(n) time complexity.
Binary Search: Works on sorted data, divides array in half, O(log n) time
complexity.
Q15. Give an example of one stable and one unstable sorting
technique.
Ans:
Stable: Merge Sort (maintains order of equal elements).
Unstable: Quick Sort (order of equal elements may change).
Q16. How does the choice of pivot affect the running time of
quicksort?
Ans:
Choosing a good pivot (e.g., median) results in O(n log n) performance,
while a bad pivot (e.g., first element in sorted array) results in O(n²).
Q17. How does the choice of pivot affect the running time of
quicksort?
Ans:
Choosing a good pivot (e.g., median) results in O(n log n) performance,
while a bad pivot (e.g., first element in sorted array) results in O(n²).
Topic
Trees (BST, AVL, Threaded Trees, and
Expression Trees)
Q18. Discuss the concept of "successor" and “predecessor” in a Binary
Search Tree
Ans:
Successor: The next largest node in in-order traversal.
Predecessor: The previous smaller node in in-order traversal.
Q19. Draw the binary search tree for the sequence: 11, 47, 81, 9, 61,
10, 12.
Ans:
Q20. Write advantages of an AVL tree over a Binary Search Tree.
Ans:
Ensures balanced height (O(log n) operations).
Prevents skewed trees (unbalanced BSTs can degrade to O(n)).
Q21. What is the importance of a threaded binary tree?
Ans:
A threaded binary tree stores extra links to make in-order traversal
faster without recursion or a stack.
Q22. Construct an expression tree for (a - b) / ((c * d) + e)?
Ans:
Topic
Graph
Q23. List the different types of graph representations.
Ans:
1. Adjacency Matrix (O(n²) space)
2. Adjacency List (O(V+E) space)
Q24. Write an algorithm for Breadth-First Search (BFS) traversal of a
graph.
Ans:
1. Start from a given node and enqueue it.
2. Mark the node as visited and dequeue it.
3. Enqueue all unvisited adjacent nodes.
4. Repeat steps 2 and 3 until the queue is empty.
Q25. Compute the transitive closure of a given graph.
Ans:
Topic
Recursion
Q26. Explain Tail Recursion with a suitable example.
Ans:
A recursive function where the last operation is the recursive call.
void tailRec(int n) {
if (n == 0) return;
printf("%d ", n);
tailRec(n-1); // Recursive call is last operation
}
Q27. Which data structure is used to perform recursion and why?
Ans:
A stack is used because it maintains function call frames and supports
LIFO execution.
Topic
Miscellaneous
Q28. What are the two different forms of hashing?
Ans:
Static Hashing (fixed-sized table).
Dynamic Hashing (resizable, e.g., Extendible Hashing).
Q29. What is min heap?
Ans:
A binary heap where the smallest element is at the root, and each
parent is smaller than its children.