34 34 votes Give the correct matching for the following pairs: $$\begin{array}{|ll|ll|}\hline \text{(A)} & \text{$O (\log n)$} & \text{(P)} & \text{Selection} \\\hline \text{(B)} & \text{$O (n)$} & \text{(Q)}& \text{Insertion sort} \\\hline \text{(C)}& \text{$O (n \log n)$} & \text{(R)} & \text{Binary search} \\\hline \text{(D)} & \text{$O (n^2)$} &\text{(S)} & \text{Merge sort} \\\hline \end{array}$$$\text{A-R B-P C-Q D-S}$$\text{A-R B-P C-S D-Q}$$\text{A-P B-R C-S D-Q}$$\text{A-P B-S C-R D-Q}$ Algorithms gate1998 algorithms sorting easy match-the-following + – Kathleen 12.5k views answer comment Share Follow Print See 1 comment 1 1 comment reply legend_of_cse commented Apr 1 reply Follow flag Sources : Wikipedia 0 0 replyShare Please log in or register to add a comment.
Best answer 44 44 votes Here we are talking about the worst case time complexities of the given algorithms. Selection actually refers to selection algorithm and not selection sort. Selection$: O(n)$ Insertion sort $: O(n^2)$ Binary search $:O(\log n)$ Merge sort $:O(n \log n)$ $\text{A} -\text{R}\quad \text{B}-\text{P}\quad \text{C}-\text{S}\quad \text{D}-\text{Q}.$ Correct Answer: $B$ Bhagirathi answered Sep 27, 2014 • selected Sep 18, 2022 by gatecse Bhagirathi comment Share Follow See all 12 Comments 12 12 Comments reply Show 9 previous comments Soumyabrata Chatterj commented Sep 30, 2020 reply Follow flag According to option B selection sort = O(n). How is it possible ? 1 1 replyShare Overflow04 commented Sep 18, 2022 i reshown by gatecse Sep 18, 2022 reply Follow flag @srestha @Gaurav nitkkriit @Soumyabrata Chatterj @Arjun Here selection is given not selection sort, So selecting an element in worst case might take O(n) if the element is not sorted. Hence Selection an element (not Selection sort) = O(n) Merge Sort = O(n log n) Binary Search = O(log n) Insertion Sort = O(n^2) 16 16 replyShare gatecse commented Sep 18, 2022 reply Follow flag @GateOverflow04 Yes, that's correct. 0 0 replyShare Please log in or register to add a comment.
16 16 votes A) O(logN) -> Binary Search. No other option Matches -> R . Option C & D eliminated. C) O(nlogn) => Merge sort, even in best worst or any case. -> S Option A eliminated. It seems to me that all options are wrong here. But I would go with Option B) A-R B-P C-S D-Q D => Q This is okay. B=> P It is okay if we just have selection. Selection sort is O(N2) Akash Kanase answered Dec 13, 2015 Akash Kanase comment Share Follow 0 reply Please log in or register to add a comment.
6 6 votes here A) (Ologn)-> Binary search B) O(n) -> max no of swap in selection sort in worst case. C) O(nlogn) -> marge sort D) O(n^2) -> No of swap (moment) in insertion sort in worst case hance B is correct answer........... Nikhil gate 2020 answered Jan 29, 2020 Nikhil gate 2020 comment Share Follow 0 reply Please log in or register to add a comment.