Sorting Algorithm
Sorting Algorithm
Algorithm
PRESENTED
BY Krishna
Garg
Array
• An array is a collection of similar data items stored
together in one place. .
9 3 8 1
Sorted List
1 3 8 9
Accending
Order
Types of Sorting
•
Algorithm:-
Bubble Sort
• Selection Sort
• Insertion Sort
• Merge Sort
• Quick Sort
• Heap Sort
Bubble Sort :-
• Bubble Sort is a technique in which we compare two
wrong order. 0 1 2 3
9 3 8 1
is sorted.
9 3 8 1
1
Step 9 3 8 O 1, 1
1
Step 3 9 8 1 1, 2
2
Step 3 8 9 2 1, 3
3
3 8 1 9
PASS
no need to
2 :-
Step swap O 9, 1
3 8 1
1
Step 3 8 1 1 9, 2
2
3 1 8 9
PASS
3 :-
Step 3 1 8 O 9, 1
1
1 3 8 9 Sorted list
Selection Sort
• This sorting algorithm is an in-place comparison-based
algorithm.
PASS 2 1 23 10 5 2 1 10 23 5 2
1 10 23 5 2 1 10 5 23 2
PASS 3
1 5 10 23 2
PASS 4 1 5 10 23 2 1 5 10 2 23
1 5 2 10 23 1 2 5 10 23
Sorte
Merge Sort
• Merge Sort is a divide and
conquer algorithm.