返回卡包市场

2.3 Algorithms

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

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

卡片预览 (24 张)

#1
正面 (问题)

What are two things needed to be kept into mind when developing an algorithm?

背面 (解答)

-time complexity -space complexity

#2
正面 (问题)

Explain time complexities? What are they known as?

背面 (解答)

-how much time an algorithm requires to solve a particular problem -known as big-o notation, shows the effectiveness of the algorithm -shows the amount of time taken relative to the number of data elements given as an input

#3
正面 (问题)

What is 0(1)?

背面 (解答)

-constant time complexity -the amount of time taken to complete an algorithm is independent from the number of elements inputted

#4
正面 (问题)

What is 0(n)?

背面 (解答)

-linear time complexity -the amount of time taken to complete an algorithm is directly proportional to the number of elements inputted

#5
正面 (问题)

What is 0(n^2)?

背面 (解答)

-polynomial time complexity -the amount of time taken to complete an algorithm is directly proportional to the square of the elements inputted

#6
正面 (问题)

What is 0(n^n)?

背面 (解答)

-polynomial time complexity -the amount of time taken to complete an algorithm is directly proportional to the elements inputted to the power of n

#7
正面 (问题)

What is 0(2^n)?

背面 (解答)

-exponential time complexity -the amount of time taken to complete an algorithm will double with every additional item

#8
正面 (问题)

What is 0(log n)?

背面 (解答)

-logarithmic time complexity -the time taken to complete an algorithm will increase at a smaller rate as the number of elements inputted

#9
正面 (问题)

What is 0(n log n)?

背面 (解答)

-logarithmic time complexity -the time taken to complete an algorithm grows at a rate that is proportional to the number of elements inputted multiplied by the logarithm of n

#10
正面 (问题)

What time complexity should be used for algorithms using a ‘divide and conquer approach’?

背面 (解答)

log n n log n

#11
正面 (问题)

What do we mean by space complexities? How can this be measured?

背面 (解答)

-the amount of storage the algorithm takes -measured using big o-notation

#12
正面 (问题)

What are the best/average/worst cases for time complexities for bubble sort? Why?

背面 (解答)

best- 0(n) as this is when array is already sorted average- 0(n^2) as this is when elements are randomly ordered worst- 0(n^2) as this is when the elements are sorted in reverse order

#13
正面 (问题)

What is the space complexity for bubble sort? Why?

背面 (解答)

0(1) as it requires additional space for number of variables

#14
正面 (问题)

What are the best/average/worst cases for time complexities for insertion sort? Why?

背面 (解答)

best- 0(n) as this is when array is nearly sorted average- 0(n^2) as this is when array is randomly sorted worst- 0(n^2) as this is when array is sorted in reverse order

#15
正面 (问题)

What is the space complexity for insertion sort? Why?

背面 (解答)

0(1) as minimal extra space needed

#16
正面 (问题)

What are the best/average/worst cases for time complexities for merge sort? Why?

背面 (解答)

all- 0(n log n) as the algorithm is being decomposed –> log n, due to the number of separations becomes n log n

#17
正面 (问题)

What is the space complexity for merge sort? Why?

背面 (解答)

0(n) as merge sort requires additional space for merging

#18
正面 (问题)

What are the best/average/worst cases for time complexities for quick sort? Why?

背面 (解答)

best- 0(n log n) as this is when the pivot consistently divides array in half and is balanced average- 0(n log n) as this is when the pivot consistently divides array in half and is balanced worst- 0(n^2) as this is when the pivot consistently results in unbalanced partitions

#19
正面 (问题)

What is the space complexity for quick sort? Why?

背面 (解答)

0(log n) as there is varying space depending on pivot and data

#20
正面 (问题)

What are the best/average/worst cases for time complexities for linear search? Why?

背面 (解答)

best- 0(1) as this is when the target is at beginning of the list average- 0(n) as this is when the target can be randomly anywhere in the list, multiple iterations worst- 0(n) as this is when the target element is at the end of the list or not present

#21
正面 (问题)

What is the time complexity for linear search? Why?

背面 (解答)

0(1) requires minimal space as nothing will be added or lost

#22
正面 (问题)

What are the best/average/worst cases for time complexities for binary search? Why?

背面 (解答)

best- 0(1) as this is when the target is at the middle of the sorted list average- 0(n log n) as each comparison reduces the search space by 1/2 worst- 0(n log n) as the target element could be at the beginning or end of the sorted list

#23
正面 (问题)

What is the space complexity for binary search? Why?

背面 (解答)

0(1) no extra space needed

#24
正面 (问题)

What are the best/average/worst cases for time complexities for hash table search? Why?

背面 (解答)

best- 0(1) when there are no collisions and the hash function distributes keys evenly average- 0(1) no collisions and a good hash function worst- 0(n) as this is when there are many collisions which leads to a linear search within the has table search