codelike-logo
Min Heap Visualization
Min Heap

Min heap

Min heap are following properties.

1) That is complete Binary tree.

2) Parent key value are smaller than child key value.


Example OF Min Heap

3205030639952688567 Array Persentation03120250330463599652768885967
344185445593698947452 Array Persentation031442183544455596367988949741052

Check this given tree are min heap or not?

491949812822045242859835

This Given tree are 11 nodes and there are complete fill then this are satisfied 1 propeties. Know check second properties. Parent node are smaller to child node.

Start with root node [49].

491949812822045242859835

Parent node [49] value is smaller in left and right child [98,194]. that means this node are satisfied second condition. check other node.

Check node [98]

49194 98 12822045242859835

Parent node [89] value is smaller in left and right child [128,452]. that means this node are satisfied second condition. check other node.

Check another node [128]

4919498 128 Not Min heap22045242859835

Parent node [128] value is greater in left child [2]. that means this is not min heap.


Min heap conversion


4919498 128 22045242859835

Convert This Tree to Min heap step by step

Node [128] is not satisfied min heap. then swapping the node values 128 to 2.

4919498 2 Swap node value 1282045242859835

Note that after swapping this two node value again check previous node. In this time checking the node [98].

49194 98 2 Check Node 1282045242859835

Node [98 value] are bigger to left child then swap those value [98<=>2].

49194 2 98 Swap Node value 1282045242859835

In this time swapping the values of [98<=>20].

491942 20 Swap node value 1289845242859835

Check node [452].

491942 20 Check Node 1289845242859835

Swap node data [452<=>35]

491942 20 Swap node Data 1289835428598452

Check Node [2].

491942 20 Check Node 1289835428598452

Check node [49].

491942 20 Check Node 1289835428598452

Swap node data [42<=>2].

219449 20 swap node value 1289835428598452

Check node [49].

219449 20 check Node 1289835428598452

Swap node Data [20<=>49].

219420 49 swap node data 1289835428598452

Check node [194].

219420 49 Check Node 1289835428598452

Swap node data [85<=>194].

28520 49 Swap node Data 12898354219498452

Finally Tree is convert to min heap

28520 49 12898354219498452

How To Insert Min heap node


Insert node [1]. In given Tree.

28520 49 12898354219498452

After insert

220854935198981289845242 1 Inserted Node

After insert node [1]. tree are not min heap then convert.

220854935198981289845242 1 Check node

Swap node data [1<=>198].

2208549351981289845242 198 Swap node value

Check Node [85].

2208549351981289845242 198 Check node

Swap node value [1<=>85].

2201493585981289845242 198 Swap node value

Check Node [2].

2201493585981289845242 198 Check Node

Swap node value [1<=>2].

1202493585981289845242 198 swap node value

Convert Min Heap.



How to use


Suppose following [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] data are inserted on min heap. Put your data separated by hyphen-minus sign (-) and putting on input field.

Like This 10-9-8-7-6-5-4-3-2-1.

showing on input field and click to submit button . And view min heap operation like insertion and deletion.

https://www.codelike.in/animation/binary-min-heap/

Possible to submit any number of positive numeric value but separate by (-) minus symbol. Note that if you have not given any data. So this editor will put default 10 numeric value.

Visualization

Binary Tree

Binary Search Tree

Avl Tree

Splay Tree

Red Black Tree

Binary Min Heap

Search Sort

Linked List

Circular Single Linked List

Doubly Linked List

Circular Doubly Linked List

Tree Questions and solution, Back To Home