4.2 Thinking in Program Design Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are the four standard algorithms?

A

Sequential Search
Binary Search
Bubble Sort
Selection Sort

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

What is Sequential Search?

A

Start at the start of an unsorted list comparing items until you find what you want.

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

What is a Binary Search?

A

Start at centre of sorted array, comparing with values and going lower or higher.

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

What is Bubble Sort?

A

Comparing adjacent tiles and switching them if they are in the wrong order.

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

What is Selection Sort?

A

Divides list into two parts, sorted and un sorted. Finds the smallest and puts it at the beginning.

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

Evaluate Binary Search

A

Faster O(log n) but can only be a sorted list.

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

Evaluate Sequential Search

A

Slower O(n)
but can be performed on an unsorted list

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

Evaluate Bubble Sort

A

Can quit early if few swaps are needed but on bigger code will need lots of swaps.

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

Evaluation Selection Sort

A

Must always perform n swaps, it can’t finish early.
But is better on longer lists

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

What is this?

A

Terminator - start or end value.

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

What is this?

A

Input/Output

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

What is this?

A

Process - something is happening.

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

What is this?

A

Decision.

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

What is used to measure the efficiency of an algorithm?

A

Run Time,

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

What can affect the run time of an algorithm?

A

Computer/Hardware
Representation of ADTs
Efficiency of Compiler
Competence of Programmer
Complexity of Algorithm
Size of Input

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

What is complexity?

A

A measure of the amount of time/space required by an algorithm for a given size.

17
Q

How is time represented?

A

t(n)

18
Q

How do we measure complexity?

A

Predicting the number of times the principle activity is performed for the input.
In best case, average case, and worst case.

19
Q

How long does a single loop take to run?

A

Repeats n times
Takes n time to run.

20
Q

How long does a nested loop take to run?

A

Repeats n times
Takes n*n to run.

21
Q

What is more efficient for or while?

A

While because it won’t always run if the condition isn’t met.

22
Q

What are the advantages of linked lists?

A

Can expand and easily add and take things away.

23
Q

What are the advantages of an array?

A

Easier to find things.