Loops/Queue/Stack(s) Flashcards
What is a loop
a basic control flow structure that allows the repeated execution of a block of code as long as a specified condition is met.
What is a Queue
a fundamental data structure that allows for the storage and retrieval of data in a specific order.
what is a stack
linear data structure that stores items in a Last-In, first-Out or First-In, Last-Out manner. a new element is added at one end and an element is removed from that end only.
Is this a loop, Queue, or stack?
queue = [“Amar”, “Akbar”, “Anthony”]
queue
Is this a loop, Queue, or stack?
For i in range(10)
if i == 7:
break:
print(i)
loop
Is this a loop, Queue, or stack?
myStack = []
> > > myStack.append(‘a’)
myStack.append(‘b’)
> > > myStack
[‘a’, ‘b’]
> > > myStack.pop()
‘c’
myStack.pop()
‘b’
stack