📊 130+ Questions • Updated 2026

Data Structures Multiple Choice Questions

Master Data Structures with 130+ curated MCQs covering arrays, linked lists, stacks, queues, trees, graphs, hashing, sorting, and searching. Perfect for exams, interviews, and placements.

📚10 Topics
130+ Questions
🎯Exam Ready

📚Explore Data Structures Topics

📝Data Structures MCQs(131 questions)

1

What is the index of the first element in an array?

  • A

    0

  • B

    1

  • C

    -1

  • D

    Depends on language

Show Answer
A. 0
2

Which of the following operations is efficient on an array?

  • A

    Access by index

  • B

    Insertion at the beginning

  • C

    Deletion from the middle

  • D

    Searching unsorted

Show Answer
A. Access by index
3

What is a multidimensional array?

  • A

    An array of arrays

  • B

    A one-dimensional array

  • C

    A dynamic array

  • D

    A sorted array

Show Answer
A. An array of arrays
4

What is the time complexity of searching an element in an unsorted array?

  • A

    O(1)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
C. O(n)
5

What is the time complexity of inserting an element at the end of a dynamic array?

  • A

    O(1) amortized

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
A. O(1) amortized
6

Which of the following is true about a circular array?

  • A

    It uses a fixed-size buffer

  • B

    It can be implemented using modulo

  • C

    Both A and B

  • D

    It is a linked list

Show Answer
C. Both A and B
7

What is a linked list?

  • A

    A linear data structure where elements are stored at contiguous memory locations

  • B

    A linear data structure where elements are stored at non-contiguous memory locations

  • C

    A data structure that uses hashing

  • D

    A data structure that uses trees

Show Answer
B. A linear data structure where elements are stored at non-contiguous memory locations
8

What is the time complexity of inserting a node at the beginning of a singly linked list?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
A. O(1)
9

What is the time complexity of searching for an element in a singly linked list?

  • A

    O(1)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
C. O(n)
10

What is a doubly linked list?

  • A

    Each node has two pointers: next and prev

  • B

    Each node has only one pointer

  • C

    It is a circular list

  • D

    It is a sorted list

Show Answer
A. Each node has two pointers: next and prev
11

What is the advantage of a doubly linked list over a singly linked list?

  • A

    Can traverse in both directions

  • B

    Uses less memory

  • C

    Faster insertion

  • D

    Easier to implement

Show Answer
A. Can traverse in both directions
12

What is a circular linked list?

  • A

    The last node points to the first node

  • B

    The list has no end

  • C

    Both A and B

  • D

    It uses circular array

Show Answer
C. Both A and B
13

What is a stack?

  • A

    A data structure that follows LIFO (Last In First Out)

  • B

    A data structure that follows FIFO (First In First Out)

  • C

    A data structure that stores elements in sorted order

  • D

    A data structure that uses hashing

Show Answer
A. A data structure that follows LIFO (Last In First Out)
14

Which operation is used to add an element to a stack?

  • A

    push

  • B

    pop

  • C

    peek

  • D

    enqueue

Show Answer
A. push
15

Which operation is used to remove an element from a stack?

  • A

    pop

  • B

    push

  • C

    top

  • D

    dequeue

Show Answer
A. pop
16

What is the time complexity of push and pop operations in a stack implemented using an array?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
A. O(1)
17

Which of the following is a common application of stacks?

  • A

    Expression evaluation

  • B

    Function call management

  • C

    Undo operations

  • D

    All of the above

Show Answer
D. All of the above
18

What is the meaning of stack overflow?

  • A

    Trying to push onto a full stack

  • B

    Trying to pop from an empty stack

  • C

    Stack memory is corrupted

  • D

    Stack pointer is lost

Show Answer
A. Trying to push onto a full stack
19

What is a queue?

  • A

    A data structure that follows FIFO (First In First Out)

  • B

    A data structure that follows LIFO

  • C

    A data structure that sorts elements

  • D

    A data structure for priority

Show Answer
A. A data structure that follows FIFO (First In First Out)
20

Which operation is used to add an element to a queue?

  • A

    enqueue

  • B

    dequeue

  • C

    push

  • D

    pop

Show Answer
A. enqueue
21

Which operation is used to remove an element from a queue?

  • A

    dequeue

  • B

    enqueue

  • C

    front

  • D

    rear

Show Answer
A. dequeue
22

What is a circular queue?

  • A

    A queue where the last position wraps around to the first

  • B

    A queue implemented using a circular linked list

  • C

    A queue with no end

  • D

    A queue that uses priority

Show Answer
A. A queue where the last position wraps around to the first
23

What is a priority queue?

  • A

    Each element has a priority; higher priority elements are dequeued first

  • B

    Elements are enqueued in priority order

  • C

    It is implemented using a heap

  • D

    All of the above

Show Answer
D. All of the above
24

What is the time complexity of enqueue and dequeue in a simple queue implemented with an array?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
A. O(1)
25

What is a tree data structure?

  • A

    A hierarchical data structure with a root and child nodes

  • B

    A linear data structure

  • C

    A cyclic data structure

  • D

    A data structure with no ordering

Show Answer
A. A hierarchical data structure with a root and child nodes
26

What is a binary tree?

  • A

    Each node has at most two children

  • B

    Each node has exactly two children

  • C

    Each node has any number of children

  • D

    It is a tree with only one node

Show Answer
A. Each node has at most two children
27

What is a binary search tree (BST)?

  • A

    Left child < parent < right child

  • B

    Left child > parent > right child

  • C

    All nodes are equal

  • D

    No ordering is maintained

Show Answer
A. Left child < parent < right child
28

What is the time complexity of searching in a balanced BST?

  • A

    O(1)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
B. O(log n)
29

What is a tree traversal?

  • A

    Visiting each node in the tree in a specific order

  • B

    Adding nodes to the tree

  • C

    Removing nodes from the tree

  • D

    Finding the height of the tree

Show Answer
A. Visiting each node in the tree in a specific order
30

What is the difference between a full binary tree and a complete binary tree?

  • A

    Full: every node has 0 or 2 children; Complete: all levels filled except possibly last

  • B

    Full: all levels filled; Complete: every node has 2 children

  • C

    They are the same

  • D

    Full is a subset of complete

Show Answer
A. Full: every node has 0 or 2 children; Complete: all levels filled except possibly last
31

What is a heap data structure?

  • A

    A specialized tree-based structure that satisfies the heap property

  • B

    A queue with priorities

  • C

    A binary tree with no ordering

  • D

    A linked list

Show Answer
A. A specialized tree-based structure that satisfies the heap property
32

What is a min-heap?

  • A

    Parent is less than or equal to children

  • B

    Parent is greater than or equal to children

  • C

    Children are less than parent

  • D

    No ordering property

Show Answer
A. Parent is less than or equal to children
33

What is a max-heap?

  • A

    Parent is greater than or equal to children

  • B

    Parent is less than or equal to children

  • C

    Children are greater than parent

  • D

    No ordering

Show Answer
A. Parent is greater than or equal to children
34

What is the time complexity to find the maximum element in a max-heap?

  • A

    O(1)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
A. O(1) (it is the root)
35

What is the time complexity to insert an element into a heap?

  • A

    O(1)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
B. O(log n)
36

Which data structure is commonly used to implement a priority queue?

  • A

    Heap

  • B

    Array

  • C

    Linked List

  • D

    Stack

Show Answer
A. Heap
37

What is a graph?

  • A

    A data structure consisting of vertices and edges

  • B

    A tree with no cycles

  • C

    A linear data structure

  • D

    A hashing structure

Show Answer
A. A data structure consisting of vertices and edges
38

What is a directed graph?

  • A

    Edges have a direction

  • B

    Edges have no direction

  • C

    All vertices are connected

  • D

    It is a tree

Show Answer
A. Edges have a direction
39

What is the degree of a vertex in an undirected graph?

  • A

    The number of edges incident to it

  • B

    The number of vertices connected to it

  • C

    The number of outgoing edges

  • D

    The number of incoming edges

Show Answer
A. The number of edges incident to it
40

What is the time complexity of Breadth-First Search (BFS) on a graph with V vertices and E edges?

  • A

    O(V + E)

  • B

    O(V^2)

  • C

    O(E^2)

  • D

    O(V * E)

Show Answer
A. O(V + E)
41

What is the time complexity of Depth-First Search (DFS) on a graph with V vertices and E edges?

  • A

    O(V + E)

  • B

    O(V^2)

  • C

    O(E^2)

  • D

    O(V * E)

Show Answer
A. O(V + E)
42

Which algorithm is used to find the shortest path in an unweighted graph?

  • A

    BFS

  • B

    DFS

  • C

    Dijkstra

  • D

    Bellman-Ford

Show Answer
A. BFS
43

What is hashing?

  • A

    A technique to map data to a fixed-size value

  • B

    A technique to sort data

  • C

    A technique to link nodes

  • D

    A technique to traverse trees

Show Answer
A. A technique to map data to a fixed-size value
44

What is a hash table?

  • A

    A data structure that uses a hash function to map keys to buckets

  • B

    A sorted array

  • C

    A linked list

  • D

    A tree

Show Answer
A. A data structure that uses a hash function to map keys to buckets
45

What is a collision in hashing?

  • A

    Two different keys map to the same index

  • B

    Two same keys map to different indices

  • C

    The hash table is full

  • D

    The hash function is not defined

Show Answer
A. Two different keys map to the same index
46

What is the load factor of a hash table?

  • A

    Number of elements / table size

  • B

    Table size / number of elements

  • C

    Number of collisions

  • D

    Hash function output

Show Answer
A. Number of elements / table size
47

Which collision resolution technique uses linked lists?

  • A

    Chaining

  • B

    Open addressing

  • C

    Double hashing

  • D

    Linear probing

Show Answer
A. Chaining
48

What is the average time complexity for search, insert, and delete in a well-designed hash table?

  • A

    O(1)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
A. O(1)
49

What is the time complexity of Bubble Sort in the worst case?

  • A

    O(n)

  • B

    O(n log n)

  • C

    O(n^2)

  • D

    O(log n)

Show Answer
C. O(n^2)
50

What is the time complexity of Merge Sort in all cases?

  • A

    O(n log n)

  • B

    O(n^2)

  • C

    O(n)

  • D

    O(log n)

Show Answer
A. O(n log n)
51

Which sorting algorithm has the best average-case time complexity?

  • A

    Quick Sort

  • B

    Bubble Sort

  • C

    Selection Sort

  • D

    Insertion Sort

Show Answer
A. Quick Sort (O(n log n) average)
52

What is the time complexity of Quick Sort in the worst case?

  • A

    O(n log n)

  • B

    O(n^2)

  • C

    O(n)

  • D

    O(log n)

Show Answer
B. O(n^2)
53

Which sorting algorithm is stable?

  • A

    Merge Sort

  • B

    Quick Sort

  • C

    Heap Sort

  • D

    Selection Sort

Show Answer
A. Merge Sort
54

Which sorting algorithm is in-place?

  • A

    Quick Sort

  • B

    Merge Sort

  • C

    Radix Sort

  • D

    Counting Sort

Show Answer
A. Quick Sort (can be in-place)
55

What is the time complexity of linear search?

  • A

    O(1)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
C. O(n)
56

What is the time complexity of binary search?

  • A

    O(1)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
B. O(log n)
57

What is the prerequisite for binary search?

  • A

    The array must be sorted

  • B

    The array must be unsorted

  • C

    The array must contain unique elements

  • D

    The array must be circular

Show Answer
A. The array must be sorted
58

What is the time complexity of interpolation search?

  • A

    O(1)

  • B

    O(log log n) average

  • C

    O(n)

  • D

    O(n^2)

Show Answer
B. O(log log n) average
59

What is the worst-case time complexity of interpolation search?

  • A

    O(n)

  • B

    O(log n)

  • C

    O(1)

  • D

    O(n^2)

Show Answer
A. O(n)
60

Which search algorithm works on the principle of divide and conquer?

  • A

    Binary Search

  • B

    Linear Search

  • C

    Jump Search

  • D

    Exponential Search

Show Answer
A. Binary Search
61

What is the result of rotating an array by one position?

  • A

    The first element moves to the last

  • B

    The last element moves to the first

  • C

    All elements shift right

  • D

    All elements shift left

Show Answer
A. The first element moves to the last (left rotation)
62

What is the advantage of a circular linked list over a singly linked list?

  • A

    Traversal can start from any node

  • B

    Uses less memory

  • C

    Faster insertion

  • D

    Easier to implement

Show Answer
A. Traversal can start from any node
63

What is the output of the following operations: push(5), push(10), pop(), push(15), pop(), pop()?

  • A

    10, 15, 5

  • B

    15, 10, 5

  • C

    5, 10, 15

  • D

    Error

Show Answer
A. 10, 15, 5 (pop returns 10, then 15, then 5)
64

What is the output of the following queue operations: enqueue(1), enqueue(2), dequeue(), enqueue(3), dequeue(), dequeue()?

  • A

    1, 2, 3

  • B

    2, 3, 1

  • C

    1, 3, 2

  • D

    3, 2, 1

Show Answer
A. 1, 2, 3 (dequeue returns 1, then 2, then 3)
65

What is the height of a tree with a single node?

  • A

    0

  • B

    1

  • C

    2

  • D

    Undefined

Show Answer
A. 0 (depending on definition, sometimes 1)
66

What is the time complexity to build a heap from an array of n elements?

  • A

    O(n)

  • B

    O(n log n)

  • C

    O(n^2)

  • D

    O(log n)

Show Answer
A. O(n) (heapify)
67

What is a spanning tree?

  • A

    A subgraph that includes all vertices and is a tree

  • B

    A subgraph with minimum edges

  • C

    A complete graph

  • D

    A graph with no cycles

Show Answer
A. A subgraph that includes all vertices and is a tree
68

What is double hashing?

  • A

    Using two hash functions to resolve collisions

  • B

    Using two hash tables

  • C

    Hashing twice

  • D

    Hash function with two parameters

Show Answer
A. Using two hash functions to resolve collisions
69

What is the time complexity of Counting Sort?

  • A

    O(n + k)

  • B

    O(n log n)

  • C

    O(n^2)

  • D

    O(k log n)

Show Answer
A. O(n + k) where k is the range
70

What is the time complexity of Jump Search?

  • A

    O(√n)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
A. O(√n)
71

What is the difference between an array and a linked list?

  • A

    Array is static; linked list is dynamic

  • B

    Array uses contiguous memory; linked list uses non-contiguous

  • C

    Both A and B

  • D

    They are the same

Show Answer
C. Both A and B
72

What is the time complexity to delete a node given only a pointer to it in a singly linked list?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
B. O(n) because you need to find the previous node
73

What is the meaning of stack underflow?

  • A

    Trying to pop from an empty stack

  • B

    Trying to push onto a full stack

  • C

    Stack memory is corrupted

  • D

    Stack pointer is lost

Show Answer
A. Trying to pop from an empty stack
74

What is a deque?

  • A

    A double-ended queue

  • B

    A queue with priority

  • C

    A circular queue

  • D

    A stack

Show Answer
A. A double-ended queue
75

What is an AVL tree?

  • A

    A self-balancing BST

  • B

    A tree with all nodes at same depth

  • C

    A tree with no rotation

  • D

    A tree with left and right subtrees of equal height

Show Answer
A. A self-balancing BST
76

What is the time complexity to delete the root from a heap?

  • A

    O(log n)

  • B

    O(1)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
A. O(log n)
77

What is a weighted graph?

  • A

    Edges have weights or costs

  • B

    Vertices have weights

  • C

    Graph has cycles

  • D

    Graph is directed

Show Answer
A. Edges have weights or costs
78

What is the difference between separate chaining and open addressing?

  • A

    Chaining uses linked lists; open addressing probes

  • B

    Open addressing uses linked lists; chaining probes

  • C

    Both are the same

  • D

    Chaining is for arrays; open addressing for trees

Show Answer
A. Chaining uses linked lists; open addressing probes
79

What is the time complexity of Heap Sort?

  • A

    O(n log n)

  • B

    O(n^2)

  • C

    O(n)

  • D

    O(log n)

Show Answer
A. O(n log n) in all cases
80

What is the time complexity of Ternary Search?

  • A

    O(log n) base 3

  • B

    O(log n) base 2

  • C

    O(n)

  • D

    O(n^2)

Show Answer
A. O(log n) base 3
81

What is the time complexity of inserting an element at the beginning of an array?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
B. O(n) because shifting elements
82

What is the time complexity of inserting a node at the end of a singly linked list with a tail pointer?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
A. O(1)
83

Which data structure is used for recursion?

  • A

    Stack

  • B

    Queue

  • C

    Heap

  • D

    Array

Show Answer
A. Stack
84

What is the time complexity of checking if a queue is empty?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
A. O(1)
85

What is a trie?

  • A

    A tree used for efficient retrieval of keys

  • B

    A binary tree

  • C

    A heap

  • D

    A graph

Show Answer
A. A tree used for efficient retrieval of keys
86

What is the time complexity to find the minimum element in a min-heap?

  • A

    O(1)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
A. O(1) (at root)
87

What is Dijkstra's algorithm used for?

  • A

    Shortest path in weighted graphs

  • B

    Shortest path in unweighted graphs

  • C

    Minimum spanning tree

  • D

    Topological sorting

Show Answer
A. Shortest path in weighted graphs
88

What is a perfect hash function?

  • A

    Injective mapping with no collisions

  • B

    A hash function with many collisions

  • C

    A hash function with no load factor

  • D

    A hash function that maps all keys to same value

Show Answer
A. Injective mapping with no collisions
89

What is the time complexity of Insertion Sort in the worst case?

  • A

    O(n)

  • B

    O(n log n)

  • C

    O(n^2)

  • D

    O(log n)

Show Answer
C. O(n^2)
90

What is the time complexity of Exponential Search?

  • A

    O(log n)

  • B

    O(n)

  • C

    O(n^2)

  • D

    O(1)

Show Answer
A. O(log n) (for binary search part)
91

What is the difference between a static array and a dynamic array?

  • A

    Static array has fixed size; dynamic array can grow

  • B

    Static array uses heap; dynamic uses stack

  • C

    Both are the same

  • D

    Static array is faster

Show Answer
A. Static array has fixed size; dynamic array can grow
92

What is the time complexity to find the length of a singly linked list?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
B. O(n)
93

Which of the following is true about a stack implemented using a linked list?

  • A

    Push and pop are O(1)

  • B

    Push and pop are O(n)

  • C

    Memory is contiguous

  • D

    It can't be implemented

Show Answer
A. Push and pop are O(1)
94

What is the difference between a simple queue and a circular queue?

  • A

    Circular queue reuses space; simple queue doesn't

  • B

    Simple queue is faster

  • C

    Both are the same

  • D

    Circular queue uses linked list

Show Answer
A. Circular queue reuses space; simple queue doesn't
95

What is the time complexity to search for a value in a BST in the worst case?

  • A

    O(n)

  • B

    O(log n)

  • C

    O(1)

  • D

    O(n^2)

Show Answer
A. O(n) (if unbalanced)
96

What is the time complexity to find the maximum element in a max-heap?

  • A

    O(1)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
A. O(1)
97

What is a cycle in a graph?

  • A

    A path that starts and ends at the same vertex

  • B

    A path with no repeated vertices

  • C

    A path with no edges

  • D

    A path with all vertices distinct

Show Answer
A. A path that starts and ends at the same vertex
98

What is a hash collision?

  • A

    Two different keys hash to same value

  • B

    Two same keys hash to different values

  • C

    Hash table is full

  • D

    Hash function is broken

Show Answer
A. Two different keys hash to same value
99

What is the time complexity of Radix Sort?

  • A

    O(nk)

  • B

    O(n log n)

  • C

    O(n^2)

  • D

    O(k)

Show Answer
A. O(nk) where k is number of digits
100

What is the worst-case time complexity of Fibonacci Search?

  • A

    O(log n)

  • B

    O(n)

  • C

    O(n^2)

  • D

    O(1)

Show Answer
A. O(log n)
101

What is a sparse array?

  • A

    An array with mostly zero or default values

  • B

    An array with all elements filled

  • C

    An array of objects

  • D

    A two-dimensional array

Show Answer
A. An array with mostly zero or default values
102

What is a skip list?

  • A

    A linked list with multiple levels for fast search

  • B

    A list with no nodes

  • C

    A circular linked list

  • D

    A doubly linked list

Show Answer
A. A linked list with multiple levels for fast search
103

What is the time complexity of evaluating a postfix expression using a stack?

  • A

    O(n)

  • B

    O(n^2)

  • C

    O(log n)

  • D

    O(1)

Show Answer
A. O(n)
104

What is the time complexity of enqueue and dequeue in a linked list-based queue?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
A. O(1) with head and tail pointers
105

What is a B-tree?

  • A

    A balanced tree with multiple children per node

  • B

    A binary tree

  • C

    A heap

  • D

    A graph

Show Answer
A. A balanced tree with multiple children per node
106

What is the time complexity to increase the priority of an element in a heap?

  • A

    O(log n)

  • B

    O(1)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
A. O(log n) (up-heapify)
107

What is the time complexity of Prim's algorithm for minimum spanning tree?

  • A

    O(E log V)

  • B

    O(V^2)

  • C

    O(E + V log V)

  • D

    Both A and C depending on implementation

Show Answer
D. Both A and C depending on implementation
108

What is the worst-case time complexity of search in a hash table using chaining?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
B. O(n) (if all keys collide)
109

Which sorting algorithm is based on the divide and conquer paradigm?

  • A

    Merge Sort

  • B

    Bubble Sort

  • C

    Selection Sort

  • D

    Insertion Sort

Show Answer
A. Merge Sort
110

What is the time complexity of Linear Search in the average case?

  • A

    O(n)

  • B

    O(n/2)

  • C

    O(1)

  • D

    O(n^2)

Show Answer
A. O(n)
111

What is a jagged array?

  • A

    An array of arrays where each inner array can have different length

  • B

    A 2D array with equal rows and columns

  • C

    A sorted array

  • D

    A dynamic array

Show Answer
A. An array of arrays where each inner array can have different length
112

What is the time complexity to reverse a singly linked list?

  • A

    O(n)

  • B

    O(1)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
A. O(n)
113

What is the output of the following: push(2), push(3), pop(), push(5), pop(), pop()?

  • A

    3, 5, 2

  • B

    2, 5, 3

  • C

    5, 3, 2

  • D

    2, 3, 5

Show Answer
A. 3, 5, 2
114

What is the time complexity of checking the front element of a queue?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
A. O(1)
115

What is the time complexity to insert an element into a balanced BST?

  • A

    O(log n)

  • B

    O(n)

  • C

    O(1)

  • D

    O(n^2)

Show Answer
A. O(log n)
116

What is the time complexity to delete an arbitrary element from a heap?

  • A

    O(log n)

  • B

    O(n)

  • C

    O(1)

  • D

    O(n^2)

Show Answer
A. O(log n) after finding its position, but finding requires O(n) unless you have a handle
117

What is the time complexity of DFS using an adjacency list?

  • A

    O(V + E)

  • B

    O(V^2)

  • C

    O(E^2)

  • D

    O(V * E)

Show Answer
A. O(V + E)
118

What is the time complexity of insertion in a hash table with open addressing?

  • A

    O(1) average

  • B

    O(n) worst case

  • C

    O(log n)

  • D

    Both A and B

Show Answer
D. Both A and B
119

What is the time complexity of Quick Sort in the average case?

  • A

    O(n log n)

  • B

    O(n^2)

  • C

    O(n)

  • D

    O(log n)

Show Answer
A. O(n log n)
120

What is the time complexity of Binary Search in the worst case?

  • A

    O(log n)

  • B

    O(n)

  • C

    O(1)

  • D

    O(n^2)

Show Answer
A. O(log n)
121

What is the time complexity of finding the maximum element in an unsorted array?

  • A

    O(n)

  • B

    O(log n)

  • C

    O(1)

  • D

    O(n^2)

Show Answer
A. O(n)
122

What is the time complexity to insert a node after a given node in a singly linked list?

  • A

    O(1)

  • B

    O(n)

  • C

    O(log n)

  • D

    O(n^2)

Show Answer
A. O(1)
123

What is the use of a stack in compilers?

  • A

    Syntax analysis and expression evaluation

  • B

    Code generation

  • C

    Memory allocation

  • D

    All of the above

Show Answer
A. Syntax analysis and expression evaluation
124

What is a priority queue implemented using?

  • A

    Heap

  • B

    Array

  • C

    Linked List

  • D

    Stack

Show Answer
A. Heap
125

What is the time complexity to find the height of a binary tree?

  • A

    O(n)

  • B

    O(log n)

  • C

    O(1)

  • D

    O(n^2)

Show Answer
A. O(n) (visit all nodes)
126

What is the space complexity of a heap?

  • A

    O(n)

  • B

    O(log n)

  • C

    O(1)

  • D

    O(n^2)

Show Answer
A. O(n)
127

What is a bipartite graph?

  • A

    Vertices can be divided into two sets with no edges within a set

  • B

    A graph with edges only in one direction

  • C

    A complete graph

  • D

    A graph with cycles

Show Answer
A. Vertices can be divided into two sets with no edges within a set
128

What is the purpose of a hash function?

  • A

    To map keys to indices in a hash table

  • B

    To sort data

  • C

    To link nodes

  • D

    To balance trees

Show Answer
A. To map keys to indices in a hash table
129

What is the time complexity of Shell Sort in the worst case?

  • A

    O(n^2)

  • B

    O(n log n)

  • C

    O(n)

  • D

    O(log n)

Show Answer
A. O(n^2)
130

What is the time complexity of Sentinel Linear Search?

  • A

    O(n)

  • B

    O(log n)

  • C

    O(1)

  • D

    O(n^2)

Show Answer
A. O(n) (but faster in practice)
131

What is the time complexity of accessing an element in an array by index?

  • A

    O(1)

  • B

    O(log n)

  • C

    O(n)

  • D

    O(n^2)

Show Answer
A. O(1)

Frequently Asked Questions

What is a data structure?
A data structure is a way of organizing and storing data in a computer so that it can be accessed and modified efficiently. Common data structures include arrays, linked lists, stacks, queues, trees, graphs, and hash tables.
What is the difference between an array and a linked list?
Arrays store elements in contiguous memory locations, allowing O(1) random access but insertion/deletion is O(n). Linked lists store elements in non-contiguous memory with pointers, allowing O(1) insertion/deletion at known positions but O(n) access time.
What is the Stack data structure and its applications?
Stack follows LIFO (Last In First Out) principle. Applications include function call management, expression evaluation, undo/redo operations, parsing, and backtracking (e.g., recursion).
What is the Queue data structure and its applications?
Queue follows FIFO (First In First Out) principle. Applications include scheduling (CPU, disk), breadth-first search, print spooling, and handling asynchronous data (e.g., producer-consumer).
What is a Binary Search Tree (BST) and its advantages?
A BST is a binary tree where left child < parent < right child. It supports search, insert, delete in O(log n) average time if balanced. It provides ordered data and efficient searching.
What is the difference between a heap and a BST?
A heap is a complete binary tree used for priority queues; it satisfies heap property (max-heap or min-heap). BST maintains sorted order and supports search, insert, delete. Heap supports efficient max/min extraction and insertion.
What is hashing and why is it used?
Hashing is a technique to map data (keys) to fixed-size values (hash codes) using a hash function. Hash tables provide O(1) average time for search, insert, and delete. Used in dictionaries, caches, and databases.
What are the common sorting algorithms and their complexities?
Common algorithms: Bubble Sort (O(n^2)), Insertion Sort (O(n^2)), Selection Sort (O(n^2)), Merge Sort (O(n log n)), Quick Sort (O(n log n) average, O(n^2) worst), Heap Sort (O(n log n)). Choice depends on data size and stability requirements.