SORTING
Need a list sorted? sorted() is a function to use. It takes a list as an argument and returns a new sorted list.
Sorting algorithm is a way to arrange/rearrange data in a sorted form, data may be in any form it would be a list and no. of elements of array.
Sorting algorithm used in this example:
There are many sorting algorithm in python but in this program we are using only five sorting algorithm. i.e,
Bubble sort:-
Bubble sort is a simple sorting algorithm.that repeats steps through the entire list, compares adjacent elements and swaps them if they are arranged in wrong order. the path through the list is repeated until the list is sorted.

SELECTION SORT:-
The selection sort algorithm sorts an array by repeatedly finding the minimum element from unsorted part and putting it at the beginning. In every iteration of selection sort, the minimum value from the unsorted part picked and place it in the sorted one.

INSERTION SORT:-
Insertion sort is most simple algorithm in this algorithm, array is split into a sorted and an unsorted part. Elements from the unsorted part are picked and placed in the sorted part.

QUICK SORT:-
Quick sort is divide and conquer algorithm.First, it picks an element as pivot and divide the given array around the picked pivot.We can take any element of array as pivot.

MERGE SORT:-
Like Quick Sort, Merge sort is also divide and conquer algorithm.It divides input array in two halves ,calls itself for the two halves and then merge the two sorted part.

PROGRAM
👉BASICS OF A PROGRAM:-
Basically, this program is for comparing the sorting algorithm.
Which algorithm takes less time to sort the no. of elements??

This is simple as we write a program consisting all the five algorithm .






informative
ReplyDelete