Stack Data Structure Tutorial - What is a Stack?

preview_player
Показать описание
So what is a stack? This stack data structure tutorial will show you how to use a stack and what it is. As well as some example uses of it. The video concludes with an example of how to use two stacks to simulate a Queue.

A stack is almost opposite to a queue and follows FILO (First in Last Out). This means the first element inserted into the stack will be the last to come out. You can think of this structure similar to a stack of plates.

◾◾◾◾◾
💻 Enroll in The Fundamentals of Programming w/ Python

◾◾◾◾◾◾

⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡

Tags:
- Tech With Tim
- Stacks
- Stacks Data Structure
- Stacks Tutorial Computer Science
- Data Structure Stacks

#stacks #DataStructure
Рекомендации по теме
Комментарии
Автор

Hi. This is actually my first time of hearing about FILO. Usually this concept is represented by LIFO, but as they say, every day learn something new. Again, some python example would be nice here. Thanks for the tutorial.

iKostanCom
Автор

these are fantastic explanations & are very easy to understand- thanks a lot for taking the time to upload these tutorials!

nafishasanruman
Автор

Best educational content on the platform for me

ansible
Автор

This is great.

What’s the purpose of using 2 Stacks to be a Queue at all? Why not use a Queue itself?

Korudo
Автор

Nice videos. Make some on inplementation of these concepts. Thank you Tim :D

riskzerobeatz
Автор

simple and easy, couldn't ask for more !
subscribers++;

seal
Автор

Great video. Please make theoretical video series about algorithms as well.

lukaskratochvila
Автор

Instead of using the second stack as temp, pop all the elements from stack1 and push into stack2 and pop the second stack is it right?

menakask
Автор

Only pop work with python list, how to use other methods on list or any other way

funnyclipchallenge
Автор

But why would you use 2 stacks to simulate a queue when you could just use a queue? Didn't really get that?

mahadhashmi
Автор

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

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

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

def insert_at(self, index, data):
if 0 <= index <= self.limit - 1:
self.stack.insert(index, data)
else:
raise Exception("Stack is full")

def remove_at(self, index):
if 0 <= index < self.limit:
self.stack.pop(index)
else:
raise Exception("Stack is empty")

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

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

stack = Stack(limit=6)
stack.push("a")
stack.push("b")
stack.push("c")
stack.pop()
stack.push("z")
stack.push("y")
stack.insert_at(1, "t")
stack.remove_at(2)
print(stack.get_length())
stack.show_stack()

kvelez
Автор

Next, how to reverse a linked list.
😁

nowyouknow