Unit 3 Algorithms and Programming Flashcards

(46 cards)

1
Q

____________ a way to represent essential features without including the background details or explanation.

A

abstraction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is the purpose of an abstraction?

A

to hide coding details so they can focus on the current problem, makes more efficient software systems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

no abstractions = ___________

A

binary machine code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

make variables meaningful. Variables are values that can be __________

A

changed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

MOD (modulus) %
4MOD2 = 0
6MOD0 = __________ error
0MOD6 = 0
3MOD4 = 3

A

remainder, divide by zero error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

__________ data abstraction that reduces complexity of a program by giving a collection of data a name without specific details

A

list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

=, <, >…
used to ___________

A

test the relationship between two variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

___________ a data type that has only two possible values, true or false

A

Boolean value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

if the robot moves beyond the grid, _____________

A

the robot will stay in the current condition and the program will terminate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Rotation is always ___________

A

relative to where the robot is facing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Steps to SWAP (common algorithm)
1.
2.
3.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

_____________ an algorithm for finding an element in a list

A

linear search, sequential search

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Sequential search - search starts from the ________________________

A

beginning of a list and sequentially checks each element until a match is found OR until the entire list is searched without finding it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Sequential search can be used for a _________ or ________ list

A

sorted, unsorted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Best scenario is sequential search is to ____________
Worse is _______-

A

find the it in the 1st comparison
find it in the last comparison

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

_______________ halves the number of elements that need to be searched after every comparison

A

binary search

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

in a binary search the list must be ___________. It compares the _____________ to the target value. if it is not equal then ________________ is eliminated.

A

sorted, middle, half in which the target cannot lie

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

look in notes for examples.

A

look

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

__________ adding strings

A

concatenation

20
Q

__________ only look for approximate solutions, tend to take less time

A

heuristics, heuristic search

21
Q

programs can be developed for
- _________
- satisfy personal curiosity
- create new knowledge
- _________-

A

creative expression, solve problems

22
Q

What is a variable?

A

An abstraction inside a program that can hold value, which can be a list or other collection containing multiple values.

23
Q

What is the purpose of meaningful names in programming?

A

To enhance code readability and maintainability.

24
Q

If A <- 1, b <- a, a <- 2, what will be the final values of a and b?

A

a = 2, b = 1.

25
What is a procedure in programming?
A set of instructions that can be called to perform a specific task.
26
What are parameters in a procedure?
Variables that are passed to a procedure when it is called.
27
Fill in the blank: An ________ is a set of instructions to accomplish a specific task.
[algorithm]
28
What does sequencing mean in programming?
Executing code statements in the order they are given.
29
What is an example of an expression?
x = 5, y = 3, result = x * y + 10, print(result).
30
How is modulus represented in code?
With a percent sign, e.g., z % y.
31
What does the modulus operator do?
It returns the remainder of a division.
32
List the arithmetic operators.
* / - division returns to a float * // - floor division returns the integer part * % - modulus returns the remainder * ** - exponentiation raises the number to the power.
33
What does the comparison operator '==' signify?
It checks if two values are equal.
34
What is the logical operator 'And' used for?
It returns true if both operands are true.
35
True or False: The assignment operator '=' performs a simple assignment.
True.
36
What is string concatenation?
Joining two or more strings end to end to create a new string.
37
What is a substring?
Part of an existing string.
38
What is the purpose of the command 'Brain.Screen.print("hello")'?
To print 'hello' on the screen.
39
What is a decision problem?
A problem that has a yes/no answer.
40
What is an optimization problem?
A problem with the goal of finding the 'best' solution among many.
41
Fill in the blank: Efficiency is an estimation of the amount of _______ used by an algorithm.
[computational resources]
42
What types of algorithms are said to run in a reasonable amount of time?
Algorithms with polynomial efficiency (constant, linear, square, cube).
43
What is a heuristic?
an approach to a problem that produces a solution that is not guaranteed to be optimal but may be used when other solutions are impractical.
44
Define a decidable problem.
A decision problem for which an algorithm can be written to produce a correct output for all inputs.
45
Define an undecidable problem.
A problem where no algorithm can be constructed that always provides a correct yes or no answer.
46
comparison operators == - ________ != _________ >= greater than or equal to <= less than or equal to
equal to, not equal to