ITA - Week 3 Flashcards
What are the approaches to analyse Time Complexity
Theoretical Analysis and Empirical Analysis
What is Theoretical Analysis
Study the number of times the algorithm performs some basic operations
What is Empirical Analysis
Code and run the algorithm on a computer for some inputs and measure how long it takes
What are the disadvantages of empirical analysis
Depends on speed of computer
Wastes time to code solution if algorithm is slow
Can’t try all inputs
How is efficiency measured
Basic operations and input size
How is the size of an input determined for a list input
The number of elements in the list
What is log2^x
x
What will log n refer to
log base2 n
log2(x*y) = ?
log2 x + log2 y
log2(x/y) = ?
log2 x - log2 y
log2(x^y) = ?
y * log2 x
What is A for a given algorithm
Worst case efficiency - Max running time
Best case - Min running time
Average case - Avg running time
The average case is the average of the best and worst case. True or False?
False
When is binary searching used instead of sequential searching
When a list is pre-sorted, as it is more efficient
What is the idea of a binary search
Compare k with middle element
If k is smaller than the middle, focus only of the first half and vice versa