edited by
1,061 views
0 votes
0 votes

Consider the following sorting algorithms:

  1. Bubble sort
  2. Insertion sort
  3. Selection sort


Which ONE among the following choices of sorting algorithms sorts the numbers in the array $[4,3,2,1,5]$ in increasing order after exactly two passes over the array?

  1. $\text{(i)}$ only
  2. $\text{(iii)}$ only
  3. $\text{(i)}$ and $\text{(iii)}$ only
  4. $\text{(ii)}$ and $\text{(iii)}$ only

edited by

1 Answer

0 votes
0 votes
Bubble sort needs 3. Insertion sort wastes 1 to assume first element as sorted. Selection sort does it in 2 with first pass swap [4, 1] and second pass swap [3, 2]. So B.

 
Answer:

Related questions

1.0k
views
2 answers
1 votes
Arjun asked Feb 16
1,035 views
Consider performing depth-first search (DFS) on an undirected and unweighted graph $G$ starting at vertex $s$. For any vertex $u$ in $G, d[u]$ is the length of the ... , then $(u, v)$ becomes a $\_\_\_\_\_\_\_\_$ edge.treecrossbackgray
1.5k
views
3 answers
0 votes
Arjun asked Feb 16
1,487 views
Consider sorting the following array of integers in ascending order using an inplace Quicksort algorithm that uses the last element as the pivot.\begin{array}{|l|l|l|l|l|}\ ... of swaps performed during this Quicksort is $\_\_\_\_\_\_\_\_$.
1.1k
views
1 answers
0 votes
Arjun asked Feb 16
1,055 views
Let $F(n)$ denote the maximum number of comparisons made while searching for an entry in a sorted array of size $n$ using binary search.Which ONE of the following options is TRUE ... $F(n)=F(n-1)+1$
829
views
1 answers
0 votes
Arjun asked Feb 16
829 views
Consider the directed acyclic graph (DAG) below:Which of the following is/are valid vertex orderings that can be obtained from a topological sort of the DAG?$\text{P Q R S T U V}$\ ... $\text{P R Q S V T U}$