+ 6

Can anyone please tell the purpose of stack(data structure) in python?

Like it's used to solve expressions ?

28th Apr 2021, 8:59 AM
Yusra
Yusra - avatar
19 odpowiedzi
+ 7
Shabnam Shaikh ok sister I'll do !
28th Apr 2021, 9:39 AM
Yusra
Yusra - avatar
+ 5
Stack (data structure) follows the LIFO(Last In First Out) principle. Real time example: the Undo option(shortcut ctrl+Z), it is used to remove(or goes back or erase) the recently(last) done work. Hope it helps, Thanks for reading my response.
30th Apr 2021, 2:00 AM
Murugan K
Murugan K - avatar
+ 4
But the main purpose not clarifies!
28th Apr 2021, 9:23 AM
Yusra
Yusra - avatar
+ 4
Exactly, like anything else in programming, if you really know what you're doing then you can make things do what you want. Please, don't even worry about stacks until you are comfortable with a language and know basic data types
28th Apr 2021, 9:25 AM
Slick
Slick - avatar
+ 4
Mohd Aadil It's used in solving any kind of expression like prefix , infix and postfix expressions?
28th Apr 2021, 2:10 PM
Yusra
Yusra - avatar
+ 4
Oh okay tysm Durga Devi
28th Apr 2021, 4:23 PM
Yusra
Yusra - avatar
+ 4
Add some durability to the language
29th Apr 2021, 2:23 AM
Ashraf Ali Qhtan Hammam
Ashraf Ali Qhtan Hammam - avatar
28th Apr 2021, 9:15 AM
Slick
Slick - avatar
+ 3
Hey Yusra Stack is a data structure, works on first in last out. Suppose you have square 🔲 pieces and you keep them one above another ( like building ) this will become a stack, now if you wish to remove then you will remove from top of collection. It's stack principle
28th Apr 2021, 12:52 PM
Mohd Aadil
Mohd Aadil - avatar
+ 3
Durga Devi can you explain last line ? that's what I m asking
28th Apr 2021, 3:15 PM
Yusra
Yusra - avatar
+ 3
Yusra Python's built-in list type makes a decent stack data structure as it supports push and pop operations in amortized O(1) time. Python's lists are implemented as dynamic arrays internally which means they occasional need to resize the storage space for elements stored in them when elements are added or removed. https://dbader.org/blog/stacks-in-python#:~:text=Python's%20built%2Din%20list%20type,elements%20are%20added%20or%20removed.
29th Apr 2021, 9:03 PM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
+ 3
-Stack is a linear data structure. -Insertion and deletion take place at one end called top. -Works on LIFO mechanism (Last in First out) which means elements inserted in last is first to remove from stack. -Push and pop are basic operation that is used for insertion and deletion of element. -eg.- Dine of plates, stack of books and so on.
30th Apr 2021, 4:58 AM
Utsav Singh
Utsav Singh - avatar
+ 2
Yusra I was saying what actually is stack, but it looks like you were looking for stack applications 😊
28th Apr 2021, 4:51 PM
Mohd Aadil
Mohd Aadil - avatar
+ 2
Actually stack is having different architectures in different programming environments like FIFO, LIFO etc. Usually two types of implementations are used - data is stored OR address of the data is stored.. hope this helps..
29th Apr 2021, 8:37 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 1
I think you should read this first: https://scoutapm.com/blog/JUMP_LINK__&&__python__&&__JUMP_LINK-memory-management#:~:text=Heap%20memory,-All%20objects%20and&text=When%20a%20variable%20is%20created,by%20all%20your%20program's%20methods.
28th Apr 2021, 9:15 AM
Md. Faheem Hossain
Md. Faheem Hossain - avatar
+ 1
Generally a stack is storage device that stores information i.e used for memory management,also used for conversion from one form of expression to another form .
28th Apr 2021, 2:59 PM
Durga Devi
Durga Devi - avatar
+ 1
Yes ,it's used in solving any kind of expression like ,infix, prefix and postfix expressions
28th Apr 2021, 3:44 PM
Durga Devi
Durga Devi - avatar
+ 1
What is a heap?
29th Apr 2021, 10:35 AM
ლაშა გაგნიძე
ლაშა გაგნიძე - avatar
+ 1
this is the real life application of stack: Let's take an example in google Docs we use undo and redo,... Here the last edited element will be removed in undo and the element is replaced in its original place in this way we can use it I think I've clarified ur doubt if ure still confused open google Docs enter any random line ... the sentence in this line is stored in the form of stack if u press (Ctrl+z) undo-> last element or sentence is popped Likewise undo all the line again redo them u can see that it's following last in first out and first in last out... thx
30th Apr 2021, 6:26 AM
kreddyt
kreddyt - avatar