Posts

Data Structure: Stack and Queue

Image
  Stack and Queue in Data Structure WHAT IS STACK ? A linear data structure is a stack. A LIFO (Last In First Out) data structure is a stack. The first element that can be deleted from a stack is the last element that was added. Only one side of the list, termed the top, can have elements added or removed. Pushing is the process of adding an element to a stack. Popping is the process of removing an element from a stack. A pointer called top is used to monitor the last entry in a list in stacks. Stack Implementation: 1)       Using array 2)       Using linked list Array: It's a random-access container, which means that any part of it can be accessed at any time. Linked: A linked list is a collection of related items. It's a sequential-access container, which means that the data structure's elements can only be accessed in that order. On the stack, the following operations are performed: • create(): creates a new object. To ...