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

Shirley #24

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

Shirley #24

wants to merge 6 commits into from

Conversation

shirley1chu
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? Abstract Data Type is agnostic about implementation details (such as whether an array or linked list is used to make a stack/queue), but is defined by the set of operations it can perform.
Describe a Stack ADT with LIFO structure. The last item added is the first to get removed
What are the 5 methods in Stack and what does each do? Push -> adds an element at top of the stack. Pop -> removes top element and returns the value. Is_empty -> boolean for whether stack is empty. Size -> returns length of stack. Peek -> returns top element value, but DOES NOT remove from stack.
Describe a Queue ADT with FIFO structure. First element added is first to get removed.
What are the 5 methods in Queue and what does each do?
  • enqueue: adds element to back of queue
  • dequeue: removes first element from q, returns element value
  • is_empty? : boolean whether q is empty
  • size: returns q length
  • front: returns value of first element, but doesn't remove it
What is the difference between implementing something and using something? Implement is creating something (writing a method) for use, and using is simply consuming it (calling a method).

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.

Nicely done. I like how you did the postfix exercise. You also did very well with the Queue and the circular buffer. Nice work!

@@ -1,9 +1,58 @@
require_relative './stack.rb'
require_relative "./stack.rb"

def balanced(string)

Choose a reason for hiding this comment

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

👍

return false unless pop_c && pop_c == char_map[c]
end
end
return stack.empty?
end

def evaluate_postfix(postfix_expression)

Choose a reason for hiding this comment

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

Well done!

end

def front
raise NotImplementedError, "Not yet implemented"
return @head == -1 ? nil : store[@head]
end

def size

Choose a reason for hiding this comment

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

Well done!

end

def to_s
return @store.to_s
clone_store = @store.clone
clone_store.delete(nil)

Choose a reason for hiding this comment

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

Clever

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