DoA Flashcards

1
Q

Time complexity of merge sort

A

O(nlogn)

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

Time complexity of Binary search

A

O(logn)

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

Time complexity of insertion sort

A

O(n^2)

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

Give a recurrence T (n) = · · · for the worst-case running time of Binary search

A

T(n) = T(n/2) + ϴ(1)
T(1) = ϴ(1)

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

Give a recurrence T (n) = · · · for the worst-case running time of Merge sort

A

T(n) = 2T(n/2) + ϴ(n)
T(1) = ϴ(1)

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

Give a recurrence T (n) = · · · for the worst-case running time of Insertion sort

A

T(n) = T(n-1) + ϴ(n)
T(1) = ϴ(1)

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

Radix

Instead of using countingsort to sort digitals in the radixsort, one can use any in-place sorting algorithm
and the radixsort will still sort correctly. TRUE or FALSE? Why?

A

False

Radix sort relies on stable sorting algorithms for each digit place. While it’s true that you can use any stable sorting algorithm, not every in-place sorting algorithm is stable.

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

Explain Binary search tree (BST)

A

A BST is a hierarchical data structure consisting of nodes, where each node has a key, and at the most 2 children.

The keys in the left subtree of a node are less than its key, and the keys in the right subtree are greater than its key.

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

Explain AVL-tree

A

An AVL tree is a self-balancing binary search tree that maintains a height-balanced property, ensuring that the height difference between the left and right subtrees of any node (called the balance factor) is at most 1.

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

Explain min-heap
And shortly how to make insertions in it.

A

A tree where every node is smaller than its children.

The tree is always filled up from left to right.

Insertions happens into the next empty space and if the inserted node is smaller than its parent: swap

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

Explain max-heap
And shortly how to make insertions in it.

A

A tree where every node is greater than its children.

The tree is always filled up from left to right.

Insertions happens into the next empty space and if the inserted node is greater than its parent: swap

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

True or false?
2n + n^3 = O(2n).

A

False
Instead it is:
2n + n^3 = O(n^3).

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

Time complexity of counting sort

A

O(n+k)

Where ‘n’ Represents The Number Of Elements And ‘k’ Represents The Range Of The Inputs.

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

Time complexity of radix sort

A

O(nd)

where ‘n’ is the size of the array and ‘d’ is the number of digits in the largest number

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

Give a recurrence T (n) = · · · for the worst-case running time of selection sort

A

T(n) = T(n-1) + O(n)
T(1) = O(1)

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

Time complexity of selection sort

A

O(n^2)

16
Q

Time complexity of In-Order-Walk

A

ϴ(n)

17
Q

Give a recurrence T (n) = · · · for the worst-case running time of in-order-walk

A

T(1) = ϴ(1)
T(n) = T(k) + ϴ(1) + T(n-k-1)

18
Q

Time complexity of depth first search

A

O(V + E)

Where V is the number of nodes and E is the number of edges.

19
Q

Time complexity of breadth first search

A

O(V + E)

Where V is the number of nodes and E is the number of edges.

20
Q

Give a recurrence T (n) = · · · for the worst-case running time of quick sort

A

T(1) = O(1)
T(n) = T(i) + T(n — i — 1) + cn

21
Q

Time complexity of quick sort

A

O(n^2)

22
Q

Time complexity of bubble sort

A

O(n^2)