Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d2911cf

Browse files
authoredOct 10, 2019
Merge pull request #886 from markgz/patch-1
The code of O(2^n) isn't correct which is O(n)
2 parents 6714e28 + 762de52 commit d2911cf

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎Big-O Notation.markdown

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ Below are some examples for each category of performance:
124124
func solveHanoi(n: Int, from: String, to: String, spare: String) {
125125
guard n >= 1 else { return }
126126
if n > 1 {
127-
solveHanoi(n: n - 1, from: from, to: spare, spare: to)
128-
} else {
129-
solveHanoi(n: n - 1, from: spare, to: to, spare: from)
127+
solveHanoi(n: n - 1, from: from, to: spare, spare: to)
128+
solveHanoi(n: n - 1, from: spare, to: to, spare: from)
130129
}
131130
}
132131
```

0 commit comments

Comments
 (0)
Please sign in to comment.