0% found this document useful (0 votes)
11 views37 pages

Short Quens

The document contains important short-answer questions related to Data Structures, covering topics such as definitions, comparisons, and characteristics of various data structures including arrays, linked lists, stacks, queues, trees, and graphs. It also discusses concepts like time-space trade-off, sorting techniques, and recursion. Additionally, it includes algorithms and advantages of different data structures, such as AVL trees and binary search trees.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views37 pages

Short Quens

The document contains important short-answer questions related to Data Structures, covering topics such as definitions, comparisons, and characteristics of various data structures including arrays, linked lists, stacks, queues, trees, and graphs. It also discusses concepts like time-space trade-off, sorting techniques, and recursion. Additionally, it includes algorithms and advantages of different data structures, such as AVL trees and binary search trees.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

AKTU

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:

• Big O (O): Worst-case time complexity.


• Big Omega (Ω): Best-case time complexity.
• Big Theta (Θ): Average-case time complexity.
Q6. Define best case, average case, and worst case for analyzing the
complexity of a program?
Ans:

• Best Case: Minimum steps required.


• Average Case: Expected steps for random input.
• Worst Case: Maximum steps needed.
Q7. Rank the following typical bounds in increasing order: O(log n),
O(n⁴), O(1), O(n² log n).
Ans:

O(1) < O(log n) < O(n² log n) < O(n⁴)


Q8. What does the following recursive function do for a given Linked
List with first node as head?
Ans:

void fun1(struct node* head)


{
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data);
}
Q9. Define a sparse matrix. Suggest a space efficient representation
for sparse matrices?
Ans:

A sparse matrix is a matrix in which most of the elements are zero.


Q10. List the advantages of doubly linked list over single linked list.
Ans:
Topic
Stack and Queue
Q11. Explain the circular queue. What is the condition if a circular
queue is full?
Ans:
A circular queue is a queue where the last position is connected to the
first, forming a circle.
Full condition: (rear + 1) % size == front
Empty condition: front == -1
Q12. Why are parentheses needed in infix expressions but not in postfix
expressions?
Ans:
In infix expressions, operators appear between operands (e.g., A + B * C). Since
different operators (+ , * , - , /) have different precedence (priority), parentheses are
needed to clarify which operation should be performed first.
Example:
Consider the infix expression:
A+B*C
Without parentheses, multiplication (*) has higher precedence than addition (+).
So, this is understood as: A + (B * C).
If we want addition to happen first, we must use parentheses:
(A + B) * C
Why No Parentheses in Postfix?
In postfix expressions, the order is clear because operators come after operands
(e.g., A B C * +).
Topic
Searching and Sorting
Q13. Differentiate between sequential search and binary search.

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.

You might also like