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 5 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 (8,g, 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 Vy with colour CC. It is allowed for two parallel edges to exist between nodes Uy and Vx, 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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please help me with 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 3 steps with 2 images

Blurred answer
Knowledge Booster
Keywords
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education