Heap Sort is a sorting algorithm based on the heap data structure. A heap is a tree based data structure where the tree is a complete binary tree. A complete binary tree is a binary tree in which all levels are completely filled, except the last level which may or may not be complelety filled. Heaps can be of two types: Max Heap: In max heap, every parent node must have value greater than or equal to it's child's value. Min Heap: In min heap, every parent node must have value less than it's child's value. We are going to use the Max Heap for heap sort here. The sorting process includes: construction of a heap from the data, a max heap precisely, swapping of the first and last node, removing the last node from the heap and processing it for the remaining. With each cycle, the heap gets smaller and the list gets to sort. Illustration: Algorithm: Construct max heap from the list Swap the first node with the last node Remove last node from heap Perform step 1 to 3 for the...
It's about Technology and Machines, that is the future. Welcome to the world of Deep Learning, Machine Learning, Artificial Intelligence, Data Science, Programming, Coding, Data Structures and Algorithms (DSA).