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

FIRE - Tram #30

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

FIRE - Tram #30

wants to merge 4 commits into from

Conversation

trambui09
Copy link

@trambui09 trambui09 commented Jun 13, 2021

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 is a type of object which is described by the methods it has and how they perform.
Describe a Stack Stack is a ADT, follows the LIFO(last-in-first-out) convention. Some supported functions include popping from the stack which removes the last item that was put in
What are the 5 methods in Stack and what does each do? push - push onto the stack, pop - remove the top item from the stack, is_empty? - checks whether the stack is empty or not, peek - sees, but not remove the item on top, size - returns the size of the stack
Describe a Queue A ADT that follows FIFO convention, First in is the first out
What are the 5 methods in Queue and what does each do? enqueue - put item into the queue, dequeue - remove item from the queue, is_empty? - checks if the queue is empty or not, peek - sees, but not remove the first item in the queue, size - returns the size of the queue
What is the difference between implementing something and using something? Implementing is constructing the methods to use. Using something would be to call the methods we implemented and reuse the implementation code every time we call it

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 Tram, you hit the learning goals here. Well done.

Comment on lines +3 to 5
# Time Complexity: O(n) - has to iterate through each char in the string input
# Space Complexity: O(n) - the stack is directly correlated with the string.length
def balanced(string)

Choose a reason for hiding this comment

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

👍

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

👍

@rear = @rear + 1
@store[@rear] = element
end

end

def dequeue

Choose a reason for hiding this comment

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

👍

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