Your lecturer is a funny guy; given an unsorted list of integer numbers of n elements,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Your lecturer is a funny guy; given an unsorted list of integer numbers of n elements, and to find the largest number in the list, he will first initialize a variable, let's say max, to the smallest possible number an integer can be, and randomly select an element (a number) from the unsorted list. Check if this number is greater than the variable max. If it is, he will set the variable max to the number. Next, he will discard the number from the list and create a new list. The new list now has n - 1 elements. He will continue with the same process on the n-1 elements list until the unsorted list has no more element. When this happens, the variable max will contain the largest number in the list. (a) Write in pseudocode a recursive implementation of the described algorithm. (b) Analyse the asymptotic complexity of the algorithm. Give the worst-case, average- case and best-case running time in terms of 8 notation. Justify your answer. Your lecturer is a funny guy; given an unsorted list of integer numbers of n elements, and to find the largest number in the list, he will first initialize a variable, let's say max, to the smallest possible number an integer can be, and randomly select an element (a number) from the unsorted list. Check if this number is greater than the variable max. If it is, he will set the variable max to the number. Next, he will discard the number from the list and create a new list. The new list now has n - 1 elements. He will continue with the same process on the n-1 elements list until the unsorted list has no more element. When this happens, the variable max will contain the largest number in the list. (a) Write in pseudocode a recursive implementation of the described algorithm. (b) Analyse the asymptotic complexity of the algorithm. Give the worst-case, average- case and best-case running time in terms of 8 notation. Justify your answer.
Expert Answer:
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these algorithms questions
-
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...
-
) Consider integer division of one two's-complement binary number by another. Programming languages may vary in the result when one argument is negative. What differing conventions might they be...
-
(a) By what percentage does your rest mass increase when you climb 30 m to the top of a ten-story building? Are you aware of this increase? Explain. (b) By how many grams does the mass of a 120-g...
-
Normal radiofrequency waves cannot penetrate more than a few meters below the surface of the ocean. One method of communicating with submerged submarines uses very low frequency (VLF) radio waves....
-
A car travels around a circular track having a radius of r = 300 m such that when it is at point A it has a velocity of 5 m/s, which is increasing at the rate of v = (0.06t) m/s 2 , where t is in...
-
In February 2007, The Elliot Group, Inc., an Illinois real estate developer, made a deal with the Village of Arlington Heights to develop property in that village. Arlington Market, LLC, was...
-
Selected T-accounts of Moore Company are given below for the just completed year: Required: 1. What was the cost of raw materials put into production during the year? 2. How much of the materials in...
-
A small electric immersion heater is used to heat 87 g of water for a cup of instant coffee. The heater is labeled "120 watts" (it converts electrical energy to thermal energy at this rate)....
-
Comparative statements of shareholders? equity for Anaconda International Corporation were reported as follows for the fiscal years ending December 31, 2021, 2022, and 2023. Required: 1. Infer from...
-
What is the significance of the authors comment that "her features are no worse than theirs" when comparing the flower girl to the mother and daughter" what other comment does it parallel and why?
-
Firm B has a 12% ROE. Other things held constant, what would its expected growth rate be if it paid out 25% of its earnings as dividends? 75%?
-
The Zinn Company plans to issue $20,000,000 of 10-year bonds in March 2021 to help finance a new research and development laboratory. Assume that interest rate futures maturing in March 2021 are...
-
The Olsen Company has decided to acquire a new truck. One alternative is to lease the truck on a 4-year contract for a lease payment of $9,748 per year, with payments to be made at the beginning of...
-
Storm Software wants to issue $100 million in new capital to fund new opportunities. If Storm raised the $100 million of new capital in a straight-debt 20-year bond offering, Storm would have to...
-
In the summer of 2021, the Gallatin Company was planning to finance an expansion with a convertible security. It considered a convertible debenture but feared the burden of fixed interest charges if...
-
Determine the molecular formula of a compound that shows an m/z ratio at 86 and the intensity of a base at 10.
-
What key concerns must functional tactics address in marketing? Finance? POM? Personnel?
-
Using Stirling's formula, N! (N/e)N 2N, give a precise estimate for log(N!).
-
Write a program that lists all files in a directory and their sizes. Mimic the routine in the online code.
-
If all the edges in a graph have weights between 1 and |E|, how fast can the minimum spanning tree be computed?
-
Discuss how a new brand manufacturer would go about defining their market segments and then begin to target them.
-
Go to www.kellogs.com, and examine the brands offered by Kelloggs. Using the BCG growth-share matrix, classify 10 brands as stars, question marks, cash cows, or dogs. Find at least one product you...
-
Diff Eyewear is a successful business built around a socially conscious mission. The company makes and sells stylish eyewear with comparable quality but a significantly lower price than luxury...
Study smarter with the SolutionInn App