The Gateway to Computer Science Excellence
+1 vote
449 views
The algorithm that will efficiently sort an array that is nearly sorted except for the interchange of some adjacent pairs of numbers like : { 1, 3, 2, 5, 4, 6} is:
(A) Quick sort               (B) Bubble sort
(C) Merge sort              (D) Selection sort



 

in DS by Boss (48.8k points) | 449 views

1 Answer

+1 vote
should it be B
by Boss (48.8k points)
0
why not merge sort?
+2
since list is nearly sorted so by using bubble  sort very few exchanges say 2 or   3 will do the job while for merge sort whole array has to be divided and then again merged in addition to comparison and all
0
yes
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,645 questions
56,587 answers
195,788 comments
101,840 users