Searching and Sorting Algorithms in Python

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play

1/14

encourage image

There are no tags or description

Looks like no tags are added yet.

15 Terms

1
New cards

Search Algorithm

An algorithm that looks for data stored within a data set, such as a string or a list.

2
New cards

Big-O Notation

An algebraic notation written as O(algebraic expression)O(\text{algebraic expression}) used by computer scientists to analyze the cost or worst-case time complexity of an algorithm in terms of the data set size nn.

3
New cards

Linear Search

A search algorithm that iterates through every element in a data set and compares it to the target value; it should be used when data is not sorted.

4
New cards

Linear Search Time Complexity

An algorithm complexity with a worst-case scenario of O(n)O(n), a best-case scenario of O(1)O(1), and an average performance of n/2n/2 steps.

5
New cards

Binary Search

A fast searching algorithm usable only on sorted lists that continuously compares the target to the middle element and eliminates the half of the list where the target cannot be.

6
New cards

Binary Search Time Complexity

A time complexity of O(log⁡n)O(\log n), requiring at most 2020 steps to find an item in a list of 1,000,0001{,}000{,}000 numbers compared to up to 1,000,0001{,}000{,}000 steps for a linear search.

7
New cards

bisect_left

A method imported from Python's bisect module that performs a binary search to find the index of an element in a sorted list, or returns the index where it would be placed if it is absent.

8
New cards

Sorting Algorithm

An algorithm used to arrange the data in an iterable in a meaningful way, such as numerical, alphabetical, or by length.

9
New cards

Bubble Sort

A sorting algorithm that iterates through a list, compares adjacent numbers, and swaps them if they are out of order so that the largest values bubble up to the end of the list.

10
New cards

Bubble Sort Inner Loop

The loop within a bubble sort algorithm where all adjacent comparisons and swapping operations take place.

11
New cards

Bubble Sort Outer Loop

The loop within a bubble sort algorithm that keeps the algorithm running for as many complete passes as needed to put the list in order.

12
New cards

Bubble Sort Complexity

A time complexity of O(n2)O(n^2) caused by two nested for loops, making it simple to implement and acceptable for small data sets, but inefficient for large data sets.

13
New cards

Insertion Sort

A sorting algorithm that splits a list into a sorted left portion and an unsorted right portion, placing each current element from the right into its proper position on the left.

14
New cards

Insertion Sort Efficiency

A sorting algorithm with a general complexity of O(n2)O(n^2) that is favored over bubble sort because it achieves O(n)O(n) efficiency when the list is almost sorted.

15
New cards

sorted() Function

Python's built-in sorting function that utilizes a hybrid algorithm combining two or more sorting methods, supporting arguments such as reverse=True and