Common Algorithms Finished Flashcards

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

what are the searching algorithms (2)

A

linear

binary

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

what are the sorting algorithms (3)

A

bubble
merge
insertion

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

describe the steps of a linear search (6)

A

find the length of the data set
set counter to 0
examine value held in the list at the counter position
check to see if the value at the counter position matches the value searched for
if it matches, end the search
if not, increase the counter by 1 and search again

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

1 adv and 1 disadv of linear search

A

+ works on any data set (doesn’t have to be sorted)

- can be slow on larger data sets

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

describe the steps of a binary search (5)

A

start by setting the counter to the middle position in the list
if the value is a match, stop
if the value at the midpoint is less than the desired value, the list is divided in half and the lower half of the list is ignored
otherwise, the upper half of the list is ignored
the search continues for the remaining items

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

what happens in a binary search of the mid point value is a decimal

A

round up

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

1 adv and 1 disadv of binary search

A

+ much more efficient than linear on longer data sets

- the list needs to be sorted

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

describe the steps of bubble sort (5)

A

start at the beginning of the list
compare the first value in the list with the next one up. if the first value is bigger, swap the position of the two values
move to the second value in the list. compare them again and swap if the value is bigger
keep going until there are no more items to compare
go back to the start of the list and go again

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

describe the steps of a merge sort (2)

A

the list is repeatedly divided into two until all the elements are in groups of two
pairs of elements are compared, placed into order and combined until the list is ordered

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

describe the steps of an insertion sort

A

values in a list are compared in turn, starting with the second value
if this value is greater than the value to the left of it, no changes are made
otherwise, that value is repeatedly moved left until this is true

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