Let's assume that a binary heap is represented using a binary tree such that each node may have a left child node and a right child node. For this type of representation, we can still label the nodes of the tree in the same way as we label the nodes for an array representation. That is, the root node has a label 1. In general, for a node with label i, its left child node will have a label 2i and the right child  has a label 2i+1.  For any i with 1 <= I <= n , Terry says that the following easy algorithm will walk you from the root node to the node with label i: First find the binary representation P of i.   Start with the rightmost bit (least significant bit) of P, walk down from the root as follow: For a 0 bit, walk to the left child, for a 1 bit walk to the right child. At the end, you’ll reach the node with label i.  Which of the following is the most appropriate? A. Terry’s algorithm is wrong and not fixable. B. Terry’s algorithm is right. C. Terry's algorithm can be fixed as follows: Walk from leftmost bit (most significant bit) of P. D. Terry's algorithm can be fixed as follows: Ignore the leftmost bit (the most significant bit) of P and Walk from the second leftmost (second most significant) bit of P.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Let's assume that a binary heap is represented using a binary tree such that each node may have a left child node and a right child node. For this type of representation, we can still label the nodes of the tree in the same way as we label the nodes for an array representation. That is, the root node has a label 1. In general, for a node with label i, its left child node will have a label 2i and the right child  has a label 2i+1.  For any i with 1 <= I <= n , Terry says that the following easy algorithm will walk you from the root node to the node with label i:

  • First find the binary representation P of i.  
  • Start with the rightmost bit (least significant bit) of P, walk down from the root as follow:
    • For a 0 bit, walk to the left child, for a 1 bit walk to the right child.
    • At the end, you’ll reach the node with label i.

 Which of the following is the most appropriate?

A. Terry’s algorithm is wrong and not fixable.

B. Terry’s algorithm is right.

C. Terry's algorithm can be fixed as follows: Walk from leftmost bit (most significant bit) of P.

D. Terry's algorithm can be fixed as follows: Ignore the leftmost bit (the most significant bit) of P and Walk from the second leftmost (second most significant) bit of P.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY