comp sci review

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

1/20

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.

21 Terms

1
New cards

What is a list in Python?

An abstraction used to store a collection of items (like numbers, strings, or other objects).

2
New cards

What does indexing in Python start at?

Indexing starts at 0.

3
New cards

What does range(0, 5) return?

[0, 1, 2, 3, 4] — goes up to but does not include the end value.

4
New cards

What is a sequential (linear) search?

An algorithm that checks each item in a list one by one to find a target value.

5
New cards

What is the best-case time complexity of sequential search?

O(1) — target is the first element.

6
New cards

What is the worst-case time complexity of sequential search?

O(n) — target is at the end or not in the list.

7
New cards

What does the "find smallest" algorithm do?

Finds the smallest (or closest) value in a list compared to a target.

8
New cards

What is the time complexity of the find smallest algorithm?

O(n) — both best and worst case.

9
New cards

What is Selection Sort?

A sorting algorithm that repeatedly finds the largest/smallest in the unsorted part and swaps it to the correct position.

10
New cards

What is the time complexity of Selection Sort (best and worst case)?

O(n²) — same for both best and worst cases.

11
New cards

What is the formula for number of comparisons in Selection Sort?

n(n-1)/2 or ½n² - ½n

12
New cards

What is Insertion Sort?

A sorting algorithm that builds the sorted list one item at a time by inserting unsorted items into the correct position.

13
New cards

What is the best-case time complexity of Insertion Sort?

O(n) — when the list is already sorted.

14
New cards

What is the worst-case time complexity of Insertion Sort?

O(n²) — when the list is in reverse order.

15
New cards

When is Insertion Sort faster than Selection Sort?

When the list is already sorted or nearly sorted.

16
New cards

What does Big O notation represent?

The efficiency of an algorithm in terms of time or space as the input size grows.

17
New cards

In Big O analysis, what do the axes on the graph represent?

X-axis = number of items (n), Y-axis = number of comparisons.

18
New cards

Why would we use Binary Search?

Because it efficiently finds an item in a sorted list by repeatedly dividing the search interval in half, reducing the time complexity to O(log n).

19
New cards

What does Binary Search do?

Repeatedly checks the middle of the current section of the list.

20
New cards

What is the best case for Binary Search?

Best Case: O(1) (when the middle is the target)

21
New cards

What is the worst case for binary search?

O(log₂n)