Skip to content

Commit f6f12c0

Browse files
Improve readme for stack (TheAlgorithms#2385)
1 parent e85127e commit f6f12c0

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

DataStructures/Stacks/README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@ stack is an ADT (abstract data type ) that act like list of objects but there is
44

55
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.
66

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

9-
## push & pop
9+
## push(element)
1010

11-
**push**: add an alement to last index of stack.
11+
add "element" to the top of the stack.
1212

1313
for example: we have `1, 3, 5` in stack, then we call push(9),
1414

1515
`9` will add to last index of stack -> `1, 3, 5 , 9`
1616

17-
**pop**: remove the last element from stack.
17+
## peek() or top()
18+
19+
return element at the top of the stack.
20+
21+
for example: we have `1, 3, 5` in stack, then we call peek(),
22+
23+
`5` will be returned (without removing it from the stack)
24+
25+
## pop()
26+
27+
remove the last element (i.e. top of stack) from stack.
1828
for example: we have `1, 3, 5 , 9` in stack, then we call pop(),
1929

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

0 commit comments

Comments
 (0)