Computer Applications
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
Java Arrays
10 Likes
Answer
3, 5, 8, 12
Reason — Selection Sort is a sorting technique where next smallest (or next largest) element is found in the array and moved to its correct position in each pass.
In the first pass, smallest element 3 will be found and swapped with the first position element 12. The array elements after the first pass will be:
3, 12, 8, 5
In the second pass, the next smallest element 5 will be found and swapped with the second position element 12.The array elements after the second pass will be:
3, 5, 8, 12
Answered By
5 Likes
Related Questions
Given that
int A[ ] = {35, 26, 19, 76, 58};
What will be value contained in A[3] ?- 35
- 26
- 19
- 76
- 58
Given that
int z[ ][ ] = {{2, 6, 5}, {8, 3, 9}};What will be value of z[1][0] and z[0][2] ?- 2 and 9
- 8 and 5
- 2 and 5
- 6 and 3
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
An array
18, 13, 2, 9, 5
is
13, 2, 9, 18, 5
after three passes. Which sorting technique is applied on it?