From 2506738d92a607b4216b88e74fd12ec0627868cb Mon Sep 17 00:00:00 2001 From: Anuj Rathour Date: Fri, 6 Oct 2023 00:40:42 +0530 Subject: [PATCH 1/4] updated-stack-readme-file --- .../datastructures/stacks/README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/README.md b/src/main/java/com/thealgorithms/datastructures/stacks/README.md index 69fc3a990383..c1a57bd40eda 100644 --- a/src/main/java/com/thealgorithms/datastructures/stacks/README.md +++ b/src/main/java/com/thealgorithms/datastructures/stacks/README.md @@ -1,10 +1,14 @@ # STACK -Stack is an ADT (abstract data type) that acts like a list of objects but there is a difference. +Stack is an ADT (abstract data type) that has a collection of elements where items are added and removed from the end, known as the "top" of 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)- +# Declaration + Stack stack=new Stack(); + +# functionalities +Stack is based on two functions (methods)- ## push(element) @@ -29,3 +33,13 @@ 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`. + +# Real Life Applications + ## Undo mechanisms: + Many software applications use stacks to implement an "undo" feature. + + ## Browser history: + The "back" button in a web browser is implemented using a stack, allowing users to navigate through previously visited pages. + + ## Function calls and recursion: + The computer's call stack keeps track of function calls, allowing programs to remember where to return after a function finishes execution. From d881af7e8c3fca908ff096b4f2a319557af46326 Mon Sep 17 00:00:00 2001 From: Anuj Rathour Date: Fri, 6 Oct 2023 00:47:53 +0530 Subject: [PATCH 2/4] updating-some-changes --- .../com/thealgorithms/datastructures/stacks/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/README.md b/src/main/java/com/thealgorithms/datastructures/stacks/README.md index c1a57bd40eda..dccb6ef7c05d 100644 --- a/src/main/java/com/thealgorithms/datastructures/stacks/README.md +++ b/src/main/java/com/thealgorithms/datastructures/stacks/README.md @@ -7,7 +7,7 @@ Stack works on the principle of _LIFO_ (Last In First Out), it means that the la # Declaration Stack stack=new Stack(); -# functionalities +# Functionalities Stack is based on two functions (methods)- ## push(element) @@ -35,11 +35,11 @@ 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`. # Real Life Applications - ## Undo mechanisms: + 1. Undo mechanisms: Many software applications use stacks to implement an "undo" feature. - ## Browser history: + 2. Browser history: The "back" button in a web browser is implemented using a stack, allowing users to navigate through previously visited pages. - ## Function calls and recursion: + 3. Function calls and recursion: The computer's call stack keeps track of function calls, allowing programs to remember where to return after a function finishes execution. From 4e67589bfc6644a8728ffeb3e5a6e05d61cd5660 Mon Sep 17 00:00:00 2001 From: Anuj Rathour Date: Fri, 6 Oct 2023 00:54:41 +0530 Subject: [PATCH 3/4] updated-stack-readme-file --- .../thealgorithms/datastructures/stacks/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/README.md b/src/main/java/com/thealgorithms/datastructures/stacks/README.md index dccb6ef7c05d..57164afe62fd 100644 --- a/src/main/java/com/thealgorithms/datastructures/stacks/README.md +++ b/src/main/java/com/thealgorithms/datastructures/stacks/README.md @@ -1,11 +1,11 @@ # STACK -Stack is an ADT (abstract data type) that has a collection of elements where items are added and removed from the end, known as the "top" of the stack. +- Stack is an ADT (abstract data type) that has a collection of elements where items are added and removed from the end, known as the "top" of 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 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. -# Declaration - Stack stack=new Stack(); +## Declaration + `Stack stack=new Stack();` # Functionalities Stack is based on two functions (methods)- @@ -35,11 +35,11 @@ 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`. # Real Life Applications - 1. Undo mechanisms: + - `Undo mechanisms:` Many software applications use stacks to implement an "undo" feature. - 2. Browser history: + - `Browser history:` The "back" button in a web browser is implemented using a stack, allowing users to navigate through previously visited pages. - 3. Function calls and recursion: + - `Function calls and recursion:` The computer's call stack keeps track of function calls, allowing programs to remember where to return after a function finishes execution. From f48ed743ecd4e90da715b4d3e0a63ae1cd740d1c Mon Sep 17 00:00:00 2001 From: Andrii Siriak Date: Sat, 7 Oct 2023 20:32:12 +0300 Subject: [PATCH 4/4] Update src/main/java/com/thealgorithms/datastructures/stacks/README.md --- src/main/java/com/thealgorithms/datastructures/stacks/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/README.md b/src/main/java/com/thealgorithms/datastructures/stacks/README.md index 57164afe62fd..55c3ffd7de64 100644 --- a/src/main/java/com/thealgorithms/datastructures/stacks/README.md +++ b/src/main/java/com/thealgorithms/datastructures/stacks/README.md @@ -1,6 +1,6 @@ # STACK -- Stack is an ADT (abstract data type) that has a collection of elements where items are added and removed from the end, known as the "top" of the stack. +- Stack is an ADT (abstract data type) that is a collection of elements where items are added and removed from the end, known as the "top" of 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.