I need help with question 4 letters A AND B. And question number 8 letters A,B AND C.
a) Suppose that it takes 0.004 seconds to run a program on a te sot of size n 20o. Assume that the number of items in the actual da t α sot is 4000 , “hat would be the oxpec ted run-time (show your work) if the program is applied to the actual data set and the under lying algorithn ist 5 Assume that it takes 0.0012 seconds to run a program on a teot data of size n = 50 Assume that the number of items in the actual ata set is 80,000. What would be the expooted run-time (show your work) if the proor am is applied to the actual data set and the underlying algor ithm isi a. OCn) b. o(n) 6. Assume that an algorithm consists of two parte, one part is on and the other i o(n). What is the 8ig-0 run-time for the entire algorithm ? 7. The Paradox of Speed: Suppose that computers become 16 times faster. If the same amount of computer time is to be used, how müch can the data set size be increased if the underlying algorithm is: 2 a. O( n) b. o(n ) e. Determine the answer and explain why it is the answer: a. O( n) ( n) b. O( n) +O(n c. O log n) o(n) ? 2
Expert Answer
8
O(n) + O(n) = O(n)
O(n) + O(n^2) = O(n^2)
O(logn) + O(n) = O(n)
4
for O(n)
for 200 inputs time = 0.004 sec
for 4000inputs time = 0.08 sec (linear 0.004/200 * 4000)
for O(n^2)
for 200 inputs time = 0.004 sec
for 4000inputs time = 1.6 sec (linear 0.004/200^2 * 4000^2)
4.
for 100 inputs time = 0.002 sec
for 10000inputs time = 0.002 sec (O(1))
for 10000inputs time = 0.2 sec(O(n))
for 10000inputs time = 20 sec (O(n^2))
for 10000inpits time = 0.004 (O(logn)) 0.002 / log(100) * log(1000)
ADT
2. Encapsulation refers to data hiding. In encapsulation, the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class.
3.Implementaion of ADT reffers to creation of real usecase using the ADT. For example we can use Node ADT to create binary tree etc