Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Short-Answer/Algorithms_Answers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

## Exercise I

a)
a) O(1)


b)
b) O(n)


c)
c) O(n)

## Exercise II

Expand Down
2 changes: 1 addition & 1 deletion Short-Answer/Algorithms_Questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Give an analysis of the running time of each snippet of
pseudocode with respect to the input size n of each of the following:

```python
a) a = 0
a) a = 0
while (a < n * n * n):
a = a + n * n
```
Expand Down
13 changes: 9 additions & 4 deletions recursive_count_th/count_th.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
Your function must utilize recursion. It cannot contain any loops.
'''
def count_th(word):

# TBC

pass

if word == "":
return 0

if word[:2] == "th":
return 1 + count_th(word[1:])
else:
return 0 + count_th(word[1:])

18 changes: 16 additions & 2 deletions robot_sort/robot_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,22 @@ def sort(self):
"""
Sort the robot's list.
"""
# Fill this out
pass
if self.can_move_right() is False:
return self._list
self.swap_item()
while self.can_move_right():
self.move_right()
if self.compare_item() == 1:
self.swap_item()
while self.can_move_left():
self.move_left()
if self.compare_item() == None:
self.swap_item()
break
self.move_right()
self.sort()




if __name__ == "__main__":
Expand Down