Data Structure Using C (313301) Practical No.8: Write a ‘C’ Program to Sort an Array of numbers using the Selection Sort Method
Selection Sort is an in-place comparison sorting algorithm. It divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front of the list, and the sublist of items remaining to be sorted that occupy the rest of the list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element from the unsorted sublist, exchanging it with the leftmost unsorted element, and moving the sublist boundaries one element to the right.
Algorithm
Flow Chart
Use below information and draw flow chart
C Program Code
Result (Output of Program)
Original array:
64 25 12 22 11
Sorted array:
11 12 22 25 64
Practical Related Questions
1. Modify the Selection Sort algorithm to handle arrays containing negative numbers.
Answer:
2. Adapt the Selection Sort algorithm to sort an array of floating-point numbers.
Answer:
Conclusion
We successfully completed Data Structure Using C (313301) Practical No.8 and Wrote a ‘C’ Program to Sort an Array of numbers using the Selection Sort Method.