Computer Applications
The following array of integers is to be arranged in ascending order using the bubble sort technique:
26 21 20 23 29 17
Give the contents of the array at the end of each iteration. Do not write the algorithm.
Answer
The contents of the array at the end of each iteration are as follows:
Itr 1 — 26, 21, 20, 23, 29, 17
Itr 2 — 21, 26, 20, 23, 29, 17
Itr 3 — 21, 20, 26, 23, 29, 17
Itr 4 — 21, 20, 23, 26, 29, 17
Itr 5 — 21, 20, 23, 26, 29, 17
Itr 6 — 21, 20, 23, 26, 17, 29
Itr 7 — 20, 21, 23, 26, 17, 29
Itr 8 — 20, 21, 23, 26, 17, 29
Itr 9 — 20, 21, 23, 26, 17, 29
Itr 10 — 20, 21, 23, 17, 26, 29
Itr 11 — 20, 21, 23, 17, 26, 29
Itr 12 — 20, 21, 23, 17, 26, 29
Itr 13 — 20, 21, 17, 23, 26, 29
Itr 14 — 20, 21, 17, 23, 26, 29
Itr 15 — 20, 17, 21, 23, 26, 29
Itr 16 — 17, 20, 21, 23, 26, 29
Related Questions
Write a program to search for an ITEM linearly in array X[10].
Write a program to search for an ITEM using binary search in array X[10].
Write a program to search for a given ITEM in a given array X[n] using linear search technique. If the ITEM is found, move it at the top of the array. If the ITEM is not found, insert it at the end of the array.