Computer Applications
An array
18, 13, 2, 9, 5
is
13, 2, 9, 18, 5
after three passes. Which sorting technique is applied on it?
Java Arrays
5 Likes
Answer
Bubble sort is applied on the array.
Explanation
In the first pass, adjacent elements (18, 13) will be compared and swapped. The array will look like this after the first pass:
13, 18, 2, 9, 5
In the second pass, adjacent elements (18, 2) will be compared and swapped. The array will look like this after the first pass:
13, 2, 18, 9, 5
In the third pass, adjacent elements (18, 9) will be compared and swapped. The array will look like this after the third pass:
13, 2, 9, 18, 5
Answered By
1 Like
Related Questions
Given array 12, 3, 8, 5. What will be array like after two passes of selection sort ?
- 12, 3, 8, 5
- 3, 5, 8, 12
- 3, 8, 5, 12
- 3, 5, 12, 8
Given an array 12, 3, 8, 5. What will be array like after two passes of bubble sort?
- 12, 3, 8, 5
- 3, 8, 12, 5
- 3, 5, 8, 12
- 12, 3, 5, 8
What do you understand by an array ? What is the significance of arrays ?
What is meant by index of an element ? How are indices numbered in JAVA ?