DSA Quiz
DSA Quiz
Quiz
Time: 30 mins
4. Which sorting algorithm is commonly used for sorting small data sets?
a. Quick sort
b. Bubble sort
c. Merge sort
d. Insertion sort
1
6. Which of the following statements are false regarding recursion?
a. A recursive algorithm should always call itself directly to solve a smaller version of
its task.
b. A recursive algorithm needs to have a terminating condition.
c. Any recursive algorithm can be rewritten to use loops instead of recursion.
d. Divide and conquer algorithms such as merge sort do not use recursion.
7. Consider the following stack where the rightmost element is at the top of the
stack.
4 9 5 2 5 7 9 1
How will the stack look like after performing the following sequence operation in order?
• pop
• push(3)
• pop
• pop
• push(2)
• pop
• push(8)
• push(6)
a. 4, 9, 5, 2, 5, 7, 8, 6
b. 4, 9, 5, 2, 8, 6, 5, 7
c. 4, 9, 5, 2, 5, 7, 9, 1, 8, 6
d. 8, 6, 4, 9, 5, 2, 5, 7
8. Drag and drop the appropriate time costs to the given lines of merge sort.
Assume that the time cost for the function itself is T( n ).
2
9. Select the appropriate worst-case running time for the following algorithms.
Consider the following code fragment and answer the questions 11-13.
3
12. How many times is statement 10 executed?
a. O( N )
b. O( N^2 )
c. O( N^3 )
d. O( N^4 )
14. When the user tries to delete the element from the empty stack then the
condition is said to be a ____.
a. Overflow
b. Underflow
c. Garbage collection
d. None of the above
15. Which one of the following is correct for the maximum value that the 'rear' can
take to avoid the overflow condition if a linear queue is implemented using an
array with a size MAX_SIZE?
a. rear = front
b. rear = front + 1
c. rear = MAX_SIZE - 1
d. rear = MAX_SIZE