Sorting 2nd
Sorting 2nd
SHELL SORT
MERGE SORT
RADIX SORT
BUCKET SORT
QUICK SORT
HEAP SORT
started from the least significant digit to the most significant digit.
ascending order of the first letter of their names. After that, in the
follows -
easier.
Radix Algorithm
have 3 digits in it. So, the loop will run up to three times
Now, first sort the elements on the basis of unit place digits
efficient.
1
/ \
3 5
/ \ / \
4 6 13 10
/\ /\
9 8 15 17
How does Heapify work?
The task to build a Max-Heap from above
array.
1
/ \
17 13
/ \ / \
9 15 5 10
/\ / \
4 8 3 6
How does Heapify work?
Heapify 1: First Swap 1 and 17, again swap 1
and 15, finally swap 1 and 6.
17
/ \
15 13
/ \ / \
9 6 5 10
/\ / \
4 8 3 1
How does Heapify work?
Follow the given steps to solve the
problem:
4
/ \
10 3
/ \
5 1
How does Heapify work?
{4, 10, 3, 5, 1}.
10
/ \
4 3
/ \
5 1
How does Heapify work?
{4, 10, 3, 5, 1}.
10
/ \
5 3
/ \
4 1
How does Heapify work?
{4, 10, 3, 5, 1}.
5
/ \
1 3
/
4
How does Heapify work?
{4, 10, 3, 5, 1}.
1
/ \
4 3
How does Heapify work?
{4, 10, 3, 5, 1}.
4
/ \
1 3
How does Heapify work?
{4, 10, 3, 5, 1}.
3
/ \
1
How does Heapify work?
{4, 10, 3, 5, 1}.
3
/ \
1
How does Heapify work?
Now when the root is removed once
again it is sorted. and the sorted array
will be like arr[] = {1, 3, 4, 5, 10}.