-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
👾 Aimee - 🔥 Fire #1
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work Aimee, you hit the learning goals here. Well done!
Time Complexity: O(1), there are no loops | ||
Space Complexity: O(1), created one node and moved the head. | ||
*/ | ||
addFirst(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
*/ | ||
findMax() { | ||
throw new Error("This method hasn't been implemented yet!"); | ||
let max = -Infinity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of -Infinity
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Another good use of getAtIndex
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Time Complexity: O(n), n nodes to iterate through | ||
Space Complexity: O(1), space required is constant | ||
*/ | ||
addLast(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Time Complexity: O(n), n nodes to iterate through | ||
Space Complexity: O(1), space required is constant | ||
*/ | ||
getLast() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Good use of existing methods
No description provided.