Test 1 Flashcards
When confronted with a new ___________ , there may be several possible solutions.
problem
A __________ is a question which requires an answer.
problem
A problem usually includes variables, called __________.
parameters
What is an algorithm?
A step - by- step procedure to solve all instances of a problem.
What are problems of an algorithm?
Difficult for complex algorithms
Hard to translate to a programming language
It is possible for sequential search to examine _______ element before solving the problem . It can be used whether the array is sorted or not.
every
A much faster algorithm is available if the array is sorted:
Binary Search
works by comparing x with the middle of the array. The algorithm then “ discards” either the first or second half of the array .
Binary search
It can be shown by mathematical induction that the recursive version performs approximately _________ operations.
2 ^ (n / 2)
The iterative version if recursion performs ____ operations.
n + 1
when the basic operation is done the same number of times for every instance of size n. In algorithm 1.2 (sum of array values), T(n) = n
Every-Case Time Complexity
when the amount of work performed by the algorithm depends on the values of other parameters. W(n) is the largest number of times the basic operation will be performed for an instance of size n. In algorithm (sequential search) W(n) = n
Worst-Case Time Complexity
When analyzing the Complexity of an algorithm, it is useful to observe some simplifying abstractions:
Do not worry about actual CPU time
Determine the number of times a basic operation is done as a function of n (the size of the input)
The total amount of work done by the algorithm is proportional to the number of times the basic operation is performed .
Once we determine the number of operations performed as a function of n(T (n) or W(n)) , we are interested in classifying algorithms according to their ________ or ____________ class.
order
complexity
Algorithms with time complexities such as n,100n, and 50n + 10 are called ____________ algorithms
linear -time
Algorithms with time complexities such as n ^ 2, 0.5n ^ 2 , and n ^ 2 + 10n + 1 are called _____________ algorithms
quadratic-time