Given a minheap H and a key k give an algorithm to compute a
Given a min-heap H and a key k, give an algorithm to compute all the entries in H with key less than or equal to k. The reported result is not necessarily sorted in some order. Your algorithm should run in time proportional to the number of entries returned.
Solution
//Recursion Method void keyLessThan(Node *node, int k){ if (node->value >= k){ /* Skip this node and its descendants, as they are all >= k . */ return; } printf(\"%d\ \", node->value); if (node->left != NULL) keyLessThan(node->left, k); if (node->right != NULL) keyLessThan(node->right, x); }