| | |

Question: Question 1: • Compare computers A and B that are running algorithms a and b. Algorithm a, takes time roughly equal to cynto sort n items, where C1 is a constant that does not depend on n. That is, it takes time roughly proportional to n?. In general, the code requires 4n2 instructions to sort n numbers. • Algorithm b, takes time roughly equal to canlgn, where Ign stands for log2 n and c2 is another constant that also does not depend on n. In general, the code requires 20nlgn instructions to sort n numbers. • Computer A executes 20 billion instructions per second and computer B executes 10 billion instructions per second. What is the time that it takes computers A and B to sort • 100 • 1000 • 10000 • 100000 • 1000000 numbers? – Free Chegg Question Answer

Transcribed text From Image: Question 1: • Compare computers A and B that are running algorithms a and b. Algorithm a, takes time roughly equal to cynto sort n items, where C1 is a constant that does not depend on n. That is, it takes time roughly proportional to n?. In general, the code requires 4n2 instructions to sort n numbers. • Algorithm b, takes time roughly equal to canlgn, where Ign stands for log2 n and c2 is another constant that also does not depend on n. In general, the code requires 20nlgn instructions to sort n numbers. • Computer A executes 20 billion instructions per second and computer B executes 10 billion instructions per second. What is the time that it takes computers A and B to sort • 100 • 1000 • 10000 • 100000 • 1000000 numbers?

Expert Chegg Question Answer:

free chegg question answer
Smart Teacher From Answerie.com
Answer:

Answer


Given Algorithms with Cost Function :

  1. Algorithm a = 4n2 # number of instructions to sort n numbers
  2. Algorithm b = 20n(log2n)  # number of instructions to sort n numbers
  3. Time to sort n number by Computer A using an algorithm a = 4n2/ 20 *109 seconds
  4. Time to sort n number by Computer B using an algorithm b = 20n(log2n) / 10 *109 seconds

The Chart is given below with the total time taken by Computer A and B for sorting :

Numbers to SortAlgorithm aAlgorithm BComputer AComputer B
1004000013287.72*10-6 sec1.3*10-6 sec
10004000000199315.62*10-4 sec1.99*10-5 sec
100004 * 1082657542.40.02 sec2.25*10-4sec
1000004 * 101033219280.92 sec3.32*10-3sec
10000004 * 10120.398*109200 sec0.0398sec


Free Chegg Question Answer

Leave a Reply

Your email address will not be published. Required fields are marked *