Input Validation: making sure that the data input by the user is acceptable e.g. in a suitable format and within the upper and lower limits of the data required by the software
RECEIVE userInput FROM (INTEGER) KEYBOARD WHILE userInput < lowerLimit OR userInput > uperLimit DO SEND “Input must be between” & lowerLimit & “and” & upperLimit TO DISPLAY RECEIVE userInput FROM (INTEGER) KEYBOARD END WHILE
Linear Search (efficient): sets a Boolean variable to false initially and uses an unconditional loop to set it to true when the item is found; the loop terminates when the item is found or the end of the array is reached
RECEIVE itemToFind FROM (INTEGER) KEYBOARD SET found to false SET arraySize to higestIndex SET counter TO 0 WHILE counter <= arraySize AND found = false SET counter to counter + 1 IF array[counter] = itemToFind THEN found=true END IF END WHILE IF found = true THEN SEND itemToFind & “found at position” & counter TO DISPLAY ELSE SEND “Item not found” TO DISPLAY END IF
Finding Minimum: sets an initial value to the first item in the array then compares it to the remaining items
SET maxiumValue to numbers[0] FOR counter FROM 1 TO 9 DO IF maximumValue < numbers[counter] THEN SET maximumValue to numbers[counter] END IF END FOR SEND “The largest value was” & maximumValue to DISPLAY
Finding Maximum: sets an initial value to the first item in the array then compares it to the remaining items
SET miniumValue to numbers[0] FOR counter FROM 1 TO 9 DO IF minimumValue > numbers[counter] THEN SET minimumValue to numbers[counter] END IF END FOR SEND “The smallest value was” & minimumValue to DISPLAY
Count Occurrences: sets a total to zero at the beginning and increments it as items are found to match the search item
RECEIVE itemToFind FROM (INTEGER) KEYBOARD SET numberFound to 0 FOR EACH number FROM numbers DO IF number=itemToFind THEN SET numberFound to numberFound+1 END IF END FOR EACH SEND “There were” & numberFound & “occurreneces of” & itemToFind & “in the list” TO DISPLAY
Thank you to C O’Toole & A Madill from Braidhurst High School for allowing me to edit and publish this here.