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

Branches - Diana Han #26

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

Branches - Diana Han #26

wants to merge 5 commits into from

Conversation

dhan0406
Copy link

@dhan0406 dhan0406 commented Mar 2, 2020

Stacks and Queues

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

Comprehension Questions

Question Answer
What is an ADT? Abstract Data Type is a data type that specifies an external interface and it's described by its methods and how they perform. It does not specify how it's build internally or implemented.
Describe a Stack Stack is an ADT in which elements follow the LIFO rule, last in first out.
What are the 5 methods in Stack and what does each do? Initialize creates the empty stack class. Push adds an element to the top of the stack. Pop removes and returns the last added element at the top of the stack. Empty? return true is the stack is empty. To_s returns the stack in a string format.
Describe a Queue Queue is an ADT in which elements follow the FIFO rule, first in first out.
What are the 5 methods in Queue and what does each do? Initialize creates a queue, in this case the default size was set at 50. Enqueue adds and element to the back of the queue. Dequeue removes and returns the first element. Empty? returns true if the front == back. To_s returns the elements in a string format, after removing the nil spaces.
What is the difference between implementing something and using something? An example of implementation is how we build the Stack and Queue class creating their methods. Using it would be when we call these methods on data types without knowing HOW it's being done.

OPTIONAL JobSimulation

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

@dhan0406
Copy link
Author

dhan0406 commented Mar 6, 2020

Hi Chris! Can I get more time to revise methods where I'm failing the tests, I can get them done by EOD!

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, you hit all the learning goals here. Very nice work with the circular buffer.

Comment on lines 3 to 5
# Time Complexity: ?
# Space Complexity: ?
def balanced(string)

Choose a reason for hiding this comment

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

👍

# @store = ...
raise NotImplementedError, "Not yet implemented"
@store = Array.new(50)
@front = @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.

👍

end

def dequeue
raise NotImplementedError, "Not yet implemented"
def dequeue #remove and return from front

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"
@back - @front

Choose a reason for hiding this comment

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

This works when front < back. What about when back has wrapped around the buffer.

Comment on lines +45 to +47
if @front == @back
return true
end

Choose a reason for hiding this comment

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

Suggested change
if @front == @back
return true
end
return @front == @back

raise NotImplementedError, "Not yet implemented"
if @front == @back
return true
end
end

def to_s

Choose a reason for hiding this comment

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

👍 Well done

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