Skip to content

C16- Maple Arcila#39

Open
arcila13 wants to merge 1 commit intoAda-C16:masterfrom
arcila13:master
Open

C16- Maple Arcila#39
arcila13 wants to merge 1 commit intoAda-C16:masterfrom
arcila13:master

Conversation

@arcila13
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? Abstract Data Type: this is a type of object is described by the methods it has and how they perform. Called ADT because the data structure description is independent from its implementation.
Describe a Stack A stack is a data structure which stores a list of data and only provides access in a LIFO order.
What are the 5 methods in Stack and what does each do? 1. push(item)--> puts item into the stack at the top, 2. pop--> removes and returns item on the top of stack, 3. is_empty--> returns true if the stack is empty and false if it is not, 4. str(self)--> returns stack in string form, 5. size--> which returns the number of items in the stack
Describe a Queue A queue is a data structure where elements are added to the back of the queue (FIFO)
What are the 5 methods in Queue and what does each do? 1. enqueue --> adds an elements to the queue, 2. dequeue --> removes and returns an element from the queue, 3. front --> returns an element for the front of the queue, 4. size --> returns the size of the queue, 5. empty --> returns true if the queue is empty and returns false if it is not
What is the difference between implementing something and using something? to implement is to put something into practice.

OPTIONAL JobSimulation

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

@arcila13 arcila13 changed the title pass tests C16- Maple Arcila Jun 13, 2022
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.

✨💫 Nice work! I left one small comment below. Let me know what questions you have.

🟢



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


def dequeue(self):

Choose a reason for hiding this comment

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

self.size -= 1
return dequeue

def front(self):

Choose a reason for hiding this comment

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


return self.store[self.front]

def size(self):

Choose a reason for hiding this comment

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

return self.size


def empty(self):

Choose a reason for hiding this comment

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

return False


def __str__(self):

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.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.length() == 0

Choose a reason for hiding this comment

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

✨ However, you could also take advantage of LinkedList's empty function

ending with the bottom of the Stack.
"""
pass
return str(self.store)

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