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

all tests passing #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

RachaelGomez
Copy link

Stacks and Queues

Thanks for doing some brain yoga. You are now submitting this assignment!

Comprehension Questions

Question Answer
What is an ADT? An abstract data type that is defined by the methods and not which type of data structure it uses ie an array or a linked list
Describe a Stack A method of storing data that uses last in first out. Like taking the most recent book you bought off of a stack of other books you bought that you swear you'll get around to reading.
What are the 5 methods in Stack and what does each do? push: to add an object to the top of the stack, pop: to removed an item from the top of the stack, is empty: to check if the stack is empty, peek: to look at but not remove the top element of the stack, and size: to tell you the size of the stack
Describe a Queue A queue is an ADT that operates on a first in first out basis like a long line for ice cream on a day that reminds you global warming is very real.
What are the 5 methods in Queue and what does each do? enqueue(item): adds an item to the end of the queue, dequeue: removes an item from the beginning of the queue, is_empty: says true if its empty or false if it's not, front: returns the first element but doesn't change it, and size: returns the size of the queue.
What is the difference between implementing something and using something? I'm not completely certain on this reading, but I believe you mean that implementing is how doing something how it was designed to be used whereas using it is just doing it, however. I can use a screwdriver to hammer in a nail, but that's not how it was designed to be implemented?

OPTIONAL JobSimulation

Question Answer
Did you include a sample run of your code as a comment?

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.

Nice work Rachael, you hit all the learning goals here. Well done.

raise NotImplementedError, "Not yet implemented"
@store = Array.new
@front = -1
@back = -1
end

def enqueue(element)

Choose a reason for hiding this comment

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

👍

@back += 1
end

@store[@back] = element
end

def dequeue

Choose a reason for hiding this comment

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

👍

Comment on lines +36 to +40
elsif @front + 1 == MAX_SIZE
@front = 0
else
@front += 1
end

Choose a reason for hiding this comment

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

Just be aware you can do things like:

Suggested change
elsif @front + 1 == MAX_SIZE
@front = 0
else
@front += 1
end
else
@front = (front + 1) % MAX_SIZE
end

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