Implementation | Algorithms Flashcards
What are standard algorithms?
Algorithms that appear in program after program.
List four standard algorithms.
- Input validation
- Find minimum/maximum
- Count occurrences
- Linear search
What is the purpose of input validation?
To restrict the data the user can input or to reject invalid input.
What type of loop is commonly used for input validation?
WHILE . . . DO . . . END WHILE conditional loop.
How does the REPEAT . . . UNTIL conditional loop function in input validation?
It checks for invalid input using an IF . . . THEN . . . END IF control structure.
True or False: The REPEAT . . . UNTIL algorithm is more efficient than the WHILE . . . DO . . . END WHILE algorithm for input validation.
False
What function is used to limit the length of an input string in input validation?
Length function.
What is a boolean flag in the context of input validation?
A boolean variable used to control the termination of the conditional loop.
What data structure is commonly used to store a list of values in the Find Minimum/Maximum algorithm?
Array.
Describe the Finding the Maximum algorithm.
It stores the largest value in a variable and checks the array contents one by one.
What is the first step in the Finding Minimum algorithm?
Set the variable for the smallest value equal to the first item in the array.
What does the Counting Occurrences algorithm do?
Counts how many times a particular value occurs in an array.
In the Counting Occurrences algorithm, what is the initial value of the counter?
Zero.
What is the purpose of the Linear Search algorithm?
To find an item in a list.
How does the Linear Search algorithm determine when to stop searching?
When the search term is found or the end of the array is reached.
True or False: The Linear Search algorithm can return the position of every instance of the search item.
False
What type of variable is used in the Linear Search algorithm to track whether an item has been found?
Boolean variable.
What is the main limitation of the linear search using a conditional loop?
It only returns the position of the first occurrence of the search item.