What is the time complexity of counting sort for n integers whose values lie in the range 0 to k?
Correct answer B. O(n + k)
Topic / 90 questions
Data Structures MCQs test how data is organised and processed in programs, a core subject for computer science students, programming job tests and exams such as GATE and university papers. Questions cover arrays, linked lists, stacks, queues, trees, heaps, graphs, hashing, searching and sorting. Computed answers such as traversal orders and postfix results were checked with code, and every answer is explained.
Correct answer B. O(n + k)
Correct answer D. Two different keys hash to the same index
Correct answer B. Each slot holds a linked list of all keys that hash to it
Correct answer B. 3
Correct answer A. 5
Correct answer D. 0.75
Correct answer C. Primary clustering
Correct answer D. O(1)
Correct answer C. The array must be sorted
Correct answer D. [3, 7, 1, 5, 9]
Correct answer A. [10, 13, 14, 37, 29]
Correct answer C. O(n), when the input is already sorted
Correct answer A. An array that is already sorted
Correct answer B. [3, 1, 4, 8, 9, 7]
Correct answer A. It is stable and runs in O(n log n) time in every case, but needs O(n) extra space for arrays
Correct answer B. Heap sort
Correct answer D. 10
Correct answer C. [9, 4, 5, 1, 3, 2]
Correct answer B. [1, 4, 3, 10, 8, 7]
Correct answer C. All data records are stored in the leaves, and the leaves are linked for sequential access
The set begins with basic ideas such as abstract data types, linear and non-linear structures and Big-O notation for common operations. Arrays and linked lists follow, including address calculation, insertion and deletion costs, doubly and circular lists, and cycle detection.
Stack and queue questions cover push and pop, overflow and underflow, infix-to-postfix conversion, postfix evaluation, circular queues, deques and priority queues. Tree questions deal with binary tree properties, traversals, binary search trees, AVL rotations, B-trees and heaps.
The final part covers graph representations, breadth-first and depth-first search, topological sorting, minimum spanning trees and shortest paths, then hashing with collision resolution and load factor, and finally searching and sorting algorithms with their time complexity, stability and in-place behaviour.
Pakistan
India
Bangladesh
A stack removes the most recently added item first (LIFO), using push and pop at one end. A queue removes the oldest item first (FIFO), adding at the rear and removing from the front.
Tree traversals and binary search trees, heaps, stack applications such as postfix evaluation, hashing with collisions, graph traversal, and the time complexity of searching and sorting algorithms appear most often.
Last reviewed October 2026