Summary:Algorithm specification

From Higher Computing Science
Jump to: navigation, search

Standard Algorithms

  • Input validation is an algorithm that asks the user for data within a particular range, and repeats the question until data in the correct range is entered.
  • Linear search is an algorithm that checks an array for the presence of a particular item of data. To do this, the user must be asked what they are searching for. Each item in the array will be compared to the search term, and if the item is found, a message is displayed.


  • Find the minimum is an algorithm that finds the smallest number in array. To do this, a variable will be used to store the smallest number. Each item in the array will be compared to this number, and if the number in the array is smaller than the lowest, then the variable that contains the lowest will be set to this new number.


  • Find the maximum is an algorithm that finds the highest number in array. To do this, a variable will be used to store the highest number. Each item in the array will be compared to this number, and if the number in the array is larger than the highest, then the highest will be set to this new number.


  • Counting occurrences is an algorithm that checks an array for the presence of a particular item of data and adds to a count each time it is found. To do this, the user must be asked what they are searching for. A variable storing the number of times the item is found is set to zero. Each item in the array will be compared to the search term, and if the item is found, the total will be updated by one.