subject

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.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:00
How do we use the sumif formula (when dealing with different formats) ?
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
question
Computers and Technology, 24.06.2019 02:00
Write an expression that will cause the following code to print "equal" if the value of sensorreading is "close enough" to targetvalue. otherwise, print "not equal". ex: if targetvalue is 0.3333 and sensorreading is (1.0/3.0), output is:
Answers: 1
question
Computers and Technology, 24.06.2019 23:00
Why is it preferable to code web pages in html format? a. to create more lines code b. to apply general formatting rules c. to display properly as search results in all browsers d. to add meaning to the document
Answers: 1
You know the right answer?
Suppose we want to find the 2nd largest and 2nd smallest elements simultaneously for an input of n n...
Questions
Questions on the website: 13722363