Unit 3 Algorithms and Programming Flashcards
(46 cards)
____________ a way to represent essential features without including the background details or explanation.
abstraction
what is the purpose of an abstraction?
to hide coding details so they can focus on the current problem, makes more efficient software systems
no abstractions = ___________
binary machine code
make variables meaningful. Variables are values that can be __________
changed
MOD (modulus) %
4MOD2 = 0
6MOD0 = __________ error
0MOD6 = 0
3MOD4 = 3
remainder, divide by zero error
__________ data abstraction that reduces complexity of a program by giving a collection of data a name without specific details
list
=, <, >…
used to ___________
test the relationship between two variables
___________ a data type that has only two possible values, true or false
Boolean value
if the robot moves beyond the grid, _____________
the robot will stay in the current condition and the program will terminate
Rotation is always ___________
relative to where the robot is facing
Steps to SWAP (common algorithm)
1.
2.
3.
create a temporary variable used to store the value of the first item in the list ex: temp = animal[1]
replace ex: animal[1] = animal[3]
replace to temp ex: animal[3] = temp
_____________ an algorithm for finding an element in a list
linear search, sequential search
Sequential search - search starts from the ________________________
beginning of a list and sequentially checks each element until a match is found OR until the entire list is searched without finding it
Sequential search can be used for a _________ or ________ list
sorted, unsorted
Best scenario is sequential search is to ____________
Worse is _______-
find the it in the 1st comparison
find it in the last comparison
_______________ halves the number of elements that need to be searched after every comparison
binary search
in a binary search the list must be ___________. It compares the _____________ to the target value. if it is not equal then ________________ is eliminated.
sorted, middle, half in which the target cannot lie
look in notes for examples.
look
__________ adding strings
concatenation
__________ only look for approximate solutions, tend to take less time
heuristics, heuristic search
programs can be developed for
- _________
- satisfy personal curiosity
- create new knowledge
- _________-
creative expression, solve problems
What is a variable?
An abstraction inside a program that can hold value, which can be a list or other collection containing multiple values.
What is the purpose of meaningful names in programming?
To enhance code readability and maintainability.
If A <- 1, b <- a, a <- 2, what will be the final values of a and b?
a = 2, b = 1.