Skip to content
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

Ringo - Earth #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Ringo - Earth #3

wants to merge 3 commits into from

Conversation

ringolingo
Copy link

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done Ringo, you hit the learning goals. I had one comment on dequeue, but otherwise this works well.

Comment on lines +3 to 8
Time Complexity: O(n), the function has to visit every node once
but operations performed in that loop are O(1)
Space Complexity: O(n), worst case scenario the stack could have on it
every character in the string
*/
const balanced = (str) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +27 to 34
Time Complexity: O(n), the function has to check every character in expr,
but operations in the for loop are O(1)
Space Complexity: O(n), the controlling factor is the height of the stack,
which does not grow quickly with longer expr in a normal use case but I suppose
in a worst case scenario with some weird postfix expressions would increase in size
linear to the length of the weird expression you were using
*/
const evaluatePostfix = (expr) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

} else {
this.store[this.tail] = element;
this.tail = (this.tail + 1) % QUEUE_SIZE;
}
}

dequeue() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Very compact! However what happens if you dequeue an empty queue?

throw new Error("This method has not been implemented!");
this.store = new Array(QUEUE_SIZE);
this.head = 0;
this.tail = 0;
}

enqueue(element) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice work, very compact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants