Quiz Questions
Each question has four choices. More than one options can be correct. When you have finished the quiz, click the button at the end of the questions to view the result, and the solutions and answers.
Correct Answers: | |
Wrong Answers: | |
Unattempted: |
Question 1
The worst case performance of selection sort is:
A
O(n2)
B
O(2n)
C
O(n)
D
O(n log n)
Soln.
Ans: A
Ans: A
Question 2
Which of the following signifies the worst case efficiency of bubble sort algorithm?
A
O(n2)
B
O(2n)
C
O(n)
D
O(nlog(n))
Soln.
Ans: A
Ans: A
O(n2), because the time taken to execute the algorithm increases quadratically with the increase in the size of the array
Question 3
Selection sort is
A
in-place
B
non in-place
C
out place
D
None
Soln.
Ans: A
Ans: A
Question 4
What is the average case performance of binary search?
A
O(n log n)
B
O(log n)
C
O(1)
D
O(n)
Soln.
Ans: B
Ans: B
The average case performance of binary search is O(log n).
Question 5
Why is the bubble sort often presented first when learning sorting methods?
A
it is the fastest
B
it is the most efficient
C
it is easiest to understand
D
it uses fewer loops than other methods
Soln.
Ans: C
Ans: C
Question 6
Which operation does the Selection Sort use to move numbers from the unsorted section to the sorted section of the list?
A
Swap
B
Sort
C
Both
D
None
Soln.
Ans: A
Ans: A
Question 7
To apply binary search algorithm, you should ensure that the list to be searched is___________
A
Unsorted
B
Partially sorted
C
Sorted
D
all of them
Soln.
Ans: C
Ans: C
To apply binary search algorithm, you should ensure that the list to be searched is sorted list.
Question 8
For each i from 1 to n - 1, there are _______ comparisons for selection sort.
A
n
B
n - i
C
i
D
n - 1
Soln.
Ans: B
Ans: B
For each i from 1 to n - 1, there is one exchange and n - i comparisons, so there is a total of n -1 exchanges and (n -1) + (n -2) + . . . + 2 + 1 = n(n -1)/2 comparisons. These observations hold no matter what the input data is.
Question 9
What is the worst case performance of binary search?
A
O(n log n)
B
O(log n)
C
O(1)
D
O(n)
Soln.
Ans: B
Ans: B
The worst case performance of binary search is O(log n).
Question 10
Selection sort is quadratic in both the worst and the average case, and requires no extra memory.(T/F)
A
True
B
False
C
Depends on elements
D
None
Soln.
Ans: A
Ans: A
My C/C++ Videos on Youtube
Here is the complete playlist for video lectures and tutorials for the absolute beginners. The language has been kept simple so that anybody can easily understand them. I have avoided complex jargon in these videos.