1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mama L [17]
3 years ago
9

You are given a tree T = (V;E) along with a designated root node r 2 V . The parent of any node v 6= r , denoted p(v), is de ned

to be the node adjacent to v in the path from r to v. By convention, p(r) = r. For k > 1, de ne pk(v) = pk????1(p(v)) and p1(v) = p(v) (so pk(v) is the kth ancestor of v). Each vertex v of the tree has an associated non-negative integer label l(v). Give a linear-time algorithm to update the labels of all the vertices in T according to the rule lnew(v) = l(pl(v)(v)).

Computers and Technology
1 answer:
il63 [147K]3 years ago
8 0

<u>Solution and Explanation:</u>

Linear time algorithm to update the label of all vertices in T :

-> It is given that the binary tree " T = ( V , E ) " with root node " r E V " . " P( V ) " is the node adjacent to ' V ' in the path from " r " to " V ".

-> By rule , "P ( r ) = r " and is defined that "Pk ( V ) - P k-1 ( P (V )) " and " P " (V ) = P (V )' for "K > 1 "

-> From the above defined statement , it means that

Pt ( V )" is ancestor of " V "

-> In this binary tree, each vertex , " V " is associated with the non - negative integer label "l(V)"

The following linear time alogrithm maintains the label of all the vertices currently on stack in an individually array. As the path may contain at 'n' vertices in tree, so the length of array is at most 'n'.

Please see the attached file.

You might be interested in
Which tab should be selected to add a hyperlink within a cell? Home tab Review tab Insert tab Formula tab
Mashcka [7]

Answer:

On the Insert tab

Explanation:

  1. You would select the tab that you want the Hyperlink to be in
  2. select the <em>Insert tab</em>
  3. There you will see a panel that says<em> link</em> press the down arrow than you will see a section that says <em>link</em> again there again you will press the down arrow which will show a option of document you want to add if your looking to add a link form a web browser than at the bottom of the list you will see <em>Insert Link</em>
  4. From there you will see a box pops up there you can upload a file from your computer or PC
  5. Once the box pops up you will enter the web browser page address in the box that says <em>address</em>
  6. From there press <em>okay</em> then your hyperlink will be in the cell you want
  7. If you don't know where or what a web browser address is than on the top of the web browser where you would insert what you are searching all you have to do is press it and it will automatically highlight the text than copy and paste the text by holding <em>Ctrl + C </em>to copy and holding <em>Ctrl + V </em>to paste

6 0
3 years ago
Read 2 more answers
Suppose that outfile is an ofstream variable and output is to be stored in the file outputData.out. Which of the following state
katrin [286]

Answer:

outFile.open("outputData.out");

4 0
3 years ago
Write a generator function named count_seq that doesn't take any parameters and generates a sequence that starts like this: 2, 1
-BARSIC- [3]

Answer:

#required generator function

def count_seq():

   #starting with number 2. using string instead of integers for easy manipulation

   n='2'

   #looping indefinitely

   while True:

       #yielding the integer value of current n

       yield int(n)

       #initializing an empty string

       next_value=''

       #looping until n is an empty string

       while len(n)>0:

           #extracting first digit (as char)

           first=n[0]

           #consecutive count of this digit

           count=0

           #looping as long as n is non empty and first digit of n is same as first

           while len(n)>0 and n[0]==first:

               #incrementing count

               count+=1

               #removing first digit from n

               n=n[1:]

           #now appending count and first digit to next_value

           next_value+='{}{}'.format(count,first)

       #replacing n with next_value

       n=next_value

#testing, remove if you don't need this

if __name__ == '__main__':

   #creating a generator from count_seq()

   gen=count_seq()

   #looping for 10 times, printing next value

   for i in range(10):

       print(next(gen))

Explanation:

6 0
4 years ago
List and discuss five economic growth indicators
patriot [66]
Strong employment numbers. To see economic growth there needs to be an increase in Gross Domestic Product (GDP). ...
Stable Inflation. ...
Interest rates are rising. ...
Wage Growth. ...
High Retail Sales. ...
Higher New Home Sales. ...
Higher Industrial Production.
5 0
2 years ago
The objectivity of a site relates to its a. Appearance c. Graphics b. Biases d. Quotes from other Internet authors
nadya68 [22]

The answer is Biases

The objectivity of evaluating a website relates to its ability to present issues based on different points of view. It is based on whether or not the information provided is presented in a fair and balanced way. For example, is the purpose of a certain website like Coca Cola or Pepsi meant to entertain, sell something, or sway public opinion? Do you think these websites will provide information on the negative effects of drinking carbonated beverages? I do not think so! Thus, these websites have bias. Their job is to sell you their product, not to make you think deep about it. We need to ask ourselves more questions about the websites we visit. Is this website balanced or biased in a way it presents information?


5 0
3 years ago
Read 2 more answers
Other questions:
  • Use cases can be used to document both the current (As-Is) system and the future (To-Be) system. A. True B. False
    13·1 answer
  • Which of these is a subdirectory? <br> HTTPS <br> /FAQ <br> .org <br> WWW
    15·1 answer
  • Which hypervisor works on older pcs without hardware virtualization support?
    9·2 answers
  • Technological uncertainty:
    15·1 answer
  • i got a set of headphones and when i plug them into my speakers the right side only works how do i fix the left side of them
    12·1 answer
  • Is USA TestPrep a test-taking site that won't let you access other windows without kicking you off?
    13·1 answer
  • 2. Discuss CORBA functions<br><br>​
    6·2 answers
  • Search the Web for three different employee hiring and termination policies. Review each and look carefully for inconsistencies.
    5·1 answer
  • Which of the following statements is TRUE? A. A name error occurs if the variable is referenced before it is declared. B. A name
    12·1 answer
  • the human resources department requests a list that contains the number (i.e. count) of orders taken on each date, grouped by th
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!