# MCQs on Sorting with answers

## MCQs on Sorting with answers

1. Which of the following is not a stable sorting algorithm?

a) Insertion sort
b) Selection sort
c) Bubble sort
d) Merge sort

2. Which of the following is a stable sorting algorithm?

a) Merge sort
b) Typical in-place quick sort
c) Heap sort
d) Selection sort

3. Which of the following is not an in-place sorting algorithm?

a) Selection sort
b) Heap sort
c) Quick sort
d) Merge sort

4. Running merge sort on an array of size n which is already sorted is

a) O(n)
b) O(nlogn)
c) O(n2)
d) None

5. The time complexity of a quick sort algorithm which makes use of median, found by an O(n) algorithm, as pivot element is

a) O(n2)
b) O(nlogn)
c) O(nloglogn)
d) O(n)

6. Which of the following is not a noncomparison sort?

a) Counting sort
b) Bucket sort
d) Shell sort

7. The time complexity of heap sort in worst case is

a) O(logn)
b) O(n)
c) O(nlogn)
d) O(n2)

8. If the given input array is sorted or nearly sorted, which of the following algorithm gives the best performance?

a) Insertion sort
b) Selection sort
c) Quick sort
d) Merge sort

9. Which of the following algorithm pays the least attention to the ordering of the elements in the input list?

a) Insertion sort
b) Selection sort
c) Quick sort
d) None

10. Consider the situation in which assignment operation is very costly. Which of the following sorting algorithm should be performed so that the number of assignment operations is minimized in general?

a) Insertion sort
b) Selection sort
c) Heap sort
d) None

11. Time complexity of bubble sort in best case is

a) θ (n)
b) θ (nlogn)
c) θ (n2)
d) θ (n(logn) 2)

12. Given a number of elements in the range [0….n3]. which of the following sorting algorithms can sort them in O(n) time?

a) Counting sort
b) Bucket sort
d) Quick sort

13. Which of the following algorithms has lowest worst case time complexity?

a) Insertion sort
b) Selection sort
c) Quick sort
d) Heap sort

14. Which of the following sorting algorithms is/are stable

a) Counting sort
b) Bucket sort
d) All of the above

15. Counting sort performs …………. Numbers of comparisons between input elements.

a) 0
b) n
c) nlogn
d) n2

16. The running time of radix sort on an array of n integers in the range [0……..n5 -1] when using base 10 representation is

a) θ (n)
b) θ (nlogn)
c) θ (n2)
d) none

17. The running time of radix sort on an array of n integers in the range [0……..n5 -1] when using base n representation is

a) θ (n)
b) θ (nlogn)
c) θ (n2)
d) None

18. Which of the following sorting algorithm is in-place

a) Counting sort
c) Bucket sort
d) None

19. The radix sort does not work correctly if each individual digit is sorted using

a) Insertion sort
b) Counting sort
c) Selection sort
d) Bubble sort

20. Which of the following sorting algorithm has the running time that is least dependant on the initial ordering of the input?

a) Insertion sort
b) Quick sort
c) Merge sort
d) Selection sort

21. Time complexity to sort elements of binary search tree is

a) O(n)
b) O(nlogn)
c) O(n2)
d) O(n2logn)

22. The lower bound on the number of comparisons performed by comparison-based sorting algorithm is

a) Ω (1)
b) Ω (n)
c) Ω (nlogn)
d) Ω (n2)

23. Which of the following algorithm(s) can be used to sort n integers in range [1…..n3] in O(n) time?

a) Heap sort
b) Quick sort
c) Merge sort

24. Which of the following algorithm design technique is used in the quick sort algorithm?

a) Dynamic programming
b) Backtracking
c) Divide-and-conquer
d) Greedy method

25. Merge sort uses

a) Divide-and-conquer
b) Backtracking
c) Heuristic approach
d) Greedy approach

26. For merging two sorted lists of size m and n into sorted list of size m+n, we require comparisons of

a) O(m)
b) O(n)
c) O(m+n)
d) O(logm + logn)

27. A sorting technique is called stable if it

a) Takes O(nlogn) times
b) Maintains the relative order of occurrence of non-distinct elements
d) Takes O(n) space

28. In a heap with n elements with the smallest element at the root, the seventh smallest element can be found in time

a) θ (nlogn)
b) θ (n)
c) θ (logn)
d) θ (1)

29. What would be the worst case time complexity of the insertion sort algorithm, if the inputs are restricted to permutation of 1…..n with at most n inversion?

a) θ (n2)
b) θ (nlogn)
c) θ (n1.5)
d) θ (n)

30. In a binary max heap containing n numbers, the smallest element can be found in time

a) θ (n)
b) θ (logn)
c) θ (loglogn)
d) θ (1)

#### Discussion

• RE: MCQs on Sorting with answers -Aarav Pant (08/14/20)
• Thank for the mcqs with answers.
• In a heap with n elements with the smallest element at the root, the seventh smallest element can be found in time -Abhishek Kumar (09/16/18)
{"ft_lang_label":"__label__en","ft_lang_prob":0.6986328,"math_prob":0.9288588,"size":6880,"snap":"2021-31-2021-39","text_gpt3_token_len":1918,"char_repetition_ratio":0.21000582,"word_repetition_ratio":0.19772172,"special_character_ratio":0.26468024,"punctuation_ratio":0.06700656,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99750054,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-21T13:39:08Z\",\"WARC-Record-ID\":\"<urn:uuid:6208f8fa-6cac-4ad0-adf2-6ced08e258f7>\",\"Content-Length\":\"29395\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:822f7cd7-fe6f-442f-8c43-b45eb8036498>\",\"WARC-Concurrent-To\":\"<urn:uuid:99d6dc87-3d3a-4f90-a08b-ac0e4b329407>\",\"WARC-IP-Address\":\"67.227.164.106\",\"WARC-Target-URI\":\"https://www.careerride.com/view/mcqs-on-sorting-with-answers-19637.aspx\",\"WARC-Payload-Digest\":\"sha1:6ZD7KITXI5DOJYTJ464S5XZDIUJBJ3SN\",\"WARC-Block-Digest\":\"sha1:OW5V4R3ZVWRHQNIU7RDTBNZNBN45W5NB\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780057225.38_warc_CC-MAIN-20210921131252-20210921161252-00056.warc.gz\"}"}