1. Questions on Big-Oh, Theta, etc.: (a) Give the standard Theta (e()) form for each of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Questions on Big-Oh, Theta, etc.: (a) Give the standard Theta (e()) form for each of the following func- tions. (E.g., 2n+3 would be written as e(n).) [10 marks] 1. 2n+3n2(logn)3+2 2. 7n logn+2n+1234 3. 5n log(n) 4. (2n+7+5)(n+1) 5. 21n (log n) +2n4 + 2n (logn)" (b) Put the following Theta classes in order of increasing growth (e.g.. increasing running times). [10 marks] e(logn), (n2), O(nlogn), (1), e (ing) (3"), (n!), log e(n) Remark: It is more important that you get the order right between the first four classes listed than that the last four are placed correctly. (c) Following are some big-Oh relationships. For each, give witnesses no and c that can be used to prove the relationship. [9 marks] 1. 7n is O(n) 2. 4+3 is O(22) 3. 5n logn is O(n). 19 36 47 11 32 42 65 27 (a) A BST for questions 2(b)-(d). (b) The BST for question 2(e). Figure 1: An empty BST for questions 2(b), 2(c), and 2(d) on left and the BST for question 2(e) on right. 2: Binary Search Trees (BSTs) (a) Insert the following items into a BST, in the following order: [11, 5, 10, 21, 49, 35, 8, 46]. Show the resulting tree. [6 marks] (b) Put the following items into the BST in Figure la [28, 37, 13, 48, 56, 9, 50, 62]. Is this always unique for a fixed array and a fixed BST? Justify your answer. [6 marks] (c) Mark all non-balanced nodes in the BST in Figure la. Justify your answer. [6 marks] (d) In the BST you got in the part (b) delete the following items, in the following order: [9, 50, 28] (So when deleting 50, 9 is not in the tree any-more...). Show how the BST changes in each deletion. [6 marks] (e) Consider the AVL Tree in Figure 1b. Delete the number 11 to the tree. Note that you might need to do some rotations to preserve the AVL property. [6 marks] 3: Express your answers for the following two questions in Big-Oh notation. Justify your answers. (a) Show an upper bound on the running time of the following function. [5 marks] void fnA (int[] array, int n) { int counter 1; int sum = 0; while (counter < n) { for (int i=0; i < n; i++) { } sum += array[i]; counter += 1; (b) The following is a sorting algorithm that uses the same merge routine as merge sort. Show an upper bound on its running time. [10 marks] Recall that the merge (A, low, mid, high) routine call joins the sorted segments A [low...mid] and A[mid+1...high] into a new sorted list, then copies it into A [low...high]. void sort2 (int[] array, int n) { int chunk-1; while (chunk < n) { for (int low 0; low chunk < n; low + 2*chunk) { } merge (array, low, low+chunk-1, low+2*chunk-1); chunk chunk*2; } 5. Consider the following function fn. 1 23456789 int fn(n) { if (n 0) { } } 10 } return 1; int sum = 0; for (int i=0; i 1. Questions on Big-Oh, Theta, etc.: (a) Give the standard Theta (e()) form for each of the following func- tions. (E.g., 2n+3 would be written as e(n).) [10 marks] 1. 2n+3n2(logn)3+2 2. 7n logn+2n+1234 3. 5n log(n) 4. (2n+7+5)(n+1) 5. 21n (log n) +2n4 + 2n (logn)" (b) Put the following Theta classes in order of increasing growth (e.g.. increasing running times). [10 marks] e(logn), (n2), O(nlogn), (1), e (ing) (3"), (n!), log e(n) Remark: It is more important that you get the order right between the first four classes listed than that the last four are placed correctly. (c) Following are some big-Oh relationships. For each, give witnesses no and c that can be used to prove the relationship. [9 marks] 1. 7n is O(n) 2. 4+3 is O(22) 3. 5n logn is O(n). 19 36 47 11 32 42 65 27 (a) A BST for questions 2(b)-(d). (b) The BST for question 2(e). Figure 1: An empty BST for questions 2(b), 2(c), and 2(d) on left and the BST for question 2(e) on right. 2: Binary Search Trees (BSTs) (a) Insert the following items into a BST, in the following order: [11, 5, 10, 21, 49, 35, 8, 46]. Show the resulting tree. [6 marks] (b) Put the following items into the BST in Figure la [28, 37, 13, 48, 56, 9, 50, 62]. Is this always unique for a fixed array and a fixed BST? Justify your answer. [6 marks] (c) Mark all non-balanced nodes in the BST in Figure la. Justify your answer. [6 marks] (d) In the BST you got in the part (b) delete the following items, in the following order: [9, 50, 28] (So when deleting 50, 9 is not in the tree any-more...). Show how the BST changes in each deletion. [6 marks] (e) Consider the AVL Tree in Figure 1b. Delete the number 11 to the tree. Note that you might need to do some rotations to preserve the AVL property. [6 marks] 3: Express your answers for the following two questions in Big-Oh notation. Justify your answers. (a) Show an upper bound on the running time of the following function. [5 marks] void fnA (int[] array, int n) { int counter 1; int sum = 0; while (counter < n) { for (int i=0; i < n; i++) { } sum += array[i]; counter += 1; (b) The following is a sorting algorithm that uses the same merge routine as merge sort. Show an upper bound on its running time. [10 marks] Recall that the merge (A, low, mid, high) routine call joins the sorted segments A [low...mid] and A[mid+1...high] into a new sorted list, then copies it into A [low...high]. void sort2 (int[] array, int n) { int chunk-1; while (chunk < n) { for (int low 0; low chunk < n; low + 2*chunk) { } merge (array, low, low+chunk-1, low+2*chunk-1); chunk chunk*2; } 5. Consider the following function fn. 1 23456789 int fn(n) { if (n 0) { } } 10 } return 1; int sum = 0; for (int i=0; i
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
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...
-
importance of workalike balance for women as a leader in healthcare. 1. The purpose of the research; 2. Research question/s; 3. Findings and relevant data; 4. Any recommendations and; 5. The...
-
Tin - Can, Inc. Aircraft ( TCAI ) R&D Project Management Problem Your group is hired to help TCAI Project Manager to solve the following problem. Using the activity time estimates and activity...
-
The data in Toys R Us are quarterly revenues (in $millions) for Toys R Us from 1996-Q1 through 2013-Q1. a. Do you think that the revenues for Toys R Us are subject to seasonal variation? Explain. b....
-
A heat engine using 1.0 mol of a monatomic gas follows the cycle shown in FIGURE P21.55. 3750 J of heat energy is transferred to the gas during process 1 2. a. Determine W s , Q, and ÎE th for...
-
Your instructor will divide your class randomly into groups of four to six people. Acting as a team, with everyone offering ideas and one person serving as official recorder, each group will be...
-
Multiple-choice questions: a. Which of the following statements is incorrect? 1. Ratios are fractions expressed in percent or times per year. 2. A ratio can be computed from any pair of numbers. 3. A...
-
Hi guys, write 300 words for each of the discussion questions. 1) Compare and contrast benefits and challenges that exist between centralized database management systems and distributed database...
-
A 50 kg woman skating to the right at 3 m/s skates into a a 20 kg boy travelling 2 m/s to the left. After they meet, they continue skating arm-in-arm on the frictionless ice. a) What is the speed and...
-
FORM 1120-U.S. CORPORATION INCOME TAX RETURN The Falcon Machinery Corp., 271 East Beaumont Street, Chicago, Illinois 60612, keeps its books on the calendar-year, accrual basis. It is engaged in the...
-
In a rugby game that lasts exactly 50 minutes, there are 12players, plus 8 substitutes who alternate equally with each player.This means that all players, including substitutes, are on thepitch for...
-
For its fiscal year ending October 31, 2020, Antonio Corporation reports the following partial data. Income before income taxes $390,000 Income tax expense (40% x $509,000) 203,600 Income from...
-
The Alpine House, Incorporated, is a large retailer of snow skis. The company assembled the information shown below for the quarter ended March 31: Sales Selling price per pair of skis Variable...
-
Wendys 4 for $4 offers eight great-tasting entres. Pair anentre with nuggets, fries and your choice of 1 of 5 availabledrinks and youve got yourself a meal deal that cant be foundanywhere else. How...
-
Choco Inc. acquired all of the outstanding common stock of Allie Co. on January 1, 2017(t), for $620,000 cash. Following is the balance sheet for Allie Co. in December 31, 2016. Book Value Fair Value...
-
What are the two components of a company's income tax provision? What does each component represent about a company's income tax provision?
-
Lisa Sizemore, a taxpayer in the 10-15 percent tax bracket, purchased stock as an investment on July 11, 2011. She sold the stock on July 9, 2012, 2 days before qualifying for the long-term holding...
-
Matthew borrows $250,000 to invest in bonds. During 2012, his interest on the loan is $30,000. Matthew's interest income from the bonds is $10,000. This is Matthew's only investment income. a....
-
Leslie is a single taxpayer who is under age 65 and in good health. For 2012, she has a salary of $23,000 and itemized deductions of $1,000. Leslie is entitled to one exemption on her tax return. a....
-
Long Weekend Ltd suffered a severe drop in sales and profit performance for the year ended 30 June 2019. The income statement revealed that net sales were $1 500 000 with a profit of $310 000. Unit...
-
TMP Human Resource Consulting had the following contribution margin income statement for the year ended 2019. Required Answer each of the following independent situations. (a) Explain how an...
-
Selcombe, Selcombe and Selcombe Media are three generations of the one family involved for nearly 50 years in providing public relations services. The firm is preparing its fees budget for the year...
Study smarter with the SolutionInn App