-
Notifications
You must be signed in to change notification settings - Fork 41
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
Water - Mackenzie #15
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 Mackenzie, you hit the learning goals here. Well done.
|
||
@store = Array.new(MAX_SIZE) | ||
@front = -1 | ||
@back = -1 | ||
end | ||
|
||
def enqueue(element) |
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.
👍
end | ||
|
||
@store[@back] = element | ||
|
||
end | ||
|
||
def dequeue |
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.
👍
end | ||
|
||
return data | ||
|
||
end | ||
|
||
def 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.
👍
end | ||
|
||
def size | ||
raise NotImplementedError, "Not yet implemented" | ||
# raise NotImplementedError, "Not yet implemented" | ||
return @store.compact.length | ||
end | ||
|
||
def empty? |
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.
👍
end | ||
|
||
def empty? | ||
raise NotImplementedError, "Not yet implemented" | ||
# raise NotImplementedError, "Not yet implemented" | ||
return @store.compact.length == 0 ? true : false | ||
end | ||
|
||
def to_s |
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.
Just note that this will return the elements in the order they are in in the internal array, not in the queue order (i.e. the 1st element in the queue could be at index 3 and the last element of the queue at index 0.
@@ -1,19 +1,23 @@ | |||
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.
👍
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation