-
Notifications
You must be signed in to change notification settings - Fork 11
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
C16 - Cedar - Afina #5
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 Afina, good use of additional fields like tail
and length
. You even got a few of the extra methods. Well done!
constructor(head = null, tail = null, length = 0) { | ||
// The # before the variable name indicates | ||
// a private variable. | ||
this.#head = null; | ||
this.#head = head; | ||
this.tail = tail; | ||
this.#length = length; | ||
} |
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.
I like these fields!
Time Complexity: O(1) | ||
Space Complexity: O(1) | ||
*/ | ||
getFirst() { | ||
throw new Error('This method has\'t been implemented yet!') |
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(1) | ||
Space Complexity: O(1) | ||
*/ | ||
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) | ||
Space Complexity: O(1) | ||
*/ | ||
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(1) | ||
Space Complexity: O(1) | ||
*/ | ||
length() { |
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.
👍 Niiice
Time Complexity: O(N) | ||
Space Complexity: O(1) | ||
*/ | ||
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.
👍
Time Complexity: O(N) | ||
Space Complexity: O(1) | ||
*/ | ||
delete(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.
👍 Nicely done. I do want to note that this becomes a bit easier with a doubly linked list (you don't need the previous reference).
Time Complexity: O(N) | ||
Space Complexity: O(N) | ||
*/ | ||
visit() { |
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) | ||
Space Complexity: O(N) | ||
*/ | ||
reverse() { |
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.
👍 However the space complexity is O(1)
Time Complexity: O(N) | ||
Space Complexity: O(1) | ||
*/ | ||
findMiddleValue() { |
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 reuse of the length field
No description provided.