Posts

Stack datastructure

Image
  𝗦𝘁𝗮𝗰𝗸 𝗗𝗮𝘁𝗮 𝗦𝘁𝗿𝘂𝗰𝘁𝘂𝗿𝗲 : A stack is a linear data structure that follows the principle of Last In First Out (LIFO). This means the last element inserted inside the stack is removed first. A stack is a linear data structure that follows the principle of Last In First Out (LIFO). This means the last element inserted inside the stack is removed first. You can think of the stack data structure as the pile of plates on top of another. Here, you can: Put a new plate on top Remove the top plate And, if you want the plate at the bottom, you must first remove all the plates on top. This is exactly how the stack data structure works. 𝗟𝗜𝗙𝗢 𝗣𝗿𝗶𝗻𝗰𝗶𝗽𝗹𝗲 𝗼𝗳 𝗦𝘁𝗮𝗰𝗸 : In programming terms, putting an item on top of the stack is called push and removing an item is called pop. We can implement a stack in any programming language like C, C++, Java, Python or C#, but the specification is pretty much the same. 𝗕𝗮𝘀𝗶𝗰 𝗼𝗽𝗲𝗿𝗮𝘁𝗶𝗼𝗻𝘀 𝗼𝗳 𝘀𝘁𝗮𝗰𝗸 : There ar...