Pseudocode
← Building blocks
Linear search
built by teacher Quan
N
Example
WHILE linear search
FOR linear search
1
DECLARE Num : ARRAY[1:5] OF INTEGER
2
DECLARE Found : BOOLEAN
3
DECLARE Index : INTEGER
4
Found ← FALSE
5
Index ← 1
6
WHILE Index <= 5 AND Found = FALSE
7
IF Num[Index] = N THEN
8
Found ← TRUE
9
ELSE
10
Index ← Index + 1
11
ENDIF
12
ENDWHILE
13
OUTPUT Found
Hide notes
← Step
Step →
Reset
Random