Searches & Sorts:

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

1/15

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.

16 Terms

1
New cards

What are search algorithms commonly used for?

Search algorithms use a distinct formula to search through arrays.

2
New cards

What is a binary search?

A 'divide and conquer' mechanism that only works on sorted data.

3
New cards

When will a binary search return -1?

When the searched element is not present in the array.

4
New cards

What is the worst-case scenario for a binary search?

The key is not in the array or is at an endpoint.

5
New cards

How is the number of comparisons calculated in the worst case for binary search?

Round n up to the next power of 2 and take the exponent.

6
New cards

What does a sequential search do?

It starts at the first element and compares the key to each element in turn.

7
New cards

What is the best case for a sequential search?

The key is found in the first slot of the array.

8
New cards

What is a selection sort?

A search-and-swap algorithm that finds and exchanges the smallest element with the first element.

9
New cards

What is the efficiency of selection sort for large n?

Inefficient for large n.

10
New cards
11
New cards

What do insertion sorts compare?

They compare the first two elements and insert the second value into the correct position.

12
New cards

What is the worst-case scenario for an insertion sort?

When the array is initially sorted in reverse order.

13
New cards

What is merge sort?

A divide and conquer algorithm that employs recursion.

14
New cards

What is the disadvantage of merge sort?

It requires a temporary array as large as the original array.

15
New cards

How does merge sort handle the initial ordering of elements?

It is not affected; the best, worst, and average cases have similar run times.

16
New cards