Sorts, Searches and Algorithms Flashcards

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

Which Is More Efficient - Merge Sort OR Bubble Sort?

A

Merge Sort

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

What are the basic steps of Merge Sort?

A
  1. Divide the unsorted list into ‘n’ sub-lists each containing one element
  2. Repeatedly merge two sub-lists at a time to produce new sorted sub-lists until there is only one sub-list remaining. This is the sorted list.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the basic steps of Bubble Sort?

A
  1. Each item in a list is compared to the next one to it, and if it is greater, they swap places
  2. At the end of one pass through the list, the largest item is at the end of the list
  3. This is repeated until the items are sorted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happens in a Linear Search?

A

Each Item in the list is checked in order.

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

What happens in a Binary Search?

A

An ordered list is divided in 2 with each comparison.

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

How do you carry out a Linear Search?

A
  1. Check the first value
    a) If it is the value you are looking for, then you are finished
    b) If it is not the value you are looking for, move and check the next value. Repeat until you have checked all the elements and not found the value you are looking for.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you carry out a Binary Search?

A
  1. The list must be in order
  2. Examine the middle item
    a) If you report ‘found’, and position
    b) If the item is less than the middle item, binary search the lower half
    c) If the item is more than the middle item, search upper half
    d) If the item is not found, report ‘item not found’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an Algorithm?

A

A set of instructions for solving a problem or completing a task

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