Chapter 4 & 7 Flashcards

Loops and Algorithms (17 cards)

1
Q

Define “loop”.

A

It is a program construct that repeatedly executes the loop’s statements while the loop’s expression is true; when false, execution proceeds past the loop.

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

What is an “iteration”?

A

It is each time through a loop’s statements

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

Define “loop body”.

A

It is a list of sub-statements.

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

Define an “infinite loop”.

A

It is a loop that never stop iterating.

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

Define a “while loop”

A

It is a loop that repeatedly executes the loop boldly while the loop’s expression evaluates to true.

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

Define a “for loop”.

A

It is a loop consisting of a loop variable initialization, a loop expression, and a loop variable update that typically describes iterating for a specific number of times.

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

What is a “nested” loop?

A

It is a loop that appears in the body of another loop.

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

What are nested loops commonly referred to as?

A

inner loop and outer loop

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

Define “do-while loop”.

A

It is a loop that first executes the loop body’s statements, then checks the loop condition.

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

What is an “algorithm”?

A

It is a sequence of steps that solves a problem, generating correct output for any valid input values.

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

Define “algorithm time efficiency”.

A

It is the number of calculations required to solve a problem.

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

What is linear search?

A

It’s an algorithm that checks each item until found or until it reaches the end of the list. This type of algorithm may be slow.

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

What is binary search?

A

It’s an algorithm that checks the range’s middle. If the value is greater, search is made on upper half. If less, on lower half. Search continues until found, or no range remains.

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

What is a computational problem?

A

A problem that can be solved using a computer//It specifies an input, a question about the input that can be answered using a computer, and the desired output.

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

Define “longest common substring”

A

It is the longest common substring that exists in two inputs strings.

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

Define “Dijksta’s shortest path”

A

It is the shortest path from start vertex to each vertex graph.

17
Q

What is “NP-complete”?

A

It is a set of problems for which no know efficient algorithm exits.