Wednesday, January 3, 2018

Heap rank

January 3, 2018

Introduction



Plan to read the blog about heap rank, the link is here.

Here is the gist I created for the algorithm. It turns out that the algorithm is the great one to practice depth first search using recursive function.



I like to write a sentence to explain how to use recursive solution to solve the problem. Give the value x in the heap, start from root node and see if it is bigger than value x, if it is true, and also there is neither left or right child, then return 1; we handle the base case first, and then we ask left subtree and right subtree to solve the same problem as well.

No comments:

Post a Comment