Tree insertion sort We can sort n objects in O(n log n) unit operations as follows:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Tree insertion sort We can sort n objects in O(n log n) unit operations as follows: We first initialize an empty binary search tree T. We second insert each of the n elements into T in turn. We third traverse the tree T and output the n elements in T using an in-order traversal. If we can insert an element into the tree in O(log |T) time, where |T| denotes the size of the tree, then our sorting algorithm will run in time O(n log n). There are several binary search trees in which basic operations can be done in time O(log |T]), such as red-black trees, AVL trees, and B-trees, which enables e.g. sorting in O(n logn). For the purposes of this assignment, we can mostly think of such a tree as an array, but where all standard operations take time O(log |T]). Let us define T[j] to denote the ith smallest element in T. In such trees, we can conduct a search in time O(log |T]), no matter which variant it may be, including e.g. "find the largest index j for which T[j] x," "find the largest index j for which T[j] < x," "find the smallest index j for which T[j] > x," "find the smallest index j for which T[j] x." Let A [11, 3, 2, 7, 13, 5, 9, 4, 12, 1] be an unsorted array of n = 10 elements which we sort using the above tree insertion method. After one insertion, our tree is T = [11]. After two insertions, our tree is T = [3, 11]. After six insertions, our tree is T = [2, 3, 5, 7, 11, 13]. Note that the sixth element A[6] = 5 is inserted at index 3. - Dominating points in the plane Now for the first application of insertion sorting. We are given n points pi = plane. Here is an example of eight points. Y .4 .2 .3 .1 .7 .6 = X We say a point p (a, b) dominates a point q = (a', b') if a a' and b b' and p q. If p dominates 9, then we say that (p, q) is a dominating pair. In the example, point 4 dominates the three points {1,2,3}, and point 6 dominates the two points {1,5}. The example contains 21 dominating pair. 1. Fill in the remaining six number of points each point dominates in the first line in the table shown below. 1 Number of points dominating: Inserted at index (key is (y, x)): 1 2 3 4 3 5 =(x, y) in the 6 2 7 8 8 2. We now insert the eight points into an initial binary search tree as discussed above, in turn, in the order they are labeled above, and as we insert each point, we note the index at which the point is being inserted. We insert a point with respect to key (y,x). That is, for points (a, b) and (a', b'), then (a, b) > (a', b') if b> b' or (b= b' and a > a'). Fill in the index at which each of the eight points are being inserted at in the table given. 3. Succinctly give an O(n log n) algorithm for the dominating pairs problem, which is as follows: Given a set of n distinct points in the plane, compute the number of dominating pairs among the n points. (In the example above, the output should thus be 21.) Briefly argue why your algorithm is correct and runs in O(n log n). The problem is designed so that your three answers may all fit into a single page, assuming a normal font-size, normal margins, on a blank page with no header/problem statement. Tree insertion sort We can sort n objects in O(n log n) unit operations as follows: We first initialize an empty binary search tree T. We second insert each of the n elements into T in turn. We third traverse the tree T and output the n elements in T using an in-order traversal. If we can insert an element into the tree in O(log |T) time, where |T| denotes the size of the tree, then our sorting algorithm will run in time O(n log n). There are several binary search trees in which basic operations can be done in time O(log |T]), such as red-black trees, AVL trees, and B-trees, which enables e.g. sorting in O(n logn). For the purposes of this assignment, we can mostly think of such a tree as an array, but where all standard operations take time O(log |T]). Let us define T[j] to denote the ith smallest element in T. In such trees, we can conduct a search in time O(log |T]), no matter which variant it may be, including e.g. "find the largest index j for which T[j] x," "find the largest index j for which T[j] < x," "find the smallest index j for which T[j] > x," "find the smallest index j for which T[j] x." Let A [11, 3, 2, 7, 13, 5, 9, 4, 12, 1] be an unsorted array of n = 10 elements which we sort using the above tree insertion method. After one insertion, our tree is T = [11]. After two insertions, our tree is T = [3, 11]. After six insertions, our tree is T = [2, 3, 5, 7, 11, 13]. Note that the sixth element A[6] = 5 is inserted at index 3. - Dominating points in the plane Now for the first application of insertion sorting. We are given n points pi = plane. Here is an example of eight points. Y .4 .2 .3 .1 .7 .6 = X We say a point p (a, b) dominates a point q = (a', b') if a a' and b b' and p q. If p dominates 9, then we say that (p, q) is a dominating pair. In the example, point 4 dominates the three points {1,2,3}, and point 6 dominates the two points {1,5}. The example contains 21 dominating pair. 1. Fill in the remaining six number of points each point dominates in the first line in the table shown below. 1 Number of points dominating: Inserted at index (key is (y, x)): 1 2 3 4 3 5 =(x, y) in the 6 2 7 8 8 2. We now insert the eight points into an initial binary search tree as discussed above, in turn, in the order they are labeled above, and as we insert each point, we note the index at which the point is being inserted. We insert a point with respect to key (y,x). That is, for points (a, b) and (a', b'), then (a, b) > (a', b') if b> b' or (b= b' and a > a'). Fill in the index at which each of the eight points are being inserted at in the table given. 3. Succinctly give an O(n log n) algorithm for the dominating pairs problem, which is as follows: Given a set of n distinct points in the plane, compute the number of dominating pairs among the n points. (In the example above, the output should thus be 21.) Briefly argue why your algorithm is correct and runs in O(n log n). The problem is designed so that your three answers may all fit into a single page, assuming a normal font-size, normal margins, on a blank page with no header/problem statement. Tree insertion sort We can sort n objects in O(n log n) unit operations as follows: We first initialize an empty binary search tree T. We second insert each of the n elements into T in turn. We third traverse the tree T and output the n elements in T using an in-order traversal. If we can insert an element into the tree in O(log |T) time, where |T| denotes the size of the tree, then our sorting algorithm will run in time O(n log n). There are several binary search trees in which basic operations can be done in time O(log |T]), such as red-black trees, AVL trees, and B-trees, which enables e.g. sorting in O(n logn). For the purposes of this assignment, we can mostly think of such a tree as an array, but where all standard operations take time O(log |T]). Let us define T[j] to denote the ith smallest element in T. In such trees, we can conduct a search in time O(log |T]), no matter which variant it may be, including e.g. "find the largest index j for which T[j] x," "find the largest index j for which T[j] < x," "find the smallest index j for which T[j] > x," "find the smallest index j for which T[j] x." Let A [11, 3, 2, 7, 13, 5, 9, 4, 12, 1] be an unsorted array of n = 10 elements which we sort using the above tree insertion method. After one insertion, our tree is T = [11]. After two insertions, our tree is T = [3, 11]. After six insertions, our tree is T = [2, 3, 5, 7, 11, 13]. Note that the sixth element A[6] = 5 is inserted at index 3. - Dominating points in the plane Now for the first application of insertion sorting. We are given n points pi = plane. Here is an example of eight points. Y .4 .2 .3 .1 .7 .6 = X We say a point p (a, b) dominates a point q = (a', b') if a a' and b b' and p q. If p dominates 9, then we say that (p, q) is a dominating pair. In the example, point 4 dominates the three points {1,2,3}, and point 6 dominates the two points {1,5}. The example contains 21 dominating pair. 1. Fill in the remaining six number of points each point dominates in the first line in the table shown below. 1 Number of points dominating: Inserted at index (key is (y, x)): 1 2 3 4 3 5 =(x, y) in the 6 2 7 8 8 2. We now insert the eight points into an initial binary search tree as discussed above, in turn, in the order they are labeled above, and as we insert each point, we note the index at which the point is being inserted. We insert a point with respect to key (y,x). That is, for points (a, b) and (a', b'), then (a, b) > (a', b') if b> b' or (b= b' and a > a'). Fill in the index at which each of the eight points are being inserted at in the table given. 3. Succinctly give an O(n log n) algorithm for the dominating pairs problem, which is as follows: Given a set of n distinct points in the plane, compute the number of dominating pairs among the n points. (In the example above, the output should thus be 21.) Briefly argue why your algorithm is correct and runs in O(n log n). The problem is designed so that your three answers may all fit into a single page, assuming a normal font-size, normal margins, on a blank page with no header/problem statement.
Expert Answer:
Related Book For
Algorithm Design And Applications
ISBN: 9781118335918
1st Edition
Authors: Michael T. Goodrich, Roberto Tamassia
Posted Date:
Students also viewed these algorithms questions
-
Which of the four worldwide learning and innovation processes is/are adopted by RedBull, and why? What types of competitive advantages do/es the adopted approach provide to the company RedBull?...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
The following data pertain to the securities of Linford Company during 2012, the companys first year of operations: a. Purchased 400 shares of Persimmon Corporation stock at $40 per share plus a...
-
Citrate synthase, one of the enzymes in the series of enzyme-catalyzed reactions known as the Krebs cycle, catalyzes the synthesis of citric acid from oxaloacetic acid and acetyl-CoA. If the...
-
Sales of industrial vacuum cleaners at Jonquel Parker Supply Co. over the past 13 months are shown below: a) Using a moving average with three periods, determine the demand for vacuum cleaners for...
-
We are separating methanol and water in a staged distillation column at total reflux to determine Murphree efficiency. Pressure is \(101.3 \mathrm{kPa}\). The column has a 2.0 -in. head of liquid on...
-
Benzene and trimethylamine (TMA) are to be separated in a three-stage liquid-liquid extraction column using water as the solvent. If the solvent-free extract and raffinate products are to contain,...
-
As a result of a slowdown in operations, Tradewind Stores is offering employees who have been terminated a severance package of $91,000 cash paid today; $91,000 to be paid in one year; and an annuity...
-
The following is the statement of financial position of TT and Co. (see Self-Assessment Question 3.1 on page 113) at the end of its first year of trading: Statement of financial position as at 31...
-
Hope is age 16 and claimed as a dependent on her mother's tax return. This year hope worked part-time at the local ice cream stand earning $2,000 and had interest income of $500. What amount of...
-
Examine the evolutionary arms race between hosts and pathogens, exploring the molecular strategies employed by pathogens to evade host immune responses and the mechanisms underlying host defense...
-
Comment the statement below: In the end, high inflation rates can significantly impact the three fundamental functions of money, serving as a medium of exchange, a unit of account, and a store of...
-
Because of existing leases, a property is projected to have NOI of $ 9 0 , 0 0 0 per year for each of the next 5 years. All of the leases will have expired at the end of the 5 years. If the property...
-
The VELOON company specializes in the manufacture and sale of laptops. It makes its forecasts by quarter. Its sales, like those of its competitors, are strongly influenced by seasonality. Each year,...
-
What career area did you research? Educational facilitator. What contact method did you use to gain this information? Why did you select this career field? What interests you the most about this...
-
To value a large publicly traded firm, if you use the effective tax rate instead of the marginal tax rate (which is often higher than the effective tax rate) all the way through your free cash flow...
-
Which task is performed by a book-keeper? A. Analysing the trading results B. Entering transactions in the ledger C. Preparing year-end financial statements D. Providing information for...
-
Let S = {a, b, c, d, e, f, g} be a collection of objects with benefit-weight values, a: (12, 4), b : (10, 6), c : (8, 5), d: (11, 7), e: (14, 3), f : (7, 1), g : (9, 6). What is an optimal solution...
-
Repeat the previous exercise for the code words, 0, 10, 101, 111. Data From Previous Exercise Fred says that he ran the Huffman coding algorithm for the four characters, A, C, G, and T, and it gave...
-
Prove that there exists a linear program in two variables with exactly one feasible solution.
-
Discuss what is meant by the tone at the top and why it is important. Further, discuss whether you feel it is ethical to be a whistle-blower.
-
Consider the following independent situations: 1. An international health club sells lifetime memberships costing \($1,500\) which allow the purchaser unlimited use of any of the clubs 300 facilities...
-
The Longo Corporation contracted with The Davis Company to manufacture various metal component parts that would be assembled by Longo before resale to Longos customers. Longo placed its most recent...
Study smarter with the SolutionInn App