Skip to content

Commit 3efbf01

Browse files
committed
Add shorter version of Algorithms problems document
1 parent 2ecf10d commit 3efbf01

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

algorithms/Algorithms_Questions.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Analysis of Algorithms
2+
**Exercise I**: _Give an analysis of the running time of each snippet of pseudocode with respect to the input size n of each of the following:_
3+
```
4+
a) a = 0
5+
while (a < n * n * n)
6+
a = a + n * n
7+
```
8+
```
9+
b) sum = 0
10+
for (i = 0; i < n; i++)
11+
for (j = i + 1; j < n; j++)
12+
for (k = j + 1; k < n; k++)
13+
for (l = k + 1; l < 10 + k; l++)
14+
sum++
15+
```
16+
```
17+
c) bunnyEars = function(bunnies) {
18+
if (bunnies == 0) return 0
19+
return 2 + bunnyEars(bunnies-1)
20+
}
21+
```
22+
23+
**Exercise II**:
24+
Suppose that you have an _n_-story building and plenty of eggs. Suppose also that an egg gets broken if it is thrown off floor _f_ or higher, and doesn't get broken if dropped off a floor less than floor _f_. Devise a strategy to determine the value of _f_ such that the number of dropped eggs is minimized.

data_structures/ex_2/heap.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
def heapsort(arr):
22
pass
3+
34

45
class Heap:
56
def __init__(self):

0 commit comments

Comments
 (0)