Question: 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

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)=100,000,000 g(n)=1

pair 2: f(n)=100,000,000 g(n)=n

pair 3: f(n)=100,000,000 g(n)=n2

pair 4: f(n)=n g(n)=100,000,000

pair 5: f(n)=50 n g(n)=51 n

pair 6: f(n)=50 n g(n)=log(n)

pair 7: f(n)=n log(n) g(n)=n2

pair 8: f(n)=n2 log(n) g(n)=n3

pair 9: f(n)= g(n)=log(n)

pair 10: f(n)=n2 log2 (n) g(n)=n3

Your submission for part c should be a sequence of 10 False/True with the following meaning: if the 5th response is True it would mean that for the pair 5 f(n) is O(g(n)),

on the other hand if 5th response is False thenit wpuld mean that for the pair 5 f(n) is NOT O(g(n)),

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!