Jack has a complete binary tree with depth DD and N=2D-1-1N=2D+1-1 nodes (numbered 11 through NN). Node 11 is the root and each edge is either white or black. The shape of the tree is as follows: 2 4 5 7

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

computer engineering question 

Question 15: Code the given problem using python
Jack has a complete binary tree with depth DD and N=2D+1-1N=2D+1-1 nodes
(numbered 11 through NN). Node 11 is the root and each edge is either white or black. The
shape of the tree is as follows:
5
6
7
Let's number the levels of the tree 00 through DD from top to bottom. Each node at an odd
level is connected to its parent with a white edge (eg, edges 1-21-2 and 1-31-3), while
each node at an even level is connected to its parent with a black edge (e.g.
edges 2-42-4, 2-52-5, 3-63-6, 3-73-7).
Jack's friend Alice wants to pick two distinct nodes Uy and Vy and a colour Cc (white or
black) uniformly randomly and add an edge between the nodes Uy and Vx with colour CC. It
is allowed for two parallel edges to exist between nodes Uy and V after this operation.
A strip is an alternating cycle of white and black edges. Each vertex may appear any number
of times in a strip. Find the probability that a strip is created when Alice adds an edge to the
graph. It can be proved that this probability can be expressed as a fraction PQPQ,
where PP and QQ are positive integers and QQ is coprime
with 1,000,000,0071,000,000,007. You should
compute P-Q-1P-Q-1 modulo 1,000,000,0071,000,000,007, where Q-1Q-1 denotes the
multiplicative inverse of QQ modulo 1,000,000,0071,000,000,007.
Input:
1
2
Output:
142857144
Transcribed Image Text:Question 15: Code the given problem using python Jack has a complete binary tree with depth DD and N=2D+1-1N=2D+1-1 nodes (numbered 11 through NN). Node 11 is the root and each edge is either white or black. The shape of the tree is as follows: 5 6 7 Let's number the levels of the tree 00 through DD from top to bottom. Each node at an odd level is connected to its parent with a white edge (eg, edges 1-21-2 and 1-31-3), while each node at an even level is connected to its parent with a black edge (e.g. edges 2-42-4, 2-52-5, 3-63-6, 3-73-7). Jack's friend Alice wants to pick two distinct nodes Uy and Vy and a colour Cc (white or black) uniformly randomly and add an edge between the nodes Uy and Vx with colour CC. It is allowed for two parallel edges to exist between nodes Uy and V after this operation. A strip is an alternating cycle of white and black edges. Each vertex may appear any number of times in a strip. Find the probability that a strip is created when Alice adds an edge to the graph. It can be proved that this probability can be expressed as a fraction PQPQ, where PP and QQ are positive integers and QQ is coprime with 1,000,000,0071,000,000,007. You should compute P-Q-1P-Q-1 modulo 1,000,000,0071,000,000,007, where Q-1Q-1 denotes the multiplicative inverse of QQ modulo 1,000,000,0071,000,000,007. Input: 1 2 Output: 142857144
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

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