2.1 - 2.5 Flashcards
What is abstraction?
Removing unnecessary detail from a problem
What is an algorithm?
A sequence of steps that can be followed to complete a task.
What is algorithmic thinking?
Solving problems by defining the steps and the sequence needed.
What is decomposition?
Breaking a problem into sub-problems that each represent a specific task.
What are Trace Tables?
Tables that show how values change when an algorithm is carried out.
What are the steps of a trace table
Go through every line
Only add to a column when it’s value changes
Move onto a new row when you move into a new block in the code
Gaps are fine!
How does linear search work?
Compares each item one by one until the target is found.
List doesn’t need to be in order
How does binary search work
Compares middle item to the target
Discards half of the list which the target can’t be in
Finds the next middle item, and repeats until the target is found/ runs out of items
What are the advantages of binary search?
More time efficient than linear search
What are the disadvantages of binary search?
List must be in order beforehand.
What are the steps of bubble sort?
In one pass, go through each pair swapping if needed.
Repeat passes until a pass happens with no swaps
What are the steps of merge sort?
Divide the list continuously by two until each list has 1 item.
Then combine two lists at a time keeping the items in order
What are the steps of insertion sort?
Start with 1 item in the sorted part
move items one by one from the unsorted part to the sorted part.
What do data types determine?
How data is stored and its operations.
What is casting?
Changing the data type of data.
What are the 5 arithmetic operators?
Multiplication: *
To the power of: ^
Division: /
Integer division: DIV
Remainder division: MOD
What are the 4 comparison operators?
Equal to: ==
Not equal to: !=
Greater than: >
Greater than equal to: >=
What are the 3 Boolean operators?
NOT
AND
OR
What are the 5 data types?
Integer: A whole number
Real: A whole number with a fraction
Boolean: True or False
Character: A letter, number or symbol
String: A group of characters
What are the two string handling functions?
Substring: .substring(Starting index, howMany)
Concatenation (Joining two strings) : +
What are Variables?
Named Identifiers that hold a value that can be changed.
What are constants?
Named identifiers that hold a value and cannot be changed.
What data type is a user input WITHOUT casting?
String
How do you generate random values?
Random(startingNUM, endNUM)
What are the 3 fundamental programming constructs?
Sequence
Selection
Iteration
What are the two types of Iteration?
Count-controlled loops
Condition-controlled loops
What are two examples of condition-controlled loops?
WHILE loops
DO UNTIL loops