Open
Conversation
CheezItMan
reviewed
Mar 23, 2021
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work Aimee, you hit the learning goals here. Well done!
Comment on lines
+23
to
26
| Time Complexity: O(1), there are no loops | ||
| Space Complexity: O(1), created one node and moved the head. | ||
| */ | ||
| addFirst(value) { |
Comment on lines
+42
to
46
| Time Complexity*: O(n), n nodes to iterate through | ||
| Space Complexity*: O(1), space required is constant | ||
| * Search calls on the length method (outside the for loop) which has O(n) time complexity and O(1) space complexity | ||
| */ | ||
| search(value) { |
Comment on lines
+63
to
67
| Time Complexity*: O(n), for loop will iterate over n nodes | ||
| Space Complexity*: O(1), space required is constant | ||
| * findMax invokes the length method (outside the for loop) which has O(n) time complexity and O(1) space complexity | ||
| */ | ||
| findMax() { |
| */ | ||
| findMax() { | ||
| throw new Error("This method hasn't been implemented yet!"); | ||
| let max = -Infinity; |
Comment on lines
+87
to
91
| Time Complexity*: O(n), for loop will iterate over n nodes | ||
| Space Complexity*: O(1), space required is constant | ||
| * findMin invokes the length method (outside the for loop) which has O(n) time complexity and O(1) space complexity | ||
| */ | ||
| findMin() { |
Comment on lines
+237
to
240
| Time Complexity: O(n), the length and getAtIndex methods are invoked separately. These each have an O(n) time complexity | ||
| Space Complexity: O(1), space required is constant | ||
| */ | ||
| findNthFromEnd(n) { |
Comment on lines
+250
to
253
| Time Complexity: O(n), there is one while loop and it has an order of n iterations | ||
| Space Complexity: O(n), the Set object will be of length n, we don't know how many nodes are in the linked list | ||
| */ | ||
| hasCycle() { |
Comment on lines
+287
to
290
| Time Complexity: O(n), n nodes to iterate through | ||
| Space Complexity: O(1), space required is constant | ||
| */ | ||
| addLast(value) { |
Comment on lines
+315
to
318
| Time Complexity: O(n), n nodes to iterate through | ||
| Space Complexity: O(1), space required is constant | ||
| */ | ||
| getLast() { |
Comment on lines
+338
to
342
| Time Complexity*: O(n), n nodes to iterate through | ||
| Space Complexity*: O(1), space required is constant | ||
| *This method calls on the findMin, findMax, addFirst, and addLast methods - this won't change the overall space/time complexity. | ||
| */ | ||
| insertAscending(value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.