Repository: TheAlgorithms/Java
Pull request #4372 (2023-09-13 14:30:20)

Moved StackPostfixNotation.java from the Others section to the Stack section

<!-- For completed items, change [ ] to [x] -->

- [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/CONTRIBUTING.md).
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.

## Issue
May solve issue #4360


beradeep: I think since this one is closely related to the application of stack, and that there are already algorithms like `PostfixToInfix.java` inside `stacks`, so moving `StackPostNotation.java` into `stacks` makes sense according to me.

BamaCharanChhandogi: > I think since this one is closely related to the application of stack, and that there are already algorithms like `PostfixToInfix.java` inside `stacks`, so moving `StackPostNotation.java` into `stacks` makes sense according to me.
> 

Exactly 
beradeep: So can it be merged?
siriak: Let's create a directory `stack` in `agorithms` directory and put stack-related algorithms there. They shouldn't be in `datastructures`. Besides, please also update file structure of tests to match that of algorithms
BamaCharanChhandogi: @beradeep are you working?
beradeep: I have tried to incorporate all the requested changes. Is it okay right now?

Patch:
diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/BalancedBrackets.java b/src/main/java/com/thealgorithms/stacks/BalancedBrackets.java
similarity index 98%
rename from src/main/java/com/thealgorithms/datastructures/stacks/BalancedBrackets.java
rename to src/main/java/com/thealgorithms/stacks/BalancedBrackets.java
index d80502d8..a73697a7 100644
--- a/src/main/java/com/thealgorithms/datastructures/stacks/BalancedBrackets.java
+++ b/src/main/java/com/thealgorithms/stacks/BalancedBrackets.java
@@ -1,4 +1,4 @@
-package com.thealgorithms.datastructures.stacks;
+package com.thealgorithms.stacks;
 
 import java.util.Stack;
 
diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/CalculateMaxOfMin.java b/src/main/java/com/thealgorithms/stacks/CalculateMaxOfMin.java
similarity index 95%
rename from src/main/java/com/thealgorithms/datastructures/stacks/CalculateMaxOfMin.java
rename to src/main/java/com/thealgorithms/stacks/CalculateMaxOfMin.java
index df7279bb..399b9efd 100644
--- a/src/main/java/com/thealgorithms/datastructures/stacks/CalculateMaxOfMin.java
+++ b/src/main/java/com/thealgorithms/stacks/CalculateMaxOfMin.java
@@ -7,7 +7,7 @@
  * Program description - Given an integer array. The task is to find the maximum of the minimum of
  * the array
  */
-package com.thealgorithms.datastructures.stacks;
+package com.thealgorithms.stacks;
 
 import java.util.*;
 
diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/DecimalToAnyUsingStack.java b/src/main/java/com/thealgorithms/stacks/DecimalToAnyUsingStack.java
similarity index 96%
rename from src/main/java/com/thealgorithms/datastructures/stacks/DecimalToAnyUsingStack.java
rename to src/main/java/com/thealgorithms/stacks/DecimalToAnyUsingStack.java
index ec6c8414..0a206a8b 100644
--- a/src/main/java/com/thealgorithms/datastructures/stacks/DecimalToAnyUsingStack.java
+++ b/src/main/java/com/thealgorithms/stacks/DecimalToAnyUsingStack.java
@@ -1,4 +1,4 @@
-package com.thealgorithms.datastructures.stacks;
+package com.thealgorithms.stacks;
 
 import java.util.Stack;
 
diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/DuplicateBrackets.java b/src/main/java/com/thealgorithms/stacks/DuplicateBrackets.java
similarity index 96%
rename from src/main/java/com/thealgorithms/datastructures/stacks/DuplicateBrackets.java
rename to src/main/java/com/thealgorithms/stacks/DuplicateBrackets.java
index fb976360..7daf2e06 100644
--- a/src/main/java/com/thealgorithms/datastructures/stacks/DuplicateBrackets.java
+++ b/src/main/java/com/thealgorithms/stacks/DuplicateBrackets.java
@@ -1,4 +1,4 @@
-package com.thealgorithms.datastructures.stacks;
+package com.thealgorithms.stacks;
 
 //  1. You are given a string exp representing an expression.
 // 2. Assume that the expression is balanced  i.e. the opening and closing brackets match with each
diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/InfixToPostfix.java b/src/main/java/com/thealgorithms/stacks/InfixToPostfix.java
similarity index 97%
rename from src/main/java/com/thealgorithms/datastructures/stacks/InfixToPostfix.java
rename to src/main/java/com/thealgorithms/stacks/InfixToPostfix.java
index b0092233..2cafdc94 100644
--- a/src/main/java/com/thealgorithms/datastructures/stacks/InfixToPostfix.java
+++ b/src/main/java/com/thealgorithms/stacks/InfixToPostfix.java
@@ -1,4 +1,4 @@
-package com.thealgorithms.datastructures.stacks;
+package com.thealgorithms.stacks;
 
 import java.util.Stack;
 
diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/LargestRectangle.java b/src/main/java/com/thealgorithms/stacks/LargestRectangle.java
similarity index 95%
rename from src/main/java/com/thealgorithms/datastructures/stacks/LargestRectangle.java
rename to src/main/java/com/thealgorithms/stacks/LargestRectangle.java
index f076d5d6..63f1d0b4 100644
--- a/src/main/java/com/thealgorithms/datastructures/stacks/LargestRectangle.java
+++ b/src/main/java/com/thealgorithms/stacks/LargestRectangle.java
@@ -1,4 +1,4 @@
-package com.thealgorithms.datastructures.stacks;
+package com.thealgorithms.stacks;
 
 import java.util.Stack;
 
diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/MaximumMinimumWindow.java b/src/main/java/com/thealgorithms/stacks/MaximumMinimumWindow.java
similarity index 98%
rename from src/main/java/com/thealgorithms/datastructures/stacks/MaximumMinimumWindow.java
rename to src/main/java/com/thealgorithms/stacks/MaximumMinimumWindow.java
index 88228000..5eb895d9 100644
--- a/src/main/java/com/thealgorithms/datastructures/stacks/MaximumMinimumWindow.java
+++ b/src/main/java/com/thealgorithms/stacks/MaximumMinimumWindow.java
@@ -1,4 +1,4 @@
-package com.thealgorithms.datastructures.stacks;
+package com.thealgorithms.stacks;
 
 import java.util.Arrays;
 import java.util.Stack;
diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/NextGraterElement.java b/src/main/java/com/thealgorithms/stacks/NextGraterElement.java
similarity index 97%
rename from src/main/java/com/thealgorithms/datastructures/stacks/NextGraterElement.java
rename to src/main/java/com/thealgorithms/stacks/NextGraterElement.java
index 294e436c..0cf56349 100644
--- a/src/main/java/com/thealgorithms/datastructures/stacks/NextGraterElement.java
+++ b/src/main/java/com/thealgorithms/stacks/NextGraterElement.java
@@ -1,4 +1,4 @@
-package com.thealgorithms.datastructures.stacks;
+package com.thealgorithms.stacks;
 
 import java.util.Arrays;
 import java.util.Stack;
diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/NextSmallerElement.java b/src/main/java/com/thealgorithms/stacks/NextSmallerElement.java
similarity index 97%
rename from src/main/java/com/thealgorithms/datastructures/stacks/NextSmallerElement.java
rename to src/main/java/com/thealgorithms/stacks/NextSmallerElement.java
index b25e5346..84263d98 100644
--- a/src/main/java/com/thealgorithms/datastructures/stacks/NextSmallerElement.java
+++ b/src/main/java/com/thealgorithms/stacks/NextSmallerElement.java
@@ -1,4 +1,4 @@
-package com.thealgorithms.datastructures.stacks;
+package com.thealgorithms.stacks;
 
 import java.util.Arrays;
 import java.util.Stack;
diff --git a/src/main/java/com/thealgorithms/datastructures/stacks/PostfixToInfix.java b/src/main/java/com/thealgorithms/stacks/PostfixToInfix.java
similarity index 98%
rename from src/main/java/com/thealgorithms/datastructures/stacks/PostfixToInfix.java
rename to src/main/java/com/thealgorithms/stacks/PostfixToInfix.java
index 0d67a793..0c674ec0 100644
--- a/src/main/java/com/thealgorithms/datastructures/stacks/PostfixToInfix.java
+++ b/src/main/java/com/thealgorithms/stacks/PostfixToInfix.java
@@ -1,4 +1,4 @@
-package com.thealgorithms.datastructures.stacks;
+package com.thealgorithms.stacks;
 
 import java.util.Stack;
 
diff --git a/src/main/java/com/thealgorithms/others/StackPostfixNotation.java b/src/main/java/com/thealgorithms/stacks/StackPostfixNotation.java
similarity index 98%
rename from src/main/java/com/thealgorithms/others/StackPostfixNotation.java
rename to src/main/java/com/thealgorithms/stacks/StackPostfixNotation.java
index 0e8ad58c..d4b7c922 100644
--- a/src/main/java/com/thealgorithms/others/StackPostfixNotation.java
+++ b/src/main/java/com/thealgorithms/stacks/StackPostfixNotation.java
@@ -1,4 +1,4 @@
-package com.thealgorithms.others;
+package com.thealgorithms.stacks;
 
 import java.util.Scanner;
 import java.util.Stack;


Test patch:
diff --git a/src/test/java/com/thealgorithms/others/CalculateMaxOfMinTest.java b/src/test/java/com/thealgorithms/stacks/CalculateMaxOfMinTest.java
similarity index 79%
rename from src/test/java/com/thealgorithms/others/CalculateMaxOfMinTest.java
rename to src/test/java/com/thealgorithms/stacks/CalculateMaxOfMinTest.java
index e80cf912..4cb1f48d 100644
--- a/src/test/java/com/thealgorithms/others/CalculateMaxOfMinTest.java
+++ b/src/test/java/com/thealgorithms/stacks/CalculateMaxOfMinTest.java
@@ -1,8 +1,7 @@
-package com.thealgorithms.others;
+package com.thealgorithms.stacks;
 
 import static org.junit.jupiter.api.Assertions.*;
 
-import com.thealgorithms.datastructures.stacks.CalculateMaxOfMin;
 import org.junit.jupiter.api.Test;
 
 public class CalculateMaxOfMinTest {
@@ -11,48 +10,48 @@ public class CalculateMaxOfMinTest {
     void testForOneElement() {
         int[] a = {10, 20, 30, 50, 10, 70, 30};
         int k = CalculateMaxOfMin.calculateMaxOfMin(a);
-        assertTrue(k == 70);
+        assertEquals(70, k);
     }
 
     @Test
     void testForTwoElements() {
         int[] a = {5, 3, 2, 6, 3, 2, 6};
         int k = CalculateMaxOfMin.calculateMaxOfMin(a);
-        assertTrue(k == 6);
+        assertEquals(6, k);
     }
 
     @Test
     void testForThreeElements() {
         int[] a = {10, 10, 10, 10, 10, 10, 10};
         int k = CalculateMaxOfMin.calculateMaxOfMin(a);
-        assertTrue(k == 10);
+        assertEquals(10, k);
     }
 
     @Test
     void testForFourElements() {
         int[] a = {70, 60, 50, 40, 30, 20};
         int k = CalculateMaxOfMin.calculateMaxOfMin(a);
-        assertTrue(k == 70);
+        assertEquals(70, k);
     }
 
     @Test
     void testForFiveElements() {
         int[] a = {50};
         int k = CalculateMaxOfMin.calculateMaxOfMin(a);
-        assertTrue(k == 50);
+        assertEquals(50, k);
     }
 
     @Test
     void testForSixElements() {
         int[] a = {1, 4, 7, 9, 2, 4, 6};
         int k = CalculateMaxOfMin.calculateMaxOfMin(a);
-        assertTrue(k == 9);
+        assertEquals(9, k);
     }
 
     @Test
     void testForSevenElements() {
         int[] a = {-1, -5, -7, -9, -12, -14};
         int k = CalculateMaxOfMin.calculateMaxOfMin(a);
-        assertTrue(k == -1);
+        assertEquals(-1, k);
     }
 }
diff --git a/src/test/java/com/thealgorithms/others/StackPostfixNotationTest.java b/src/test/java/com/thealgorithms/stacks/StackPostfixNotationTest.java
similarity index 90%
rename from src/test/java/com/thealgorithms/others/StackPostfixNotationTest.java
rename to src/test/java/com/thealgorithms/stacks/StackPostfixNotationTest.java
index 9256e2bc..4857529e 100644
--- a/src/test/java/com/thealgorithms/others/StackPostfixNotationTest.java
+++ b/src/test/java/com/thealgorithms/stacks/StackPostfixNotationTest.java
@@ -1,8 +1,7 @@
-package com.thealgorithms.others;
+package com.thealgorithms.stacks;
 
 import static java.util.Map.entry;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Map;
 import org.junit.jupiter.api.Test;