Algorithm Analysis Exercises
- Searching Algorithms
- Describe the algorithm for sequential search to your neighbor
- Describe the algorithm for binary search to your neighbor
- Outline the code for sequential search and binary search
-
Write the code for sequential search and binary search
- Algorithm Analysis
- A federal institution is considering contracting you to extend your lab project into a commercial grade program.
One question they have is how much is the program going to cost?
They're requesting a list of categorized costs for the program.
What costs are there in developing such a program?
-
Give examples of what is meant by n inputs for a given problem
-
What's the difference between:
- Best case
- Average case
- Worst case
What is the default for algorithm analysis if one is not specified?
-
List eight common growth functions and rank them in ascending order based on their Big-Oh:
- Demo: Shuffling Example
-
What are the 4 properties of growth-rate functions:
-
Determine the Big-Oh of the growth functions below:
- 5N + 4
- 9N2+ 8N - 7
- 2 log N
- 3N log 4N
- 6*27N
- 3N! + 1/2*N3
- 42
- 2*N3 + 999 * N2 + 123456789*N
Stuck? Plug in some numbers to get a better idea.
- What is the Big-Oh of sequential search?
- What is the Big-Oh of binary search?
-
Discuss with your neighbor(s) how understanding algorithm analysis will help you at your future job
- What is the worst case order for the following scenarios:
- Given an array and an index, displaying the element at the specified index in the array
- Given an array of Fibonacci numbers, adding together the first n values
- Finding an item in a sorted array of integers
- Finding an item in an array of integers
- Summing all elements in an ArrayList of Integers
- Summing the length of all strings in a two-dimensional array (n by m elements)
Last Modified: