fundamentals of algorithms Flashcards

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

define the term algorithm

A

a sequence of steps that can be followed to complete a task

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

define the term decomposition

A

breaking a problem into a number of sub-problems, so that each sub- problem accomplishes an identifiable task ( which might itself be further subdivided )

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

define the term abstraction

A

the process of removing unnecessary detail from a problem

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

what shape is a decision in a flowchart?

A

diamond

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

what shape is a process in a flowchart?

A

rectangle

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

what shape is a input/output in a flowchart?

A

parallelogram

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

what shape is a subroutine in a flowchart?

A

rectangle with a line at each side

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

explain linear search

A

a linear search checks each item of the list in turn to see if it’s the correct one and stops when it either finds the item or has checked every item

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

explain binary search

A

a binary search finds the middle item in the list (if this is the right item then it stops)

if not it compares the requested item with the middle item and gets rid of the half which the item isn’t in

this will repeat until the number is found
( in an odd list ( e.g 7 ) round down so ( item 3 would be half )

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

what are the advantages of linear search over binary search?

A

works in an unordered list

for small lists the run time of both algorithms will be similar

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

what are the advantages of binary search over linear search?

A

is much quicker at searching big lists
run time is similar for small lists
( but doesn’t work in an unordered list )

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

explain the merge sort

A

split the list in half ( into sublists )
repeat until each sublist has one item
merge the sublists and sort the order each time
repeat until all the sublists are merged

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

explain the bubble sort

A

the bubble sort looks at the first two items and swaps them if they are in the wrong order
this continues until the end of the list ( called a pass ( now the final number is in the correct place )
repeat until a pass has no swaps

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

what are the advantages for a bubble sort over a merge sort?

A

much quicker for longer lists

very consistent run time no matter how unordered the list is

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

what are the advantages of a merge sort over a bubble sort?

A

little memory is used
simple and can be easily implemented
efficient - for a list of n you only need to do n-1 comparisons to check if the list is ordered

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