0
Sorting
May I know how to make a function to sort the elements in ascending or descending order using selection sort and insertion sort
3 Answers
+ 1
Jayakrishna🇮🇳 Can you tell be how Insertion sort is different from Selection sort?
0
0
Atul
Once go through the link, you can understand it..
Selection Sort is first finds the smallest element in the array and swaps it with the element in the first 0th position, then finds the second and swaps it with second (1st) position, and continues for entire array..
Where as insertion sort, first arrange 1st 2 elements in order. Then next 3rd element is added in ascending order with 1,2. Now 1,2,3 are in ordered. Next 4th element is placed in order with 1,2,3,4 to its needed position.. so 1,2,3,4 is ordered now. This goes on for entire list.
hope it helps..
Hot today
Python — File Handling
0 Votes
Help me solve this (using loop)
3 Votes
What is wrong? Error on test.
1 Votes
Help me wiht python
1 Votes
Question is write a c program to print prime numbers up to n and print the largest number in array.
1 Votes
Help me
0 Votes