From e341f44065ec8129d5b03eeb9a514f96c7df9740 Mon Sep 17 00:00:00 2001 From: Richa Srivastava <74401402+getRicha@users.noreply.github.com> Date: Sun, 24 Oct 2021 12:48:49 +0530 Subject: [PATCH] Update README.md of stack (#2671) --- DataStructures/Stacks/README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/DataStructures/Stacks/README.md b/DataStructures/Stacks/README.md index 48f28ff93..69fc3a990 100644 --- a/DataStructures/Stacks/README.md +++ b/DataStructures/Stacks/README.md @@ -1,30 +1,31 @@ # STACK -stack is an ADT (abstract data type ) that act like list of objects but there is a diffrents. +Stack is an ADT (abstract data type) that acts like a list of objects but there is a difference. -stack act is _LIFO_ (Last In First Out), it means that when we want to get an element from the stack we get the last element in the stack. +Stack works on the principle of _LIFO_ (Last In First Out), it means that the last item added to the stack will be the first item to be removed. -stack is based on two methods (functions) +Stack is based on two methods (functions)- ## push(element) -add "element" to the top of the stack. +It adds "element" to the top of the stack. -for example: we have `1, 3, 5` in stack, then we call push(9), +For example: If we have `1, 3, 5` in stack, and we call push(9), -`9` will add to last index of stack -> `1, 3, 5 , 9` +`9` will be added to last index of stack -> `1, 3, 5 , 9`. ## peek() or top() -return element at the top of the stack. +It returns element at the top of the stack. -for example: we have `1, 3, 5` in stack, then we call peek(), +For example: If we have `1, 3, 5` in stack, and we call peek(), -`5` will be returned (without removing it from the stack) +`5` will be returned (without removing it from the stack). ## pop() -remove the last element (i.e. top of stack) from stack. -for example: we have `1, 3, 5 , 9` in stack, then we call pop(), +It removes the last element (i.e. top of stack) from stack. + +For example: If we have `1, 3, 5 , 9` in stack, and we call pop(), the function will return `9` and the stack will change to `1, 3, 5`.