1. How long would it take to remove the ⌈logn⌉ smallest elements from a heap that contains n entries, using the removeMin operation?2. Suppose you set the key for each position p of a binary tree T...
Popular Questions - Uncategorized
1. Design an algorithm for drawing general trees, using a style similar to the inorder traversal approach for drawing binary trees.2. Let the rank of a position p during a traversal be defined such...
What does each removeMin call return within the following sequence of priority queue ADT operations: insert(5, A), insert(4, B), insert(7, F), insert(1, D), removeMin( ), insert(3, J), insert(6, L),...
Let T be a tree with n positions. Define the lowest common ancestor (LCA) between two positions p and q as the lowest position in T that has both p and q as descendants (where we allow a position to...
Suppose each position p of a binary tree T is labeled with its value f(p) in a level numbering of T. Design a fast method for determining f(a) for the lowest common ancestor (LCA), a, of two...
Let T be a binary tree with n positions, and, for any position p in T, let dp denote the depth of p in T. The distance between two positions p and q in T is dp + dq − 2da, where a is the lowest...
Recent Comments