Searching and Sorting I Flashcards

(7 cards)

1
Q

What is a Sequential (Linear) Search ?

A

Scans each element one by one,
Simple but time inefficient (O(n)),
Useful for unsorted arrays.

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

What is a Binary Search ?

A

Repeatedly divides the search range in half,
Efficient on sorted arrays (O(log n))
Can be implemented iteratively or recursively.

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

What is an Interpolation Search ?

A

Uses the estimated position of the search key
Optimised for uniformly distributed data (average case = O (log log n), worst case = O(n))
More precise than binary when data is evenly spaced (e.g. 1,2,3,4)

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

What is a Bubble Sort ?

A

Repeatedly swaps adjacent elements if they’re out of order,
Very inefficient - (On^2)

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

What is an Insertion Sort ?

A

Builds sorted arrays one element at a time,
Efficient for small or nearly sorted arrays,
Best = O(n), worst = O(n^2)

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

What is a Merge Sort ?

A

Recursively splits the array then merges sorted halves,
Very efficient but needs additional space,
Time complexity = O(n log n)
Space Complexity = O(n)

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

What is a QuickSort ?

A

Selects a pivot, partitions the array and recursively sorts subarrays,
Average = O(n log n)

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