Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

part a. 2p implement the three algorithms presented in the first class on slide 18 of the file Wk1_Ch04_the_efficiency_of_algorithms.pptx as 3 methods: methodA, methodB, methodC

part a. 2p implement the three algorithms presented in the first class on slide 18 of the file Wk1_Ch04_the_efficiency_of_algorithms.pptx as 3 methods: methodA, methodB, methodC There you have the algorithm A, B and C. You will run the three implementations of the algorithms with imputs and do the computation but it does not need to print to the screen the actual sum (for the last value it could exceed the maximum value stored into a long); it should print on the screen the time taken for the running of the algorithm : 1,000,000 1,000,000,000 1,000,000,000,000,000,000 To print the time you should use something like long startTime = System.currentTimeMillis(); methodA(1000000); long endTime = System.currentTimeMillis(); System.out.println("That method A for 1,000,000 took " + (endTime - startTime) + " milliseconds"); Your submission for part a should be the java file/files for solving the problem, an actual list of the running times for all the 3*3 possibilities (3 algorithm*3 imputs each)

part b. 2p Implement a STACK of floats as discussed in the second week of the class (for example WK2_b_Ch06_Stack_Implementations.pptx WK2_b_Ch06_Stack_Implementations.pptx - Alternative Formats ) as a linked list and as an array. You should ask the user what operation to do (Push/Pop/Peek/Clear/etc) and if needed the parameter needed then perform that operation. Your submission for part b should be the java file/files for solving the problem.

part c. 2p compare the following pairs of functions and say whether f(n) is O (g(n)) for each of the following: pair 1: f(n)=300,000,000 g(n)=1 pair 2: f(n)=300,000,000 g(n)=n pair 3: f(n)=300,000,000 g(n)=n2 pair 4: f(n)=n g(n)=300,000,000 pair 5: f(n)=10 n g(n)=11 n pair 6: f(n)=10 n g(n)=log(n) pair 7: f(n)=n log(n) g(n)=2 n2 pair 8: f(n)=n2 log(n) g(n)=3 n3 pair 9: f(n)= square root of n g(n)=3 log(n) pair 10: f(n)=n2 log2 (n) g(n)=3 n3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

Students also viewed these Databases questions