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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:00, ziahziah
Which function key is used to enable the spelling & grammar function in a word processing program such as microsoft word?
Answers: 3
image
Computers and Technology, 23.06.2019 18:50, ana7496
What is transmission control protocol/internet protocol (tcp/ip)? software that prevents direct communication between a sending and receiving computer and is used to monitor packets for security reasons a standard that specifies the format of data as well as the rules to be followed during transmission a simple network protocol that allows the transfer of files between two computers on the internet a standard internet protocol that provides the technical foundation for the public internet as well as for large numbers of private networks
Answers: 2
image
Computers and Technology, 24.06.2019 00:30, sethhdoty
Use the keyword strategy to remember the meaning of the following word. the meaning for the word has been provided. write your keyword and describe the picture you would create in your mind. obfuscate: to make something so confusing that it is difficult to understand.
Answers: 2
image
Computers and Technology, 24.06.2019 13:50, jaystarr9395
Write a program that performs a simple n-body simulation, called "jumping leprechauns." this simulation involves n leprechauns, numberd 1 to n. it maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, g_i = 1000000 for each i = 1,. in addition, the simulation also maintains, for each leprachaun, i, a place on the horizon, which is represented as a double-precision floating point number, x_i. in each iteration of the simulation, the simulation processes the leprachauns in order. processing a leprachaun i during its iteration begins by computing a new place on the horizon for i, which is determined by the assignment:
Answers: 3
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 in other subjects:

Konu
Mathematics, 25.04.2020 07:42