Algorithms/Pseudocode Flashcards
What is a SEQUENCE?
A SEQUENCE is a simple list (in order) of steps
What is a WHILE?
A WHILE is conditional – while a condition is true, the steps are run. A simple test at the start of each iteration.
What is a IF-THEN-ELSE?
A IF-THEN-ELSE is a decision – something is tested and one of 2 possible responses are run. These can be nested to create multiple levels.
What is a REPEAT-UNTIL?
A REPEAT-UNTIL is a loop which runs a test at the end of each iteration
What is a FOR?
A FOR is for counting loops
What is a CASE?
A CASE is for selecting from several options
What are the different structures?
o Repetition – loops, repeats
o Sequence – several unconnected steps in order (same as pseudocode)
o Recursion – problem solved by solving smaller versions of itself eg nested if
o Selection – choosing path based on value test
What will the size of a file affect?
The bigger files will usually result in longer times to open, find things etc
What are the choices of storage medium constrained by?
cost, storage capacity, robustness, portability and compatibility between systems
What is the difference between Selection Sorting and Quick Sorting?
In a Selection Sort, the list is sorted into 2 sections. Each value is checked from the start to the end to find the smallest value (or largest if sorting descending). When found, this item is placed at the front of the list and is no longer compared. The rest of the list is then checked for the next smallest value. In a Quick Sort, a mid point is selected and all values less than this move to the left, higher to the right. New midpoints are chosen; smaller selections each time. Much faster
What is the difference between a Linear Search and a Binary Search?
A Linear Search refers to reading a file from start to end looking for required record (N.T. records do not need to be in order). A Binary Search refers to picking a midpoint and if the value being searched is less than the midpoint, the upper half is discarded. A new midpoint is selected and the process is repeated until the record is found.