1 / 16
Settings
<<<>>>
Here is a visual summary showing how to differentiate between a problem, a problem instance, an algorithm, and a program.
- static int sequential(int[] A, int K) {
- for (int i=0; i<A.length; i++)
- if (A[i] == K)
- return i;
- return A.length;
- }
- Sequential(A: array, k: integer)
- for i = 1 to arraySize(A) do
- if A[i] == k
- return i
- return arraySize(A)
Searching Problem
- Key 10
- Key 21
- Key 32
- Key 43
- Key 54
- Key 65
Target key
Found
Not found
Index of the target key
n
- 70
- 21
- 12
- 103
- 54
- 95
Target key = 10