Analyze the running time of lca

Assignment Help Data Structure & Algorithms
Reference no: EM131036661

Ancestor's algorithm

The least common ancestor of two nodes u and ν in a rooted tree T is the node w that is an ancestor of both u and ν and that has the greatest depth in T. In the off-line least-common-ancestors problem, we are given a rooted tree T and an arbitrary set P = {{u, ν}} of unordered pairs of nodes in T, and we wish to determine the least common ancestor of each pair in P. To solve the off-line least-common-ancestors problem, the following procedure performs a tree walk of T with the initial call LCA (T.root). We assume that each node is colored WHITE prior to the walk.

LCA(u)

1 MAKE-SET(u)
2 FIND-SET(u).ancestor = u
3 for each child ν of u in T
4 LCA(ν)
5 UNION(u, ν)
6 FIND-SET(u).ancestor D u
7 u.color = BLACK
8 for each node ν such that {u, ν } ∈P
9 if ν.color = = BLACK
10 print "The least common ancestor of"

u "and" ν "is" FIND-SET(ν).ancestor

a. Argue that line 10 executes exactly once for each pair {u,ν}∈P.

b. Argue that at the time of the call LCA(u), the number of sets in the disjoint-set data structure equals the depth of u in T .

c. Prove that LCA correctly prints the least common ancestor of u and ν for each pair {u, ν} ∈P.

d. Analyze the running time of LCA, assuming that we use the implementation of the disjoint-set data structure in Section 21.3.

Reference no: EM131036661

Questions Cloud

Find community program -focuses on addressing health issues : Identify one community based program (in Prince George's County, Maryland or Washington, D.C) that focuses on addressing health issues. The program will focus on behavior change, changing local environments for health, or developing new health pol..
Determine the mass fractions of the constituents of air : The composition of moist air is given on a molar basis to be 78 percent N2, 20 percent O2, and 2 percent water vapor.
Transactions demand for money : According to Baumol and Tobin, the transactions demand for money is
Business matters within the company : Mr. Smith is a retired director of XYZ Co Ltd, he was not appointed a director for the current year (2014), but still attends to many of the business matters within the company, and also attends the directors meetings to advise and mentor the new ..
Analyze the running time of lca : Prove that LCA correctly prints the least common ancestor of u and ν for each pair {u, ν} ∈P. Analyze the running time of LCA, assuming that we use the implementation of the disjoint-set data structure in Section 21.3.
Goals of the fed frequently conflict : 1. Unemployment us a bad thing, and the government should make every effort to eliminate it." Do you agree or disagree? Explain your answer. 2. Which goals of the Fed frequently conflict
Write comparative report on methodology all parties followed : Task: Read the ruling in both the Mittal Steel and SCI case and write a comparative report on the methodology all the parties followed in their assessment of excessive pricing. In your report specifically address the following: Factors assessed to..
Aggregate demand and real gross domestic product : the price level will drop.b. aggregate demand and real Gross Domestic Product (GDP) will not change.c. aggregate demand and real Gross Domestic Product (GDP) will increase by the amount of the spending increase.d. the government spending multiplie..
Why was that moment significant : After watching the video at http://www.youtube.com/watch?v=zT7TeryDzk0&feature=player_detailpage, consider how over time, the practice of psychology has become more widely accepted. What was one of the defining moments in the history of psycholog..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Sort the array 15 80 35 25 60 30 into descending order

The above algorithm has a fundamental flaw. As written, how does it change theArray?

  Examples of pseudocode containing control structures

From the above examples of pseudocode containing control structures, analyze the logic implemented in the pseudocode.

  For no-edge weights in the graph

And all you can find (out of the still-eligible distances) is an infinity for the minimum. So... "emergency exit" case out of the while loop (which isn''t in the pseudocode algorithm).

  Write pseudo-code for the given problem

Think of scenarios when you would use a) a while-loop, b) a do-until loop, c) a for-loop. Write one pseudo-code example for each

  Setup an example rsa public/private key pair using primes

RSA with three primes would also work: n = pqr, ?(n) = (p?1)(q?1)(r?1), gcd(e, ?(n)) = 1, and d = e^?1 (mod ?(n)).

  How to analyse spectrum of a digital signal using dft method

To learn how to analyse spectrum of a digital signal using DFT method. To learn how to perform I/O operations using interrupt method and program/implement them using the evaluation toolkit

  Edge connectivity of undirected graph-running maximum-flow

Illustrate how edge connectivity of undirected graph G = (V, E) can be determined by running maximum-flow algorithm on at most |V| flow networks, each having O(V) vertices and O(E) edges.

  Create world database using mysql

create World database using MySQL and write a Java or C# or program to access the DB

  Relationship between security mechanisms and attacks

Draw a matrix similar that shows the relationship between security mechanisms and attacks - Show the calculations for corresponding decryption of the ciphertext to recover the original plaintext.

  What should be modeled as threads

What should be modeled as variables? Which of them should be global (shared) and which can be local? What problems can occur in this game? (List all instances and be specific)

  Create an online student class registration system.

All information on classes, students, department, and instructors can be added, deleted, and updated.

  Describes the steps required to perform the task specified

Write an algorithm in structured English (pseudocode) that describes the steps required to perform the task specified. Some examples of pseudocode can be found athttp://www.unf.edu/~broggio/cop2221/2221pseu.htm

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd