返回卡包市场

2.3.1 Algorithms

暂无描述。系统推荐的高质量记忆内容,适合每天坚持背诵学习。

卡片总数: 24内容版本: v4公开卡包更新时间: 8/1/2026

卡片预览 (24 张)

#1
正面 (问题)

Algorithms

背面 (解答)

A series of instructions that are used to solve a problem

#2
正面 (问题)

Properties of a good algorithm

背面 (解答)

• Produce the correct output for valid inputs • Should account for invalid inputs • Must always terminate at some point • Executes efficiently in as few steps as possible • Should be designed such that other people can easily understand and modify it

#3
正面 (问题)

Big O notation

背面 (解答)

The time complexity of an algorithm, how changing the size of the units affects the runtime Remove coefficients and write the highest power of n only

#4
正面 (问题)

Big O process

背面 (解答)

• Calculate how many times each line runs • Simplify • Remove coefficients and put O(n^highest power)

#5
正面 (问题)

Sequential big O

背面 (解答)

O(1)

#6
正面 (问题)

Single loop big O

背面 (解答)

O(n)

#7
正面 (问题)

Loops inside each other big O

背面 (解答)

O(n^2)

#8
正面 (问题)

Recursive functions big O

背面 (解答)

O(numberofrecursions^n)

#9
正面 (问题)

Divide and conquer big O

背面 (解答)

O(log n)

#10
正面 (问题)

Permutations

背面 (解答)

The permutation of n items is the number of ways n items should be arranged

#11
正面 (问题)

Permutation where values can be repeated big O

背面 (解答)

O(a^n) Where a is the amount of possible values for each

#12
正面 (问题)

Permutation where values can’t be repeated big O

背面 (解答)

O(n!)

#13
正面 (问题)

Linear search

背面 (解答)

Iterates through each item in turn until you find the item or have checked every item

#14
正面 (问题)

Linear search pseudocode

背面 (解答)

Iterating through an array until the value is found, at which point the index is returned or if the loop is completed the value has not been found

#15
正面 (问题)

Linear search big O

背面 (解答)

O(n)

#16
正面 (问题)

Binary search big O

背面 (解答)

O(log n)

#17
正面 (问题)

Binary search process

背面 (解答)

Order the items and examine the middle item of the list. if that is the item it is found, else repeat using the items bigger or smaller than the value depending if it is bigger or smaller than the middle value

#18
正面 (问题)

Binary search pseudocode

背面 (解答)

The lowerbound starts at 0 and the upperbound 1 less than the list length The midpoint is (LB + UB) DIV 2 If the midpoint is the value return the index If the midpoint is less than the value LB is midpoint + 1 If the midpoint is more than the value UB is midpoint - 1 If lowerbound > upperbound it is not found

#19
正面 (问题)

Bubble sort big O

背面 (解答)

O(n^2)

#20
正面 (问题)

Insertion sort big O

背面 (解答)

O(n^2)

#21
正面 (问题)

Bubble sort pseudocode

背面 (解答)

for (i = 0 to length - 2) for (j = 0 to length - i - 1) if list[i] > list [i + 1] temp = list[i] list[i] = list[i + 1] list [i + 1] = temp end if next j next i end procedure

#22
正面 (问题)

Insertion sort pseudocode

背面 (解答)

for (j = 1 to length - 1) nextItem = list[j] i = j - 1 while i>=0 and list[i] > nextItem list [i+1] = list[i] i-- end while list{i+1] = nextItem next j end procedure

#23
正面 (问题)

Merge Sort Process

背面 (解答)

• Divide the unsorted list into n sublists, each containing one element, halving the length each time • Order consecutive pairs of sublists and combine • Repeat to have 4 items in each ordered list • Repeat until there is one ordered list

#24
正面 (问题)

Merge Sort Big O

背面 (解答)

n log n