You are on page 1of 1

OUTPUT “Statement regarding what you need to input”

INPUT variable name


IF condition
THEN OUTPUT “true statement”
ELSE IF condition
THEN OUTPUT”true statement”
ELSE
OUTPUT “false statement
END IF

linear search
first assign the index no
a= [“brown”,|”red”,”blue"] a = 0,1,2
then assign counter to zero\
counter = 0
check the value at position counter with the search alue
a[counter] == search value
a[0] == red
brown== red
false
if the value is not equal, increment cunter by 1
counter = counter + 1
counter = 0 + 1
counter 1
a[counter] = search value
a[1] == 20
20 == 20
true
Hence value was found at position 1

Binary search
first arrange the array in ascending order
a= [20,30,10] a=[10,20,30]
assign index no to each value
a= 0,1,2
assign begin, end and calculate mid= (begin + end )/ 2
begin = 0 end = 2
mid 0 + 2 /2 1

check if the value at mid == search_value then stop


20 30

else assign mid to begin or end depending on the value you are searhing
begin = 1 end 2

You might also like