Searching and Sorting Flashcards

1
Q

what is binary search

A

Start at middle position in the list.
If the value at the midpoint is less than the value to be found, the list is divided in half. The lower half of the list is ignored and the search keeps to the upper half of the list.
Otherwise, if the value at the midpoint is greater than the value to be found, the upper half of the list is ignored and the search keeps to the lower half of the list.
The search moves to the midpoint of the remaining items. Steps 2 through 4 continue until a match is made or there are no more items to be found.

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

what is linear search

A

Find out 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 that position matches the value searched for.
If it matches, the value is found. End the search.
If not, increment the counter by 1 and go back to step 3 until there are no more items to search.

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

explain the differences of binary and linear search

A
  • linear is much more simpler than binary
  • linear is less efficient
  • liner is better with small list
  • in a ordered list binary list is better as it is suitable for larger lists
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is bubble sort

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 positions of the two values.
Move to the second value in the list. Again, compare this value with the next and swap if the value is bigger.
Keep going until the there are no more items to compare.
Go back to the start of the list.

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

what is a pass in binary search

A

when you get to the end of the list for the first time

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

what the advantages of bubble sort

A
  • simpler
  • efficient to check if in order
  • doesn’t use much memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what are disadvantages of bubble sort

A
  • inefficient to sort

- not good with large lists

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

what is merge sort

A
  • split the list in half into sub lists
  • keep doing till you get individual items
  • each time ur merging sort it
  • keep merging and sorting till sub list become one
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what are advantages of merge sort

A
  • efficient and quicker than bubble sort for large lists
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what are disadvantages of merge sort

A

slower for small lists
not good for checking
use lots of memory

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

what is insertion sort

A

look at second item at list if smaller than first insert in position keep going till all inserted properly

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

what is insertion sort

A

look at second item at list if smaller than first insert in position keep going till all inserted properly

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

what are advantages of insertion sort

A
  • easy coded
  • good with small list
  • not much memory
  • quick
  • easy to check
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what are disadvantages or insertion sort

A

not good with large lists

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