Starting from:
$35

$29

Homework 2 Solution




In chapter two, we learn how to estimate the runtime of algorithms using big O notation.

The following exercieses ask you to visualize these estimates (10 pts each).




1. Visualize the runtime of revList on page 32.

2. Visualize the runtime of binary search on page 33.

3. Visualize the runtime of word frequency counter on page 35.

4. Visualize the runtime of word frequency counter on page 37.

5. Translate the pseudo code on page 38 into Scala code.

6. Visualize the runtime of the pseudo code on page 38.







How to record the runtime?

Write your code in a way that can print out the following:

1, t1

2, t2

3, t3

4, t4

....




The first columun has the data size, the second has the time for processing this data size.

Save these values in a file, then using Excel to plot the curve and you turn in these Excel files as

part of your HW.

More products