In this post we will see how to implement the selection sort algorithm in java with a sample program.In selection sorting
When we run the above program,we will get this output
Above output will show the array elements position at the end of each iteration.
- We will find the smallest element in the array and then swap this element with the element in the 0th index of the array.
- Then we will find the second smallest element in the array and swap this element with the element in the 1st index of the array.This iteration will continue upto the number of times equal to the the size of the array.
When we run the above program,we will get this output
Above output will show the array elements position at the end of each iteration.
No comments:
Post a Comment