Big O/Searching/sorting/algorithms Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What does O(1) represent

A

Constant time complexity (independent of num of elements)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

O(n)

A

Linear time complexity (directly proportional to num of elements)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

O(n^2)

A

Polynomial time complexity (example, directly proportional to the square of elements inputted)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

O(2^n)

A

Exponential time complexity (doubles with each element added)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

O(log n)

A

Logarithmic time complexity (increase at a smaller rate as the num of elements inputted)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Stacks: size()

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Stacks: isEmpty()

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Stacks: peek()

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Stacks: push(element)

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Stacks: pop

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Queues: size()

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Queues: isEmpty()

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Queues: peek()

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Queues: enqueue(element)

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Queues: dequeue()

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are pre post and in examples of

A

Depth first

17
Q

What is pre

A

Left

18
Q

What is in

A

Bottom

19
Q

What is post

A

Right

20
Q

Only order you need to know

A

Post

21
Q

Pseudocode for bubble sort

A
22
Q

Pseudocode for insertion sort

A
23
Q

How many functions is the merge sort algorithm made from

A

2

24
Q

What are the two functions called in merge sort

A

MergeSort and Merge

25
Q

What does MergeSort do

A

Divides its inputs into two parts and recursively calls MergeSort on each of those two parts until they are of length 1 and Merge is called

26
Q

What does Merge do

A

Puts groups of elements back together in a special way ensuring the final result is sorted

27
Q

Pseudocode for binary search

A
28
Q

Pseudocode for linear search

A
29
Q

Merge sort time complexity

A

O(nlogn)