Question

Assume that a max-heap contains one key equal to 1 and n - 1 keys equal...

Assume that a max-heap contains one key equal to 1 and n - 1 keys equal to 2.

In what type of a node is 1 located (in an internal node, in a leaf?). Why?

What is the minimum index i such that A[i] might contain 1?

Homework Answers

Answer #1

Given that a max-heap contains one key equal to 1 and n-1 keys equal to 2.

now, The 1 is located in leaf node, because if 1 is located in internal node then it should have a children with 2 which is impossible in max-heap.

So the 1 should be located in leaf node.

Assume the height of tree is h. then the minimu index i such that a[i] might contain 1 is 2^h -1.

Now assume n = 2^k and k = logn base 2. So now the height of the tree will be k-1. So the index will be 2^(k-1) - 1.

So the minimum index will be 2^(k-1) -1 , if n = 2^k

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
(a) Consider an initially empty max-heap, where the following keys are to be inserted one at...
(a) Consider an initially empty max-heap, where the following keys are to be inserted one at a time: 11, 19, 23, 12, 13, 17, 13, 14, 18, and 33. Draw the tree that results after building this max-heap. (b) Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a time and in the giver order , into an initially empty binary min heap. (c) Show the...
‏What is the output of the Euler tour in the normal binary search tree if the...
‏What is the output of the Euler tour in the normal binary search tree if the key insert order is 5 , 2 , 8 , 5 , 9 , 5 , 1 , 3 , 4 , 2 , 8 ? All keys equal to the node should be the right subtree of that node. ____________________________________________________________ ‏Construct the binary max - heap for the keys given below. Once all the keys are inserted, perform the remove maximum operation, and...
a). A man has n keys on a key ring, one of which opens the door...
a). A man has n keys on a key ring, one of which opens the door to his apartment. Having celebrated a bit too much one evening, he returns home only to find himself unable to distinguish one key from another. Resourceful, he works out a fiendishly clever plan: He will choose a key at random and try it. If it fails to open the door, he will discard it and choose at random one of the remaining n−1 keys,...
1. Suppose StudentID is the primary key of one table (e.g., the Students table) and the...
1. Suppose StudentID is the primary key of one table (e.g., the Students table) and the foreign key of another table (e.g., the Top10DesiredJobs table). If you can’t enforce the referential integrity relationship between these two tables, what might be the cause? Select one: a. The values of the primary key column are referenced by the values of the foreign key column. b. The foreign key contains duplicate data. c. The foreign key column contains values that do not exist...
(12pts) The mathematics main office has backup keys to the offices in Kiely Hall. One day...
(12pts) The mathematics main office has backup keys to the offices in Kiely Hall. One day Dr. Unlucky locked himself out of his office. So he borrowed the keys from the main office. Unfortunately, these keys have no room number on them and thus he has to try one by one. Suppose there are n keys and only one key will open Dr. Unlucky’s office. (a) (6pts) If he tries the keys at random and discards those that do not...
Let Xi, i=1,...,n be independent exponential r.v. with mean 1/ui. Define Yn=min(X1,...,Xn), Zn=max(X1,...,Xn). 1. Define the...
Let Xi, i=1,...,n be independent exponential r.v. with mean 1/ui. Define Yn=min(X1,...,Xn), Zn=max(X1,...,Xn). 1. Define the CDF of Yn,Zn 2. What is E(Zn) 3. Show that the probability that Xi is the smallest one among X1,...,Xn is equal to ui/(u1+...+un)
Assume one file has r = 10^6 records. Each record takes R = 100 bytes, of...
Assume one file has r = 10^6 records. Each record takes R = 100 bytes, of which 10 bytes are for the key of the record. Suppose the key values range from 1 through 1,000,000 inclusive. Assume the block size B is 1000 bytes for all files, and that an address (block pointer, tree node pointer, or data record pointer) takes 10 bytes. What is the blocking factor bfr i for the single level index ? How many index blocks...
This laboratory assignment involves implementing a data structure called a map. A map associates objects called...
This laboratory assignment involves implementing a data structure called a map. A map associates objects called keys with other objects called values. It is implemented as a Java class that uses arrays internally. 1. Theory. A map is a set of key-value pairs. Each key is said to be associated with its corresponding value, so there is at most one pair in the set with a given key. You can perform the following operations on maps. You can test if...
1.Consider the following (normalized) relational model (primary keys are underlined, foreign keys are in italics). EMPLOYEE(SSN,...
1.Consider the following (normalized) relational model (primary keys are underlined, foreign keys are in italics). EMPLOYEE(SSN, ENAME, EADDRESS, SEX, DATE_OF_BIRTH, SUPERVISOR, DNR) S U P E R V I S O R : foreign key refers to SSN in EMPLOYEE, NULL value allowed D N R : foreign key refers to DNR in DEPARTMENT, NULL value not allowed DEPARTMENT(DNR, DNAME, DLOCATION, MGNR) MGNR: foreign key refers to SSN in EMPLOYEE, NULL value not allowed PROJECT(PNR, PNAME, PDURATION, DNR) DNR: foreign...
Write a C++ program that would report all of the Min and Max. example: 1. 95...
Write a C++ program that would report all of the Min and Max. example: 1. 95 2. 95 3. 80 4. 80 lowest 80 on test(s): 3, 4 highest 95 on test(s): 1, 2 I have started it, however, this only outputs one of the Min and Max and not all of the other instances. #include<iostream> using namespace std; int main() { int grades[10] , min , max , minIndex , maxIndex ; int n , choice , rt ,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT