Skip to content

C16 - Spruce - Vange Spracklin#46

Open
HouseOfVange wants to merge 3 commits intoAda-C16:masterfrom
HouseOfVange:master
Open

C16 - Spruce - Vange Spracklin#46
HouseOfVange wants to merge 3 commits intoAda-C16:masterfrom
HouseOfVange:master

Conversation

@HouseOfVange
Copy link
Copy Markdown

Stacks and Queues

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

Comprehension Questions

Question Answer
What is an ADT?
Describe a Stack
What are the 5 methods in Stack and what does each do?
Describe a Queue
What are the 5 methods in Queue and what does each do?
What is the difference between implementing something and using something?

OPTIONAL JobSimulation

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

Copy link
Copy Markdown

@kyra-patton kyra-patton left a comment

Choose a reason for hiding this comment

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

✨😎 Very nice work, Vange! I left a couple small suggestions, but overall your implementation is solid.

I am grading this as a yellow because you did not attempt the comprehension questions, but a yellow is a passing score. If you would like to resubmit with the comprehension questions filled in, I'd happily up this to a green!

🟡

Comment thread stacks_queues/queue.py


def enqueue(self, element):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread stacks_queues/queue.py
self.rear = (self.rear + 1) % self.buffer_size
self.size += 1

def dequeue(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread stacks_queues/queue.py
"""
pass
if self.size == 0:
None
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤔 Looks like you forgot to return here. As it stands, you basically state the name of a literal None and then it floats away into the ether ☁

Suggested change
None
return None

Comment thread stacks_queues/queue.py
return self.store[self.front]


def size(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread stacks_queues/queue.py
pass
return self.size

def empty(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread stacks_queues/stack.py
Returns None
"""
pass
self.store.add_last(element)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread stacks_queues/stack.py
"""
pass
self.store.add_last(element)
return None
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Small style tip: If a function always returns None, I'd recommend returning None implicitly by just not having any return value (functions in Python return None by default).

Suggested change
return None

Comment thread stacks_queues/stack.py
return None

def pop(self):
""" Removes an element from the top
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread stacks_queues/stack.py
return self.store.remove_last()
# return None

def empty(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread stacks_queues/stack.py
ending with the bottom of the Stack.
"""
pass
if self.empty:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✨ Nice! You could also take advantage of LinkedList's str method!

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