Skip to content

Commit e341f44

Browse files
authored
Update README.md of stack (TheAlgorithms#2671)
1 parent 83ecf56 commit e341f44

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

DataStructures/Stacks/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
# STACK
22

3-
stack is an ADT (abstract data type ) that act like list of objects but there is a diffrents.
3+
Stack is an ADT (abstract data type) that acts like a list of objects but there is a difference.
44

5-
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.
5+
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.
66

7-
stack is based on two methods (functions)
7+
Stack is based on two methods (functions)-
88

99
## push(element)
1010

11-
add "element" to the top of the stack.
11+
It adds "element" to the top of the stack.
1212

13-
for example: we have `1, 3, 5` in stack, then we call push(9),
13+
For example: If we have `1, 3, 5` in stack, and we call push(9),
1414

15-
`9` will add to last index of stack -> `1, 3, 5 , 9`
15+
`9` will be added to last index of stack -> `1, 3, 5 , 9`.
1616

1717
## peek() or top()
1818

19-
return element at the top of the stack.
19+
It returns element at the top of the stack.
2020

21-
for example: we have `1, 3, 5` in stack, then we call peek(),
21+
For example: If we have `1, 3, 5` in stack, and we call peek(),
2222

23-
`5` will be returned (without removing it from the stack)
23+
`5` will be returned (without removing it from the stack).
2424

2525
## pop()
2626

27-
remove the last element (i.e. top of stack) from stack.
28-
for example: we have `1, 3, 5 , 9` in stack, then we call pop(),
27+
It removes the last element (i.e. top of stack) from stack.
28+
29+
For example: If we have `1, 3, 5 , 9` in stack, and we call pop(),
2930

3031
the function will return `9` and the stack will change to `1, 3, 5`.

0 commit comments

Comments
 (0)