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

R Melookaran #4

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

R Melookaran #4

wants to merge 4 commits into from

Conversation

roslynm
Copy link

@roslynm roslynm commented Apr 28, 2022

Fixed pickups.

Copy link

@kyra-patton kyra-patton left a comment

Choose a reason for hiding this comment

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

👍🏻 Your implementations looks good Roslyn. Let me know what questions you have.

Apologies for the extremely delayed feedback.

🟢

this.capacity = 20;
this.head = 0;
this.tail = 0;
this.store = Array(this.capacity).fill(null);
}

enqueue(element) {

Choose a reason for hiding this comment

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

if (this.size()!==this.capacity) {
this.store[this.tail] = element;
this.tail = (this.tail + 1) % this.capacity;
}
}

dequeue() {

Choose a reason for hiding this comment

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

this.store[this.head] = null;
this.head = (this.head + 1) % this.capacity;
return dequeued;
}
}

front() {

Choose a reason for hiding this comment

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

👀 We want to return the value at the front of the queue, not the index

}

front() {
throw new Error("This method has not been implemented!");
return this.head
}

size() {

Choose a reason for hiding this comment

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

} else {
size = this.tail - this.head;
}
return size;
}

isEmpty() {

Choose a reason for hiding this comment

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

}

push() {
throw new Error("This method has not been implemented!");
push(value) {

Choose a reason for hiding this comment

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

push() {
throw new Error("This method has not been implemented!");
push(value) {
this.store.addFirst(value);
}

pop() {

Choose a reason for hiding this comment

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

throw new Error("This method has not been implemented!");
const first = this.store.getFirst();
this.store.delete(first);
return first;
}

isEmpty() {

Choose a reason for hiding this comment

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

👀 This works, however LinkedList also has an empty method you could take advantage of

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.

3 participants