Computers and Technology

Suppose we want to find the 2nd largest and 2nd smallest elements simultaneously for an input of n numbers stored in an array a[1: n]. compare the following strategies in terms of their exact number of comparisons. strategy 1: adapt the two separate for loops idea for minimum and maximum. strategy 2: run mergesort to sort the numbers in ascending or descending order, then output the 2nd ranked and (n-1)th ranked elements. first write each algorithm in pseudocde, then analyze the exact number of comparisons required by the algorithm. note, asymptotic calculations will only get you partial credit for this problem. can you find a better strategy for this problem than the two given? if yes, write the algorithm and analyze the exact number of comparisons required by the algorithm. if not, prove that one of the given strategies is optimal.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:00, SoccerHalo
How is the number 110 written when expanded out to place values in the base 2 (binary) number system? options: 2 x 4 + 3 x 2 + 4 x 1 1 x 2 + 1 x 2 + 0 x 2 1 x 100 + 1 x 10 + 0 x 1 1 x 4 + 1 x 2 + 0 x 1
Answers: 1
image
Computers and Technology, 22.06.2019 20:00, BreadOfTheBear
What statement best describes operating systems? it’s possible for modern computers to function without operating systems. most operating systems are free or very inexpensive. operating systems are managed by the computer’s microprocessor (cpu). operating systems manage the computer’s random access memory (ram).
Answers: 1
image
Computers and Technology, 24.06.2019 00:30, bsonicx
The best definition of an idiom is a. a word or phrase that describes a noun b. a word or phrase describing a verb c. a phrase containing figurative language in which the word expresses a different idea from its exact meaning d. a phrase that compares two unlike objects or ideas
Answers: 2
image
Computers and Technology, 24.06.2019 01:30, shonnybenskin8
Hazel has just finished adding pictures to her holiday newsletter. she decides to crop an image. what is cropping an image?
Answers: 1
Do you know the correct answer?
Suppose we want to find the 2nd largest and 2nd smallest elements simultaneously for an input of n n...

Questions in other subjects:

Konu
Chemistry, 12.03.2021 19:50
Konu
Mathematics, 12.03.2021 19:50