sorting algorithms

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/10

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

11 Terms

1
New cards

What is the algorithm of a bubble sort?

1) Look at the first two items in the list.

2) If they’re in the right order, don’t do anything. If they aren’t, swap them.

3) Move onto the next pair of items, as repeat step 2.

4) Repeat step 3 until you get to the end of the list - called one pass. The last item will be in the correct place, so don’t include it in the next pass.

5) Repeat steps 1-4 until there are no swaps in a pass.

2
New cards

What type of algorithm is a bubble sort?

Simple

3
New cards

Is a bubble sort efficient?

Not to sort a list, but to check if a list is in order.

4
New cards

Does a bubble sort use a lot of memory?

No

5
New cards

What is the algorithm for a merge sort?

1) Split the list in half, the second sub-list should start at the middle item.

2) Keep repeating step 1 on each sub-list until all lists only contain one item.

3) Merge pairs of sub-lists and each time you merge sub-lists, sort the items into the right order.

4) Repeat step 3 until you’ve merged all the sub-lists together.

6
New cards

What is a pro of a merge sort?

More efficient

7
New cards

How quickly does a merge sort sort small lists?

Slower compared to other algorithms.

8
New cards

How much memory does a merge sort use compared to the other sorting algorithms?

More memory.

9
New cards

What is the algorithm for a insertion sort?

1) Look at the second item in a list.

2) Compare it to all items before it and insert the number into the right place.

3) Repeat step 2 until the last number in the list has been sorted into the correct place.

10
New cards

What size list does an insertion sort cope best with?

Small.

11
New cards

How quick is an insertion sort?

Very quick.