-
Notifications
You must be signed in to change notification settings - Fork 7
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 Walton #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.
Let me know what questions you have.
🔴
@@ -0,0 +1,55 @@ | |||
function balanced(string) { |
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.
💫🌸 Impressive! You didn't need to implement this, but good work. I apologize for the confusion!
@@ -1,27 +1,33 @@ | |||
class Queue { | |||
constructor() { |
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.
👀 While your implementation does work and utilize Javascript arrays effectively, the readme asks you to implement a queue using a circular buffer.
@@ -1,19 +1,20 @@ | |||
class Stack { |
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.
👀 While your implementation does work and utilize Javascript arrays effectively, unfortunately the readme requested you implement stacks using the included LinkedList class.
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.
✨
@kp483 Hello! The README in the JavaScript version of this project includes a link with "See the Ruby version for details." that I honestly did not notice at all. So I didn't realize the project required a specific implementation. In the future, is it possible to have these details added directly into the JavaScript README (rather than linked)? I will re-do this project as soon as I can. Thank you. |
Hi Afina, I agree the readme should be directly in the JavaScript version and have added it to our list of curriculum updates to implement. Additionally, I will be screening all future CS Fun projects to look out for this issue and be making changes as necessary. I apologize again that the JavaScript version was misleading and understand if you feel frustrated. Take your time resubmitting; I'll look out for it and prioritize getting feedback to you quickly when you do. |
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 changes to the Stack implementation!
@@ -1,19 +1,20 @@ | |||
class Stack { |
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.
✨
} | ||
|
||
isEmpty() { | ||
if (!this.store.length) return true; | ||
return false; | ||
return this.store.isEmpty(); | ||
} | ||
|
||
toString() { |
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.
👀 You might consider LinkedList's toString
method instead!
const toRemove = this.store.getLast(); | ||
this.store.delete(toRemove); | ||
|
||
return toRemove; | ||
} | ||
|
||
isEmpty() { |
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.
✨
} | ||
|
||
push(element) { | ||
this.store.push(element); | ||
this.store.addLast(element); | ||
return; | ||
} | ||
|
||
pop() { |
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.
✨
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 job Afina! Thanks for completing the project using a circular buffer and linked list respectively. I left a few comments on your new Queue implementation. Let me know what questions you have.
🟢
throw new Error("This method has not been implemented!"); | ||
this.store = new Array(20); | ||
// front and rear are index refs | ||
this.#front = this.#rear = 0; |
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.
✨ Curious as to why you chose to set the front
and rear
fields as private
constructor() { | ||
// this.store = ... | ||
throw new Error("This method has not been implemented!"); | ||
this.store = new Array(20); |
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.
👀 When implementing a circular buffer, it's often helpful to have a capacity
field to enable users to set the size of the buffer (you'd want to set capacity
as a parameter which can to default to 20)
this.store = new Array(20); | |
this.capacity = capacity | |
this.store = new Array(capacity); |
else if (this.isEmpty()) { | ||
this.store[this.#front] = element; | ||
} else { | ||
this.#rear += 1; |
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.
👀 Make sure you're handling the case where rear
wraps around!
this.#rear += 1; | |
this.#rear = (this.#rear + 1) % this.capacity; |
) { | ||
throw 'QueueFullException' | ||
} | ||
else if (this.isEmpty()) { |
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 use of your other methods!
this.store[this.#front] = null; | ||
|
||
if (this.#front === this.#rear) { | ||
this.#front = this.#rear = -1; |
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.
In your constructor, you initialize front
and rear
to zero. Make sure you stay consistent on this
this.#front = this.#rear = -1; | |
this.#front = this.#rear = 0; |
this.#front += 1 | ||
} | ||
|
||
return data; | ||
} | ||
|
||
front() { |
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.
✨
} | ||
|
||
front() { | ||
throw new Error("This method has not been implemented!"); | ||
return this.store[this.#front]; | ||
} | ||
|
||
size() { |
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.
✨
} | ||
|
||
size() { | ||
throw new Error("This method has not been implemented!"); | ||
return this.store.length; | ||
} | ||
|
||
isEmpty() { |
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.
✨
No description provided.