Recent questions tagged insertion-sort

1 1 vote
1 1 answer
236
236 views
You have given an array A[] = {12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}. An inversion in an array A is a pair of array indices (i, j) such that i < j and A[i] A[j]. Assume...
2 2 votes
2 2 answers
224
224 views
Suppose Binary Search is used in Insertion Sort to locate where the $i$th element should be inserted among the first $i-1$ elements.What is the worst-case running time of...
1 1 vote
2 2 answers
169
169 views
When is insertionsort a good choice for sorting an array?Each component of the array requires a large amount of memory. Each component of the array requires a small amoun...
0 0 votes
1 1 answer
130
130 views
Which of the following is correct with regard to insertion sort?insertion sort is stable and it sorts In-place insertion sort is unstable and it sorts In-place insertion ...
0 0 votes
1 1 answer
122
122 views
Consider an array of elements $5, 4, 3, 2, 1$, what are the steps of insertions done while doing insertion sort in the array.$(4,5,3,2,1) \rightarrow (3,4,5,2,1) \rightar...
1 1 vote
1 1 answer
111
111 views
Consider the following two statementsStatement $1:$ In insertion sort, after $m$ passes through the array, the first $m$ elements are in sorted order.Statement $2:$ And t...
0 0 votes
1 1 answer
117
117 views
In Insertion sort, for the array $[34, 8, 64, 51, 32, 21]$, how will the array elements look like after second iteration$8, 21, 32, 34, 51, 64$ $8, 32, 34, 51, 64, 21$ $8...
3 3 votes
2 2 answers
569
569 views
Recall the insertion sort algorithm: procedure INSERTIONSORT(A) for i ← 1 to A.length - 1 do key ← A[i] j ← i - 1 while j ≥ 0 and A[j] key do A[j + ...
9 9 votes
6 6 answers
4.0k
4.0k views
Suppose that insertion sort is applied to the array $[1,3,5,7,9,11, x, 15,13]$ and it takes exactly two swaps to sort the array. Select all possible values of $x$.$10$$12...
0 0 votes
0 0 answers
412
412 views
2 2 votes
2 answers 2 answers
2.8k
2.8k views
Meena is working in an IT company as HR manager. She has a large list of potential candidates to be recruited which are all sorted by their names. But she found that due ...
1 1 vote
1 1 answer
1.7k
1.7k views
Why option (A) is not correct ?
94 94 votes
11 answers 11 answers
32.0k
32.0k views
In a permutation $a_1\ldots a_n$, of $n$ distinct integers, an inversion is a pair $(a_i, a_j)$ such that $i < j$ and $a_i a_j.$What would be the worst case time complex...
2 2 votes
1 answers 1 answer
1.1k
1.1k views
A) 192 B) 120 c) 188 D) 176
86 86 votes
3 answers 3 answers
27.3k
27.3k views
The usual $\Theta(n^2)$ implementation of Insertion Sort to sort an array uses linear search to identify the position where an element is to be inserted into the already ...
To see more, click for the full list of questions or popular tags.