-
Notifications
You must be signed in to change notification settings - Fork 48
Fire 🔥 - Aimee 👾 #29
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
base: master
Are you sure you want to change the base?
Fire 🔥 - Aimee 👾 #29
Conversation
CheezItMan
left a comment
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.
Well done, you hit the learning goals here. Nice work.
| @@ -0,0 +1,6 @@ | |||
| # Default ignored files | |||
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.
Add .idea to your .gitignore file
| # Time complexity - O(1) - A node is added to the beginning of the list. Since this is not an array, we are not replacing an element and shifting the rest of the data over. | ||
| # Space complexity - O(1) | ||
| def add_first(data) |
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) - We look up the first node (where the head is) | ||
| # Space complexity - O(1) | ||
| def get_first |
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) we count n nodes in the list | ||
| # Space complexity - O(1) | ||
| def 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.
👍
| # Time complexity - O(n) - need to traverse list of length n to find the last node and add one after that | ||
| # Space complexity - O(1) | ||
| def add_last(data) |
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) - we need to traverse the list of length n to find the last node | ||
| # Space complexity - O(1) | ||
| def get_last |
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.
👍
| index.times do | ||
| current = current.next | ||
| end |
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.
what if index > length?
Linked List Comprehension Questions