Question

In: Computer Science

need algorithm not code otherwise will downvote 10 times use ms team or latex code or...

need algorithm not code otherwise will downvote 10 times use ms team or latex code or pdf only
Consider an n-node complete binary tree T, where n = 2d − 1 for some d. Each node v of T is labeled with a real number xv. You may assume that the real numbers labeling the nodes are all distinct. A node v of T is a local minimum if the label xv is less than the label xw for all nodes w that are joined to v by an edge.
You are given such a complete binary tree T, but the labeling is only specified in the following implicit way: for each node v, you can determine the value of xv by probing the node v. Show how to find a local minimum of T using only O(logn) probes to the nodes of T.
Note:- dont use handwritten image

Solutions

Expert Solution

/*Dear Student, As you requested for the only algorithm, I have spent a lot of time and made these statements with algorithms in a simple and clear manner, so if you got something from it, then give it an Upvote. Thank You.*/

Q) Local minimum of T using only O(logn) probes to the nodes of T.

Ans: The algorithm is the following.

  • We begin at the root of the tree. and see if r is smaller than its two children. If so, the root is the local minimum. Otherwise, we move to any smaller child and iterate
  • The algorithm terminates when either (1) we reach a node v that is smaller than both its children or (2) we reach a leaf w. In the former case, we return v; in the latter case, we return w.

To find the local minimum in T we evaluate localMin(r). The algorithm performs O(d) =O(log n) probes of the tree;

We must now argue that the returned value is a local minimum. If the root is returned it is a local minimum as explained above.

  • If we terminate in case (1) v is a local minimum because v is smaller than its parent (since it was chosen in the previous iteration) and its two children (since we terminated).
  • If we terminate in case (2),w is a local minimum because w is smaller than its parent (again since it was chosen in the previous iteration).

Algorithm: Local Minimum in tree T

LocalMin(v) //This function finds the local minimum in the subtree rooted at v in T.

  

  

  


Related Solutions

Need to write a code using c# Strassen’s Algorithm for matrix multiplication.
Need to write a code using c# Strassen’s Algorithm for matrix multiplication.
Code in C# please. Write a program that will use the greedy algorithm. This program will...
Code in C# please. Write a program that will use the greedy algorithm. This program will ask a user to enter the cost of an item. This program will ask the user to enter the amount the user is paying. This program will return the change after subtracting the item cost by the amount paid. Using the greedy algorithm, the code should check for the type of bill. Example: Cost of item is $15.50 User pays a $20 bill $20...
A 64-year-old woman with multiple sclerosis (MS) is hospitalized. The team feels she may need to...
A 64-year-old woman with multiple sclerosis (MS) is hospitalized. The team feels she may need to be placed on a feeding tube soon to assure adequate nourishment. They ask the patient about this in the morning and she agrees. However, in the evening (before the tube has been placed), the patient becomes disoriented and seems confused about her decision to have the feeding tube placed. She tells the team she doesn’t want it in. They revisit the question in the...
I have to modify the following code to: 1. Use the unique algorithm to reduce the...
I have to modify the following code to: 1. Use the unique algorithm to reduce the array to unique values 2. Use the copy algorithm to display the unique results. #include<iostream> #include<vector> #include<algorithm> using namespace std; int main() {     //creating an array of 20 integers     int array[20];     //creating an empty vector     vector<int> vec;     //input from end user to get 20 ints and a for loop to interate through 20     cout << "Enter 20 integers:"...
At times firms will need to decide if they want to continue to use their current...
At times firms will need to decide if they want to continue to use their current equipment or replace the equipment with newer equipment. The company will need to do replacement analysis to determine which option is the best financial decision for the company. LoRusso Co. is considering replacing an existing piece of equipment. The project involves the following: • The new equipment will have a cost of $1,200,000, and it will be depreciated on a straight-line basis over a...
At times firms will need to decide if they want to continue to use their current...
At times firms will need to decide if they want to continue to use their current equipment or replace the equipment with newer equipment. The company will need to do replacement analysis to determine which option is the best financial decision for the company. Price Co. is considering replacing an existing piece of equipment. The project involves the following: • The new equipment will have a cost of $600,000, and it will be depreciated on a straight-line basis over a...
At times firms will need to decide if they want to continue to use their current...
At times firms will need to decide if they want to continue to use their current equipment or replace the equipment with newer equipment. The company will need to do replacement analysis to determine which option is the best financial decision for the company. Price Co. is considering replacing an existing piece of equipment. The project involves the following: • The new equipment will have a cost of $9,000,000, and it will be depreciated on a straight-line basis over a...
At times firms will need to decide if they want to continue to use their current...
At times firms will need to decide if they want to continue to use their current equipment or replace the equipment with newer equipment. The company will need to do replacement analysis to determine which option is the best financial decision for the company. Price Co. is considering replacing an existing piece of equipment. The project involves the following: • The new equipment will have a cost of $1,200,000, and it will be depreciated on a straight-line basis over a...
At times firms will need to decide if they want to continue to use their current...
At times firms will need to decide if they want to continue to use their current equipment or replace the equipment with newer equipment. The company will need to do replacement analysis to determine which option is the best financial decision for the company. Price Co. is considering replacing an existing piece of equipment. The project involves the following: • The new equipment will have a cost of $2,400,000, and it will be depreciated on a straight-line basis over a...
At times firms will need to decide if they want to continue to use their current...
At times firms will need to decide if they want to continue to use their current equipment or replace the equipment with newer equipment. The company will need to do replacement analysis to determine which option is the best financial decision for the company. Jones Co. is considering replacing an existing piece of equipment. The project involves the following: • The new equipment will have a cost of $1,200,000, and it is eligible for 100% bonus depreciation so it will...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT