__Complexity :__Best case: O(n^2)

average case:O(n^2)

Worst Case: O(n^2)

*Technique :*- we first select the ith(for the first iteration i=0) element of the array and assume it to be the smallest
- next we traverse from the i+1 position to the end of the array using the smallest function to find the position of the smallest element and we return its position .
- then the current value and the smallest value are compared and swapped.
- this entire process continues till the array is completely sorted.

**Basically what happens is , in every iteration the smallest element element in the array is placed in its proper position.

Source code:

Output :

**the code given above can be sufficiently tweaked . i have purposely made it a bit more lengthy for clarity sake .

## No comments:

## Post a Comment