Set Algorithm Complexity and Control Structure
- n1 = size of range 1, n2 = size of range
2; or n = size of each range
- Unsorted input ranges
- For each element in range 1, iterate through range2
- Runtime = Θ(n1 x n2) = Θ(n2)
- Sorted input ranges
- iterate through each range one time only
- Runtime = Θ(n1 + n2) = Θ(n)
- Sorted range control structure
- compare current elements from each input range
- perform action based on comparison
- increment past elements used for action
- continue until an input range is exhausted
- deal with tail of remaining range
|