Standard Methods of a Solution Flashcards
(10 cards)
What is a searching algorithm?
Searching algorithms are precise step-by-step instructions that a computer can follow to efficiently locate specific data in massive datasets.
What is a sorting algorithm?
Sorting algorithms are precise step-by-step instructions that a computer can follow to efficiently sort data in massive datasets.
What is a linear search?
- Checks each item in a dataset one by one
- Can work on unsorted data
How does a linear search work?
1️⃣ Check the first value
2️⃣ If it’s the target value → STOP
3️⃣ Else, move to the next value
4️⃣ Repeat until the value is found or all values are checked
What is a bubble - sort?
- A simple sorting algorithm
- Compares pairs of values and swaps them if out of order
- One full run through the list = a pass
- Repeats passes until no swaps are needed
How does a bubble - sort work?
1️⃣ Compare the first two values
2️⃣ If in wrong order → swap them
3️⃣ Move to the next pair
4️⃣ Repeat until end of list (1 pass)
5️⃣ If swaps made → start another pass
6️⃣ If no swaps → STOP, list is sorted
Totalling Example
Total ← 0
FOR Count ← 1 TO ReceiptLength
INPUT ItemValue
Total ← Total + ItemValue
NEXT Count
OUTPUT Total
What is totalling?
Totalling is keeping a running total of values entered into the algorithm
What is counting?
- Counting is when a count is incremented or decremented by a fixed value, usually 1, each time it iterates
- Counting keeps track of the number of times an action has been performed
Counting Example
Count ← 0
DO
OUTPUT “Pass number”, Count
Count ← Count + 1
UNTIL Count >= 50