Home › Programming › Data Structures & Algorithms › Page 3
Data Structures & Algorithms MCQs
20 practice MCQs on this page Page 3 of 4
Tap an option to check your answer — the correct answer and full explanation appear after you choose.
Programming Data Structures & Algorithms BPSC ID: BPP-2127
When analyzing time complexity which of the following provides an upper bound of run time
A Best case
B Average case
C Worst case ✓ Correct answer
D all of them
✓ Correct answer: Worst case
Full explanation The worst case provides an upper bound of run time in time complexity analysis.
Programming Data Structures & Algorithms BPSC ID: BPP-2138
Which of the following describes a "brute force" approach to problem-solving?
A Optimizing each step
B Exploring all possible solutions ✓ Correct answer
C Using domain-specific knowledge
D Applying heuristics
✓ Correct answer: Exploring all possible solutions
Full explanation A brute force approach works by exploring all possible solutions.
Programming Data Structures & Algorithms KPPSC ID: KPP-0048
When in-order traversing a tree resulted in E A C K F H D B G; the preorder traversal would return?
A FAEKCDHGB ✓ Correct answer
B FEAKDCHBG
C EAFKHDCBG
D FAEKCDBHG
✓ Correct answer: FAEKCDHGB
Full explanation FAEKCDHGB. From the given in-order traversal, the pre-order traversal is FAEKCDHGB.
Programming Data Structures & Algorithms KPPSC ID: KPP-0052
The time factor when determining the efficiency of the algorithm is measured by:
A Counting the number of key operations ✓ Correct answer
B Counting the number of statements
C Counting the kilobytes of algorithm
D Counting Microseconds
✓ Correct answer: Counting the number of key operations
Full explanation Counting the number of key operations. The time factor in determining the efficiency of an algorithm is measured by counting the number of key operations.
Programming Data Structures & Algorithms KPPSC ID: KPP-0059
Binary search algorithm cannot be applied to:
A Pointer Array
B Sorted Linked List ✓ Correct answer
C Sorted Linear Array
D Sorted Binary Trees
✓ Correct answer: Sorted Linked List
Full explanation Sorted Linked List. Binary search cannot be applied to a sorted linked list.
Programming Data Structures & Algorithms KPPSC ID: KPP-0060
Which of the following data structures is a non-linear type?
A Strings
B Lists
C Graph ✓ Correct answer
D Stacks
✓ Correct answer: Graph
Full explanation Graph. A graph is a non-linear data structure.
Programming Data Structures & Algorithms KPPSC ID: KPP-0102
Which data structure works on the LIFO principle?
A Linked list
B Stack ✓ Correct answer
C Array
D Queue
✓ Correct answer: Stack
Full explanation Stack. A stack works on the LIFO principle.
Programming Data Structures & Algorithms KPPSC ID: KPP-0138
Which of the following is a sorting algorithm?
A Binary search
B Bubble sort ✓ Correct answer
C Linear search
D Hashing
✓ Correct answer: Bubble sort
Full explanation Bubble sort. Bubble sort is a sorting algorithm.
Programming Data Structures & Algorithms FPSC ID: FPP-2367
The FIFO principle is followed by which data structure?
A Stack
B Queue ✓ Correct answer
C Tree
D Graph
✓ Correct answer: Queue
Full explanation The FIFO principle is followed by a queue, in which the first element added is the first one removed.
Programming Data Structures & Algorithms BPSC ID: BPP-2773
Which data structure follows the LIFO principle?
A Linked list
B Tree
C Queue
D Stack ✓ Correct answer
✓ Correct answer: Stack
Full explanation A stack follows the LIFO (Last In, First Out) principle. The correct answer is Stack.
Programming Data Structures & Algorithms BPSC ID: BPP-3935
What is the time complexity of linear search in the worst case?
A O(log n)
B O(n²)
C O(1)
D O(n) ✓ Correct answer
✓ Correct answer: O(n)
Full explanation In the worst case linear search checks every element once, so its time complexity is O(n). The correct answer is O(n).
Programming Data Structures & Algorithms BPSC ID: BPP-2777
Which sorting algorithm has the worst-case time complexity O(n^2)?
A Quick sort (best case)
B Merge sort
C Bubble sort ✓ Correct answer
D Heap sort
✓ Correct answer: Bubble sort
Full explanation Bubble sort has a worst-case time complexity of O(n^2).
Programming Data Structures & Algorithms BPSC ID: BPP-2778
Which sorting algorithm has a worst-case time complexity of O(n log n)?
A Bubble sort
B Insertion sort
C Selection sort
D Merge sort ✓ Correct answer
✓ Correct answer: Merge sort
Full explanation Merge sort has a worst-case time complexity of O(n log n).
Programming Data Structures & Algorithms FPSC ID: FPP-11401
Which loop is used when the number of iterations is known in advance?
A do-while loop
B if statement
C while loop
D for loop ✓ Correct answer
✓ Correct answer: for loop
Full explanation A for loop is used when the number of iterations is known in advance.
Programming Data Structures & Algorithms FPSC ID: FPP-11405
The binary search algorithm requires the data to be:
A Unsorted
B Random
C Sorted ✓ Correct answer
D Reversed
✓ Correct answer: Sorted
Full explanation Binary search requires the data to be sorted. The correct answer is Sorted.
Programming Data Structures & Algorithms FPSC ID: FPP-11406
Recursion is implemented with the help of which data structure?
A Stack ✓ Correct answer
B Array
C Queue
D Linked list
✓ Correct answer: Stack
Full explanation Recursion is implemented with the help of a stack. The correct answer is Stack.
Programming Data Structures & Algorithms BPSC ID: BPP-3688
In a binary tree, a node with no children is called?
A Root node
B Leaf node ✓ Correct answer
C Parent node
D Internal node
✓ Correct answer: Leaf node
Full explanation The correct answer is Leaf node. A leaf node is a node in a tree that has no children.
Programming Data Structures & Algorithms BPSC ID: BPP-3689
Which sorting algorithm has an average-case time complexity of O(n log n)?
A Bubble sort
B Insertion sort
C Quick sort ✓ Correct answer
D Selection sort
✓ Correct answer: Quick sort
Full explanation Quick sort has an average-case time complexity of O(n log n), while bubble, insertion and selection sort are O(n²).
Programming Data Structures & Algorithms BPSC ID: BPP-3690
A hash table resolves collisions by which technique?
A Chaining ✓ Correct answer
B Linear search
C Binary search
D Recursion
✓ Correct answer: Chaining
Full explanation Chaining resolves hash collisions by storing all elements that hash to the same slot in a linked list at that slot.
Programming Data Structures & Algorithms PPSC ID: LTP-7714
A stack data structure follows which order of access?
A First In, First Out (FIFO)
B Random access only
C Last In, First Out (LIFO) ✓ Correct answer
D Smallest first
✓ Correct answer: Last In, First Out (LIFO)
Full explanation A stack follows Last In, First Out (LIFO), so the last item pushed on is the first item taken off.
Practice these MCQs interactively
← Programming MCQs