212k views
0 votes
You are in charge of the IT division for a company that has 1,048,576 customers. Your boss asks you to decide between buying a database system from Vendor A or Vendor B. Both systems are the same price but Vendor B’s computer (computers are included in each system) has hardware that is 1000 times faster than that provided by vendor A. However, Vendor A’s system is based on an algorithm that returns a response to a query in time proportional to 10nlog2n machine operations where n is the number of customers in the database while Vendor B’s system is based on an algorithm that returns a response to a query in time proportional to 10n2 machine operations. Vendor A’s computer has a speed of 1 nanosecond (=10-9 seconds) per operation.

How long (in seconds, rounded correctly to three decimal places to the right of the decimal) would Vendor A’s system take to return a response to a query based on your current number of customers? seconds


How long (in seconds, rounded correctly to three decimal places to the right of the decimal) would Vendor B’s system take to return a response to a query based on your current number of customers? seconds

User Unni
by
5.1k points

2 Answers

1 vote

Final answer:

Calculations reveal that Vendor A's system would take 0.209 seconds, while Vendor B's system, despite having hardware 1000 times faster, would take an infeasible 10,973.839 seconds due to the different algorithms used. Thus, Vendor A's system is the superior choice for query speed.

Step-by-step explanation:

To determine which database system to choose based on the query response times for 1,048,576 customers, we need to calculate the response times for both Vendor A and Vendor B given their respective algorithms and computer speeds.

For Vendor A, the time is proportional to 10nlog2n machine operations. Plugging in the number of customers we have:

TA = 10 * 1,048,576 * log2(1,048,576) * 10-9

We know that log2(1,048,576) = 20 because 220 = 1,048,576. So:

TA = 10 * 1,048,576 * 20 * 10-9 = 209,715.2 * 10-9 = 0.209 seconds (rounded to three decimal places)

For Vendor B, whose computer is 1000 times faster, the time is proportional to 10n2 machine operations.

TB = 10 * (1,048,576)2 * 10-9 / 1000

TB = 10 * 1,097,383,936,256 * 10-9 / 1000 = 1.097x1013 * 10-9 seconds = 10,973.839 seconds, which is not feasible for the system. Hence, Vendor A's system is clearly the better choice in terms of response time.

User Niroshan Ratnayake
by
6.0k points
4 votes

Answer:

See explaination for the details

Step-by-step explanation:

Vendor A's total operation = 10 * (1048576) * (log2(1048576)) = 209715200

time taken for A's = 209715200 * 10-9 = 0.2097152 second = 0.210 second

Now Vendor B's total operation = 10 * (1048576)2 = 1.09951163 * 1013

time taken for B's = 1.09951163 * 1013 * 10-9 = 1099.51163 second = 1099.512 second

User Bruno Brant
by
5.8k points