Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved 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

 

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

a Heres a pseudocode for a recursive implementation of the given algorithm function findMaxnumbers c... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Structures and Algorithm Analysis in Java

Authors: Mark A. Weiss

3rd edition

132576279, 978-0132576277

More Books

Students also viewed these Algorithms questions

Question

11. What is the evidence that taste is not suffi cient for satiety?

Answered: 1 week ago