Skip to content

Conversation

waterlilly169
Copy link

@waterlilly169 waterlilly169 commented Jul 19, 2022

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
Describe a Stack A group of element based on the principal last in first out.
What are the 5 methods in Stack and what does each do? Push - puts item a top, pop returns item on top is empty test if stack is empty peek which returns but not removes size which tells the size
Describe a Queue they are first in first out
What are the 5 methods in Queue and what does each do? enqueue(item) - This method puts an item into the back of the queue. front that returns the item at the front
dequeue - This method removes and returns the item at the front of the queue.
is_empty - This method returns true if the queue is empty and false otherwise.
Front, Rear
|

| What is the difference between implementing something and using something? | Implementing something is create a method yourself versus using something that was already created |

OPTIONAL JobSimulation

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

Copy link

@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.

✨🌸 Hi Lilly, take another look at your str implementation for Stack; I think there were some missteps there. Otherwise, your implementations for Queue and Stacks looked really solid.

Since the comprehension questions were not filled out, I'm grading this as a yellow. Feel free to resubmit with them filled out and your 'str' method updated for a green score.

🟡

In the store are occupied
returns None
"""
pass

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

resubmitted, some formatting was off for questions, and missing a couple answers

Raises a QueueEmptyException if
The Queue is empty.
"""
pass

Choose a reason for hiding this comment

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

Comment on lines +53 to +54
if self.front == -1:
return None

Choose a reason for hiding this comment

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

Because you never check in dequeue whether dequeuing an element makes the Queue empty and, if the Queue does become empty, reset front to point at index -1, it may not always be true that the front pointer is at index -1 when the queue is empty. Try using the empty method you implement instead.

Suggested change
if self.front == -1:
return None
if self.empty():
return None

The Queue
"""
pass
return self.size

Choose a reason for hiding this comment

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

And False otherwise.
"""
pass
return self.size == 0

Choose a reason for hiding this comment

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

""" Returns the Queue in String form like:
[3, 4, 7]
Starting with the front of the Queue and
ending with the rear of the Queue.

Choose a reason for hiding this comment

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

Returns None
"""
pass
self.store.add_first(element)

Choose a reason for hiding this comment

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

returns None
"""
pass
return self.store.remove_first()

Choose a reason for hiding this comment

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

And False otherwise
"""
pass
return self.store.empty()

Choose a reason for hiding this comment

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

Comment on lines 42 to 43
String = "[" + str(self.store.first()) + "]"
return String

Choose a reason for hiding this comment

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

String is a keyword (name of the String class) in Python, so you want to avoid using it as your variable name. Additionally, you're only returning the first element of the Stack here - the specification asks for the entire stack to be printed instead. The Stack tests don't cover this method which is why they didn't catch this.

Try taking advantage of the str method in the LinkedList class instead.

@waterlilly169
Copy link
Author

resubmitted

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