Stacks and Queues (Python) - Data Structures and Algorithms

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

"Gosh Claire, why do you always want to torment me?"

kundaichasinda
Автор

I enjoy both kinds of videos you do. In person, and actually coding. I love the switch up of content. Really helps me pay attention and learn items from different perspectives.

chelseypeck
Автор

I think there is a lot of value derived from both the conceptual and hands on, I'd suggest staying with both for different types of learners!

k.
Автор

wooow!, well explained thanks man...👌

SiphepheloMlungwana
Автор

You know that you can just write data[-1] to access the last element of the list?

janh
Автор

Really helpful video, and I watched quite a few others before this one. Yours had the perfect balance between being objective but also not superficial. Thanks!

aliceiselectric
Автор

What troubling me was why in python we just use an array for a stack for just pop and push, when you can just get array[ 2] or [3] easily. The fact that you mentioned "we just have to limit its usage to make it work like a stack" is what cleared my head. LOL. And the stack implementation using the class at the end was perfect. Thank you dowg.

temp
Автор

i thought pop was only used for stacks and you are supposed to use deq for queues.. can you provide clarification on this?

pjverek
Автор

all my doubts cleared in a single vid regarding these topics

callmexfalcon
Автор

where is top or head and tail parameters?

mamaafrica
Автор

Caleb I beg of you to make one of these for Java lol I feel like they would be super similar but I also get confused

dsvhs
Автор

"Gosh Claire, why do you... always want to torment me?" oh Claire😭🤣

mapalo
Автор

class Stack:
def __init__(self, limit):
self.stack = []
self.limit = limit

def get_length(self):
return len(self.stack)

def push_stack(self, data):
if self.get_length() < self.limit:
self.stack.append(data)
else:
raise Exception("Stack is full")

def pop_stack(self):
if self.get_length() > 0:
self.stack.pop()
else:
raise Exception("Stack is empty")

def insert_at(self, index, data):
if self.get_length() < self.limit:
self.stack.insert(index, data)
else:
raise Exception("Invalid stack insertion")

def remove_at(self, index):
if self.get_length() > 0:
self.stack.pop(index)
else:
raise Exception("Invalid stack removal")

def show_stack(self):
print(self.stack)

def peek_stack(self):
print(self.stack[-1])

stack = Stack(limit=6)
stack.push_stack("a")
stack.push_stack("b")
stack.push_stack("c")
stack.insert_at(1, "z")
stack.remove_at(3)
stack.pop_stack()
print(stack.get_length())
stack.peek_stack()
stack.show_stack()

kvelez
Автор

toyota corrola chicken sandwich revolver god dangit

skulves
Автор

Can you do ASMR videos? Your voice sounds so soothing.

puzzlelovers