2.1 Search and sort Flashcards

1
Q

Binary search pros/cons

A

+
Fast for large datasets

Efficient for repeated searches

-
Dataset must be in order

More complex to implement

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

Linear search pros/ cons

A

+
Works on unsorted datasets
Faster (than binary) on very small datasets
Simple to understand and implement

-
Slow for large datasets
Inefficient, starts at the beginning each time

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

Bubble sort

A

A bubble sort is a simple sorting algorithm that starts at the beginning of a dataset and checks values in ‘pairs’ and swaps them if they are not in the correct order

One full run of comparisons from beginning to end is called a ‘pass’, a bubble sort may require multiple ‘passes’ to sort the dataset

The algorithm is finished when there are no more swaps to make

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

Insertion sort

A

The insertion sort sorts one item at a time by placing it in the correct position of an unsorted list. This process repeats until all items are in the correct position

Values in the dataset can move as many places as they need

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