Skip to content

Conversation

@Parseluni
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?
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

@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 Delia, you hit the learning goals, well done. Nothing to critique here, excellent submission.

Comment on lines +25 to +30
if self.size == self.buffer_size:
raise QueueFullException("The queue is full")
else:
self.rear = (self.rear + 1) % self.buffer_size
self.store[self.rear] = element
self.size += 1

Choose a reason for hiding this comment

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

👍

Comment on lines +37 to +43
if self.size == 0:
raise QueueEmptyException("The queue is empty")
else:
front_item = self.store[self.front]
self.front = (self.front + 1) % self.buffer_size
self.size = self.size - 1
return front_item

Choose a reason for hiding this comment

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

👍

Comment on lines +51 to +54
if self.size == 0:
return None
else:
return self.store[self.front]

Choose a reason for hiding this comment

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

👍

Comment on lines +75 to +79
q_list = []
for i in range(self.front, self.front + self.size):
i = i % self.buffer_size
q_list.append(self.store[i])
return str(q_list)

Choose a reason for hiding this comment

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

👍

pass
pass

class 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