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

Ivana - Scissors #49

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

Ivana - Scissors #49

wants to merge 1 commit into from

Conversation

i-vs
Copy link

@i-vs i-vs commented Jan 18, 2022

Stacks and Queues

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

Comprehension Questions

Question Answer
What is an ADT? (oh an Abstract Data Structure) - An ADT defines a "group" of essential operations to perform with data, without defining details about the implementation.
Describe a Stack A type of ADT that holds data using a Last In First Out logic/system; to remove the first element from a stack, all the other elements added later need to be removed first.
What are the 5 methods in Stack and what does each do? stack.push(): add an element to the top; stack.pop(): remove the top element from the stack; .is_empty(): returns true if empty!; stack.size(): return the size or length of the stack; stack.peek(): verify/retrieve the top item without removing it from the stack.
Describe a Queue A type of ADT that holds data using a First In First Out logic/system; the first element added is the first one that will be removed. The elements on a queue are kept in order/are indexed, so that adding or removing elements to a queue won't move it's items to an unused space.
What are the 5 methods in Queue and what does each do? queue.enqueue(element): add an element at the rear of the queue; .dequeue(): retrieve an element from the queue. it's indexed in the front, so it'll be the first removed; .is_empty(): return True when the queue is empty; .is_full(): indicate that the queue has reached its max capacity, which starts with a fixed size
What is the difference between implementing something and using something? Implementing: building (programs) and any other useful tools given certain data that need to be handled in specific ways, or problems that need to be addressed with specific requirements. when there's a problem that needs to be solved, first we need to understand the problem and what's necessary to solve it; then, implement algorithms and tools that will help solving that problem. Using: when there are enough tools to solve a problem, there's no need to re-implement/build the foundations in order to solve it :B (someone has already done the job)

OPTIONAL JobSimulation

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

@i-vs i-vs changed the title add stack and queue Ivana - Scissors Jan 18, 2022
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 Ivana, this all hits the learning goals here. Well done.

self.size = 0


def enqueue(self, element):

Choose a reason for hiding this comment

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

👍

self.size += 1
self.store[self.rear] = element
self.rear = (self.rear + 1) % self.buffer_size


def dequeue(self):

Choose a reason for hiding this comment

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

👍

The Queue
"""
pass
return self.store[self.front] if not self.empty() else None

def empty(self):

Choose a reason for hiding this comment

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

👍

@@ -12,7 +12,8 @@ def push(self, element):
""" Adds an element to the top of the Stack.

Choose a reason for hiding this comment

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

Stack looks good!

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