topics
- review
- linear search
- binary search
- selection sort
- reading
your first algorithm

linear search
found = "no";
i = 1;
while (found == "no" and i <= n)
{
if (A[i] == x)
{ found = "yes";
location = i;
}
i++;
}
if (found == "no")
{
print("sorry, " + x + " is not on the list");
}
else
{ print (x + " occures at position " + location + " on the list");
}
- = ← assignment operator (functions as a ←)
- thing to the left of the = is a variable
- java uses ;
- next to while, you see a boolean expression
- booleans: evaluate to true or false
- while loops
- as long as while loop evaulates to true, we keep doing it
- this is articulating repetition
- it articulates UNTIL
- if has a boolean expression next to it
- if boolean evaluates to true
- with if, you just stop when you finish