Unit 3 - Algorithms and data structures Flashcards

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

What is an algorithm?

A

A set of rules of instructions for completing a task.

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

Why don’t algorithms give perfect results?

A

The perfect result is not efficient and takes a lot more time than ‘good enough’.

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

What type of problems are algorithms very useful for?

A

Recurrent problems where you can perform the same task over and over again.

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

What is a flowchart?

A

It is used to translate human instruction into computer instruction.

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

What is a terminator in a flowchart?

A

It is used at the beginning and end, representing the external node of a flow. You use an oval.

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

What is a Process in a flowchart?

A

A rectangle representing a process such as data calculation or filtering.

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

What is a decision in a flowchart?

A

Diamond shaped indicating a choice and multiple possible paths.

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

What is input/output in a flowchart?

A

A parallelogram, data is sent into or out of the process.

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

What does an arrow do in a flowchart?

A

It represents the direction of the flow.

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

What is a stack?

A

It is a data structure with the philosophy Last in, First Out (LIFO)

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

What operations does a stack have?

A

Push: Add a new item to the top. Used to populate the stack with data.
Pop: Removes the top piece of data from the stack. Used to read the value and then remove it.

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

What are characteristics of a stack?

A

Takes up a low amount of space, but cannot be searched randomly. Random Access Memory is not possible with Stack.

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

What is a linked list?

A

It is a sequential storage structure where each element is linked to the next. The last element has no pointer and so points to null.

You can insert elements in the middle of the sequence, but it is still allowing quick access. More flexibility than a stack.

There is no restriction on number of elements. It is unbounded.

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

What is an array?

A

A sequential data structure. Takes more memory but allows for random access for reading and writing. They are usually bounded meaning they have a predetermined size.

Each element has an index that identifies it, starting at 0.

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

What is a multi-dimensional array?

A

Imagine a checkerboard, you give coordinates to the array. You can have more than two dimensions but this makes it a lot more complex.

Checkerboard[3,5] “Red

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

What is binary search?

A

Slicing the data size in two by jumping in the middle and then based on the information there, move left or right.

17
Q

What is linear search?

A

You start at the beginning and look at each element until you find what you want.

18
Q

What is jump search?

A

You jump forward in pre-determined steps. For a 2500-page book, jump 50 pages each time until you’re past your objective. Then, go back one jump and continue with linear search.

19
Q

What is bubble sort?

A

You compare two values at a time and sort those, putting the largest on top. After doing this for all elements, you start at the top again and repeat. The large values will ‘bubble’ to the top.

Amount of passes is n-1 ( one less than the total amount of elements).

20
Q

What is a modified bubble sort?

A

An enhanced version of bubble sort, you stop when a whole pass did not produce any swaps. That way you don’t have to do the full n-1 passes.

21
Q

What is binary insertion sort?

A

Take a list of elements (input list) and put them in a new list one by one (output list). If it has 5 values, divide it in two. Look at the middle value and keep dividing in two until you find the place where you need to insert the next value. It is slightly faster than bubble sort.

22
Q

What is quicksort?

A

An efficient sorting algorithm, but also more complex. Divide your data in two piles, one with higher values and one with lower. Divide them again until you have 4 piles. Sort each pile in the normal fashion. After that you can place the four piles on top of each other.

23
Q

What is an exhaustive search?

A

Calculating every single possibility of a route / problem. Not an optimal algorithm.

24
Q

What is algorithm termination?

A

A place where the algorithm stops calculating. it needs to know when to do this beforehand.

25
Q

What is algorithm complexity?

A

How many operations an algorithm requires to complete a task. The more operations, the more complex and thus more time and energy.

26
Q

What does the big O stand of?

A

The mathematical complexity of an algorithm.

27
Q

What is a constant algorithm complexity?

A

The exact number of steps is needed, no matter the data size.

O(n)

28
Q

What is a linear algorithm complexity?

A

It takes (close to) as many steps as the size of the data set.

O(n)

29
Q

What is a N*Log algorithm? Name an example.

A

Algorithm where O is n times the logarithm of n. Close to as efficient as linear for a lot of data sets.

Example: quick sort.

30
Q

What is a quadratic algorithm? Name an example.

A

The number of steps is the square of the data set size.

O(n2)

Example: Bubble sort and binary insertion.

31
Q

What is a cubic algorithm?

A

The number of steps are the data size cubed.

O(n^3)

32
Q

What is an exponential algorithm?

A

A complexity with an exponent above 3 raised to the power of n.

O(n^k)