Write "Enter item to search"
Read searchItem
Set position to 0
Set found to FALSE
WHILE(position < 10 AND found is FALSE)
IF(numbers[position] equals searchItem)
Set found to TRUE
ELSE
Set position to position + 1
Read in array of values
Write "Enter value for which to search"
Read searchItem
Set found to TRUE if searchItem is there
IF(found)
Write "item is fount"
ELSE
Write "Item is not found"
*Read in array of values
Write "How many values"
Read length
Set index to 0
Set found to FALSE
WHILE(index < length)
Read data[index]
Set index to index + 1
*Set found to TRUE if searchItem is there
Set index to 0
Set found to FALSE
WHILE(index < length AND NOT found)
IF(data[index] equals searchItem)
Set found to TRUE
ELSE IF(data[index] > searchItem)
Set index to length
ELSE
Set index to index + 1
Set first to 0
Set last to length-1
Set found to FALSE
WHILE(first <= last AND NOT found)
Set middle to(first + last) / 2
IF(item equals data[middle])
Set found to TRUE
ELSE
IF(item < data[middle])
Set last to middle - 1
ELSE
Set first to middle + 1
Return found
BinarySearch(first, last)
IF(first > last)
RETURN FALSE
ELSE
Set middle to (first + last) / 2
IF(item equals data[middle])
RETURN TRUE
ELSE
IF(item < data[middle])
BinarySearch(first, middle - 1)
ELSE
BinarySearch(middle + 1, last)
WHILE(not sortedYet)
Find smallest unsorted item
Swap firstUnsorted item with the smallest
Set firstUnsorted to firstUnsorted + 1
firstUnsorted < length - 1
Set indexOfSmallest to firstUnsorted
Set index to firstUnsorted + 1
WHILE(index <= length - 1)
IF(data[index] < data[indexOfSmallest])
Set indexOfSmallest to index
Set index to index + 1
Set tempItem to data[firstUnsorted]
Set data[firstUnsorted] to data[indexOfSmallest]
Set data[indexOfSmallest] to tempItem
Set firstUnsorted to 0
Set swap to TRUE
WHILE(firstUnsorted < length - 1 AND swap)
Set swap to FALSE
"Bubble up" the smallest item in unsorted part
Set firstUnsorted to firstUnsorted + 1
Set index to length - 1
WHILE(index > firstUnsorted)
IF(data[index] < data[index - 1])
Swap data[index] and data[index - 1]
Set current to 1
WHILE(current < length)
Set index to current
Set placeFound to FALSE
WHILE(index > 0 AND NOT placeFound)
IF(data[index] < data[index - 1])
Swap data[index] and data[index - 1]
Set index to index - 1
ELSE
St placeFound to TRUE
Set current to current + 1