Computers and Technology

1. (60 pts.) Analyzing Code. For each of the following, answer parts a-e. a.) (5pts.) Is the code correct? If not, provide a counterexample. b.) (3pts.) What is the asymptotic worst-case time complexity of the code. c.) (2pts.) What is the asymptotic worst-case space complexity of the code. d.) (3pts.) What is the asymptotic best-case time complexity of the code. e.) (2pts.) What is the asymptotic best-case space complexity of the code. i.) (15pts.) Maximum element (note this code is not the same as in the example in Notes3) double Max(double a[], int b, int e) { if (b>=e) { return a[b]; } else { int m=(b+e)/2; return(fmax(Max(a, b, m), Max(a, m+1, e))); } } // The following is the top level call to Max. // Returns the largest element in a. There are n elements in a[] double Max(double a[], int n) { return(Max(a, 0, n-1)); } ii.) (15pts.) Sequential Search version 1 int Find(double x, double a[], int b, int e) { if (b>=e) { if (a[e]==x) { return(e+1); } else { return(0); } } else { int m=(b+e)/2; int res=Find(x, a, b, m)

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, lexhorton2002
The great length of north america causes the climate to be varied. true false
Answers: 2
image
Computers and Technology, 22.06.2019 11:30, melissalopez12
Write a function so that the main program below can be replaced by the simpler code that calls function original main program: miles_per_hour = float( minutes_traveled = float( hours_traveled = minutes_traveled / 60.0 miles_traveled = hours_traveled * miles_per_hour print('miles: %f' % miles_traveled) sample output with inputs: 70.0 100.0 miles: 116.666667
Answers: 3
image
Computers and Technology, 23.06.2019 17:00, taytay1828
What are the 12 colors of the spectrum called?
Answers: 1
image
Computers and Technology, 24.06.2019 18:30, millie54
How does the use of e-mail benefit business communications? it can be sent at any time. it is faster than regular mail. it improves writing skills. it is less expensive than using a courier. it reduces the need for proofreading.
Answers: 1
Do you know the correct answer?
1. (60 pts.) Analyzing Code. For each of the following, answer parts a-e. a.) (5pts.) Is the code co...

Questions in other subjects:

Konu
History, 21.11.2019 18:31