diff --git a/.gitignore b/.gitignore
index cff400b..976e04b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,28 @@
/RemoveDuplicates/nbproject/private/
/RecursionProblems/nbproject/private/
-/RecursionProblems/build/
\ No newline at end of file
+/RecursionProblems/build/
+/Recursion/Triple Step/nbproject/private/
+/Recursion/Triple Step/build/
+/Recursion/NQueen/nbproject/private/
+/Recursion/NQueen/build/
+/Recursion/RobotOnGrid/nbproject/private/
+/Recursion/RobotOnGrid/build/
+/Recursion/PowerSet/nbproject/private/
+/Recursion/PowerSet/build/
+/Recursion/RecursiveMultiply/nbproject/private/
+/Recursion/RecursiveMultiply/build/
+/Recursion/TowerOfHanoi/nbproject/private/
+/Recursion/TowerOfHanoi/build/
+/Recursion/PermutationWithoutDuplicate/nbproject/private/
+/Recursion/Permutation/nbproject/private/
+/Recursion/Permutation/build/
+/Recursion/Parenstheses/nbproject/private/
+/Recursion/Parenstheses/build/
+/Recursion/FloodFill/nbproject/private/
+/Recursion/FloodFill/build/
+/Recursion/Coins/nbproject/private/
+/Recursion/Coins/build/
+/Recursion/StackOfBoxes/nbproject/private/
+/Recursion/StackOfBoxes/build/
+/Recursion/BooleanEvaluation/nbproject/private/
+/Recursion/BooleanEvaluation/build/
\ No newline at end of file
diff --git a/Recursion/BooleanEvaluation/build.xml b/Recursion/BooleanEvaluation/build.xml
new file mode 100644
index 0000000..75be52e
--- /dev/null
+++ b/Recursion/BooleanEvaluation/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project BooleanEvaluation.
+
+
+
diff --git a/Recursion/BooleanEvaluation/manifest.mf b/Recursion/BooleanEvaluation/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/BooleanEvaluation/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/BooleanEvaluation/nbproject/build-impl.xml b/Recursion/BooleanEvaluation/nbproject/build-impl.xml
new file mode 100644
index 0000000..dda37ae
--- /dev/null
+++ b/Recursion/BooleanEvaluation/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/BooleanEvaluation/nbproject/genfiles.properties b/Recursion/BooleanEvaluation/nbproject/genfiles.properties
new file mode 100644
index 0000000..7e61513
--- /dev/null
+++ b/Recursion/BooleanEvaluation/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=845fda0d
+build.xml.script.CRC32=29fe8b83
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=845fda0d
+nbproject/build-impl.xml.script.CRC32=ac42229d
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/BooleanEvaluation/nbproject/project.properties b/Recursion/BooleanEvaluation/nbproject/project.properties
new file mode 100644
index 0000000..70551ff
--- /dev/null
+++ b/Recursion/BooleanEvaluation/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/BooleanEvaluation.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=booleanevaluation.BooleanEvaluation
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/BooleanEvaluation/nbproject/project.xml b/Recursion/BooleanEvaluation/nbproject/project.xml
new file mode 100644
index 0000000..c9f1b03
--- /dev/null
+++ b/Recursion/BooleanEvaluation/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ BooleanEvaluation
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/BooleanEvaluation/src/booleanevaluation/BooleanEvaluation.java b/Recursion/BooleanEvaluation/src/booleanevaluation/BooleanEvaluation.java
new file mode 100644
index 0000000..d0540ef
--- /dev/null
+++ b/Recursion/BooleanEvaluation/src/booleanevaluation/BooleanEvaluation.java
@@ -0,0 +1,71 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package booleanevaluation;
+
+/**
+ * Given a boolean expression consisting of the symbols 0 (false), 1 (true) & (AND)
+ * | (OR) and ^ (XOR) and a desired boolean result value result. Implement a
+ * function to count the number of ways of parenthesizing the expression such that
+ * it evaluates to result. The expression should be fully parenthesized (e.g (0)^(1))
+ * but not extraneously (e.g. (((0))^(1)))
+ * @author souravpalit
+ */
+public class BooleanEvaluation {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ // TODO code application logic here
+ //String expression = "1^0|0|1";
+ //String expression = "0&0&0&1^1|0";
+ String expression = "0|1^1&0";
+ boolean result = true;
+ System.out.println(countEval(expression, result));
+ }
+
+ public static int countEval(String s, boolean result) {
+ if (s.length() == 0) return 0;
+ if (s.length() == 1) return stringToBool(s) == result ? 1: 0;
+
+ int ways = 0;
+
+ for (int i = 1; i < s.length(); i += 2) {
+ char c = s.charAt(i);
+ String left = s.substring(0, i);
+ String right = s.substring(i+1, s.length());
+
+ // Evaluate each side for each result
+ int leftTrue = countEval(left, true);
+ int rightTrue = countEval(right, true);
+ int leftFalse = countEval(left, false);
+ int rightFalse = countEval(right, false);
+
+ int total = (leftTrue + leftFalse) * (rightTrue + rightFalse);
+
+ int totalTrue = 0;
+
+ if (c == '^') { // required 1 true and 1 false
+ totalTrue = (leftTrue * rightFalse) + (leftFalse * rightTrue);
+ } else if (c == '&') {
+ totalTrue = leftTrue * rightTrue;
+ } else if (c == '|') {
+ totalTrue = (leftTrue * rightTrue) + (leftTrue * rightFalse) + (leftFalse * rightTrue);
+ }
+
+ int subWays = result ? totalTrue : total - totalTrue;
+
+ ways+= subWays;
+ }
+
+ return ways;
+ }
+
+ public static boolean stringToBool(String c) {
+ return c.equals("1") ? true : false;
+ }
+
+}
diff --git a/Recursion/BooleanEvaluation/src/booleanevaluation/BooleanEvaluationOptimized.java b/Recursion/BooleanEvaluation/src/booleanevaluation/BooleanEvaluationOptimized.java
new file mode 100644
index 0000000..c296e38
--- /dev/null
+++ b/Recursion/BooleanEvaluation/src/booleanevaluation/BooleanEvaluationOptimized.java
@@ -0,0 +1,78 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package booleanevaluation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Given a boolean expression consisting of the symbols 0 (false), 1 (true) & (AND)
+ * | (OR) and ^ (XOR) and a desired boolean result value result. Implement a
+ * function to count the number of ways of parenthesizing the expression such that
+ * it evaluates to result. The expression should be fully parenthesized (e.g (0)^(1))
+ * but not extraneously (e.g. (((0))^(1)))
+ * @author souravpalit
+ */
+public class BooleanEvaluationOptimized {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ // TODO code application logic here
+ //String expression = "1^0|0|1";
+ //String expression = "0&0&0&1^1|0";
+ String expression = "0|1^1&0";
+ HashMap memory = new HashMap();
+ boolean result = true;
+ System.out.println(countEval(expression, result, memory));
+ }
+
+ public static int countEval(String s, boolean result, HashMap memory) {
+ if (s.length() == 0) return 0;
+ if (s.length() == 1) return stringToBool(s) == result ? 1: 0;
+ if (memory.containsKey(result + s)) return memory.get(result + s);
+
+ int ways = 0;
+
+ for (int i = 1; i < s.length(); i += 2) {
+ char c = s.charAt(i);
+ String left = s.substring(0, i);
+ String right = s.substring(i+1, s.length());
+
+ // Evaluate each side for each result
+ int leftTrue = countEval(left, true, memory);
+ int rightTrue = countEval(right, true, memory);
+ int leftFalse = countEval(left, false, memory);
+ int rightFalse = countEval(right, false, memory);
+
+ int total = (leftTrue + leftFalse) * (rightTrue + rightFalse);
+
+ int totalTrue = 0;
+
+ if (c == '^') { // required 1 true and 1 false
+ totalTrue = (leftTrue * rightFalse) + (leftFalse * rightTrue);
+ } else if (c == '&') {
+ totalTrue = leftTrue * rightTrue;
+ } else if (c == '|') {
+ totalTrue = (leftTrue * rightTrue) + (leftTrue * rightFalse) + (leftFalse * rightTrue);
+ }
+
+ int subWays = result ? totalTrue : total - totalTrue;
+
+ ways+= subWays;
+ }
+
+ memory.put(result + s, ways);
+
+ return ways;
+ }
+
+ public static boolean stringToBool(String c) {
+ return c.equals("1") ? true : false;
+ }
+
+}
diff --git a/Recursion/Coins/build.xml b/Recursion/Coins/build.xml
new file mode 100644
index 0000000..483cbd1
--- /dev/null
+++ b/Recursion/Coins/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project Coins.
+
+
+
diff --git a/Recursion/Coins/manifest.mf b/Recursion/Coins/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/Coins/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/Coins/nbproject/build-impl.xml b/Recursion/Coins/nbproject/build-impl.xml
new file mode 100644
index 0000000..b16bca0
--- /dev/null
+++ b/Recursion/Coins/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/Coins/nbproject/genfiles.properties b/Recursion/Coins/nbproject/genfiles.properties
new file mode 100644
index 0000000..484600a
--- /dev/null
+++ b/Recursion/Coins/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=793db524
+build.xml.script.CRC32=f587c492
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=793db524
+nbproject/build-impl.xml.script.CRC32=2ca90b70
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/Coins/nbproject/project.properties b/Recursion/Coins/nbproject/project.properties
new file mode 100644
index 0000000..5cf90da
--- /dev/null
+++ b/Recursion/Coins/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Coins.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=coins.Coins
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/Coins/nbproject/project.xml b/Recursion/Coins/nbproject/project.xml
new file mode 100644
index 0000000..8acd739
--- /dev/null
+++ b/Recursion/Coins/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ Coins
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/Coins/src/coins/Coins.java b/Recursion/Coins/src/coins/Coins.java
new file mode 100644
index 0000000..762bc5e
--- /dev/null
+++ b/Recursion/Coins/src/coins/Coins.java
@@ -0,0 +1,46 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package coins;
+
+/**
+ * Given an infinite number of quarters (25 cents), dimes (10 cents), nickels
+ * (5 cents) and pennies (1 cent) write code to calculate the number of ways of
+ * representing n cents.
+ * @author souravpalit
+ */
+public class Coins {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ System.out.println(makeChange(100));
+ }
+
+ public static int makeChange(int n) {
+ int [] denoms = {25, 10, 5, 1};
+ return makeChange(n, denoms, 0);
+ }
+
+ public static int makeChange(int amount, int [] denoms, int index) {
+ if (index >= denoms.length -1) return 1; // last denom
+
+ int denomAmount = denoms[index];
+ int ways = 0;
+
+ for (int i = 0; i * denomAmount <= amount; i++) {
+ int remainingAmount = amount - i * denomAmount;
+ if (remainingAmount == 0) {
+ ways++;
+ } else {
+ ways = ways + makeChange(remainingAmount, denoms, index + 1);
+ }
+ }
+
+ return ways;
+ }
+
+}
diff --git a/Recursion/Coins/src/coins/CoinsOptimized.java b/Recursion/Coins/src/coins/CoinsOptimized.java
new file mode 100644
index 0000000..0e33dc1
--- /dev/null
+++ b/Recursion/Coins/src/coins/CoinsOptimized.java
@@ -0,0 +1,51 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package coins;
+
+/**
+ * Given an infinite number of quarters (25 cents), dimes (10 cents), nickels
+ * (5 cents) and pennies (1 cent) write code to calculate the number of ways of
+ * representing n cents.
+ * @author souravpalit
+ */
+public class CoinsOptimized {
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ System.out.println(makeChange(100));
+ }
+
+ public static int makeChange(int n) {
+ int [] denoms = {25, 10, 5, 1};
+ int [][] memory = new int [n+1][denoms.length];
+ return makeChange(n, denoms, 0, memory);
+ }
+
+ public static int makeChange(int amount, int [] denoms, int index, int [][] memory) {
+ if (memory[amount][index] > 0) {
+ return memory[amount][index];
+ } else if (index >= denoms.length -1) {
+ return 1; // last denom
+ } else {
+ int denomAmount = denoms[index];
+ int ways = 0;
+
+ for (int i = 0; i * denomAmount <= amount; i++) {
+ int remainingAmount = amount - i * denomAmount;
+ if (remainingAmount == 0) {
+ ways++;
+ } else {
+ ways = ways + makeChange(remainingAmount, denoms, index + 1, memory);
+ }
+ }
+
+ memory[amount][index] = ways;
+
+ return ways;
+ }
+ }
+}
diff --git a/Recursion/FloodFill/build.xml b/Recursion/FloodFill/build.xml
new file mode 100644
index 0000000..80dc182
--- /dev/null
+++ b/Recursion/FloodFill/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project FloodFill.
+
+
+
diff --git a/Recursion/FloodFill/manifest.mf b/Recursion/FloodFill/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/FloodFill/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/FloodFill/nbproject/build-impl.xml b/Recursion/FloodFill/nbproject/build-impl.xml
new file mode 100644
index 0000000..9e8855a
--- /dev/null
+++ b/Recursion/FloodFill/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/FloodFill/nbproject/genfiles.properties b/Recursion/FloodFill/nbproject/genfiles.properties
new file mode 100644
index 0000000..ab77307
--- /dev/null
+++ b/Recursion/FloodFill/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=123db360
+build.xml.script.CRC32=0e889d30
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=123db360
+nbproject/build-impl.xml.script.CRC32=1d3248bb
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/FloodFill/nbproject/project.properties b/Recursion/FloodFill/nbproject/project.properties
new file mode 100644
index 0000000..73277b1
--- /dev/null
+++ b/Recursion/FloodFill/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/FloodFill.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=floodfill.FloodFill
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/FloodFill/nbproject/project.xml b/Recursion/FloodFill/nbproject/project.xml
new file mode 100644
index 0000000..9663bbc
--- /dev/null
+++ b/Recursion/FloodFill/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ FloodFill
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/FloodFill/src/floodfill/FloodFill.java b/Recursion/FloodFill/src/floodfill/FloodFill.java
new file mode 100644
index 0000000..d85942c
--- /dev/null
+++ b/Recursion/FloodFill/src/floodfill/FloodFill.java
@@ -0,0 +1,76 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package floodfill;
+
+/**
+ * Implement a function that one might see on many image editing programs. This
+ * is, given a screen (represented by a two-dimensional array of colors), a point,
+ * and a new color, fill in the surrounding area until the color changes from the
+ * original color
+ * @author souravpalit
+ */
+public class FloodFill {
+
+ /* Considering we have a two dimensional array as an image where each value
+ * is like an image pixel. Where Consider three color. 0 means black, 1 means
+ * white and 2 means blue. Consider the array has only black and white color
+ * and we want to replace black color with blue.
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+
+ int [][] image = {
+ {0,0,0,0,0},
+ {0,1,1,1,0},
+ {0,1,0,1,0},
+ {0,1,1,1,0},
+ {0,0,0,0,0}};
+
+ // Select a point to start coloring
+ int rowPos = 0;
+ int colPos = 2;
+ int oldColor = 0;
+ int newColor = 2;
+ floodFill(image, rowPos, colPos, oldColor, newColor);
+
+ System.out.println();
+ printImage(image);
+ }
+
+ public static void floodFill(int [][] image, int row,
+ int col, int oldColor, int newColor) {
+
+ if (row < 0 || row >= image.length || col < 0 || col >= image[0].length) {
+ return;
+ } else {
+ // If the position has target color then we will work
+ if (image[row][col] == oldColor) {
+ image[row][col] = newColor;
+
+ printImage(image);
+
+ floodFill(image, row - 1, col, oldColor, newColor); // Top
+ floodFill(image, row + 1, col, oldColor, newColor); // Bottom
+ floodFill(image, row, col - 1, oldColor, newColor); // Left
+ floodFill(image, row, col + 1, oldColor, newColor); // Right
+
+
+ }
+
+ return;
+ }
+ }
+
+ public static void printImage(int [][] image) {
+ for (int row = 0; row < image.length; row++) {
+ for (int col = 0; col < image[row].length; col++) {
+ System.out.print(image[row][col] + " ");
+ }
+ System.out.println();
+ }
+ }
+
+}
diff --git a/Recursion/NQueen/README.md b/Recursion/NQueen/README.md
new file mode 100644
index 0000000..9c8ba74
--- /dev/null
+++ b/Recursion/NQueen/README.md
@@ -0,0 +1 @@
+# Java-DataStructure-Algorithm-Problem
\ No newline at end of file
diff --git a/Recursion/NQueen/build.xml b/Recursion/NQueen/build.xml
new file mode 100644
index 0000000..eb5a6fa
--- /dev/null
+++ b/Recursion/NQueen/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project NQueen.
+
+
+
diff --git a/Recursion/NQueen/manifest.mf b/Recursion/NQueen/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/NQueen/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/NQueen/nbproject/build-impl.xml b/Recursion/NQueen/nbproject/build-impl.xml
new file mode 100644
index 0000000..57748e2
--- /dev/null
+++ b/Recursion/NQueen/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/NQueen/nbproject/genfiles.properties b/Recursion/NQueen/nbproject/genfiles.properties
new file mode 100644
index 0000000..6e100ea
--- /dev/null
+++ b/Recursion/NQueen/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=f5984323
+build.xml.script.CRC32=0136b2aa
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=f5984323
+nbproject/build-impl.xml.script.CRC32=f0d51449
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/NQueen/nbproject/project.properties b/Recursion/NQueen/nbproject/project.properties
new file mode 100644
index 0000000..8915652
--- /dev/null
+++ b/Recursion/NQueen/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/NQueen.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=nqueen.NQueen
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/NQueen/nbproject/project.xml b/Recursion/NQueen/nbproject/project.xml
new file mode 100644
index 0000000..d5b66f2
--- /dev/null
+++ b/Recursion/NQueen/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ NQueen
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/NQueen/src/nqueen/NQueen.java b/Recursion/NQueen/src/nqueen/NQueen.java
new file mode 100644
index 0000000..b00d01d
--- /dev/null
+++ b/Recursion/NQueen/src/nqueen/NQueen.java
@@ -0,0 +1,99 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package nqueen;
+
+/**
+ * Write an algorithm to print all ways of arranging n queens on on n*n chess board
+ * so that none of them share the same row, column or diagonal.
+ * @author souravpalit
+ */
+public class NQueen {
+
+ public static final int N = 4;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ solveNQueenProblem();
+ }
+
+ public static void solveNQueenProblem() {
+
+ int board [][] = new int [N][N];
+
+ for (int i = 0; i < N; i++) {
+ for (int j = 0; j < N; j++) {
+ board[i][j] = 0;
+ }
+ }
+
+ if (solveNQueen(board, 0)) {
+ printSolution(board);
+ } else {
+ System.out.println("Solution doesn't exist");
+ }
+ }
+
+ public static boolean solveNQueen(int board[][], int col) {
+
+ if (col >= N) {
+ return true;
+ }
+
+ for (int i = 0; i < N; i++) {
+
+ if (canPlaceQueen(board, i, col)) {
+ board[i][col] = 1;
+
+ if (solveNQueen(board, col + 1)) {
+ return true;
+ } else {
+ board[i][col] = 0;
+ }
+ }
+ }
+
+ return false;
+ }
+
+
+ public static boolean canPlaceQueen(int board[][], int row, int col) {
+
+ // row-wise
+ for (int i = 0; i < col; i++) {
+ if (board[row][i] == 1) {
+ return false;
+ }
+ }
+
+ // diagonal wise left lower diagonal
+ for(int i = row, j = col; i >= 0 && j >= 0; i--, j--) {
+ if (board[i][j] == 1) {
+ return false;
+ }
+ }
+
+ // diagonal wise upper left diagonal
+ for(int i = row, j = col; i < N && j >= 0; i++, j--) {
+ if (board[i][j] == 1) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /* A utility function to print solution */
+ public static void printSolution(int board[][]) {
+ for (int i = 0; i < N; i++) {
+ for (int j = 0; j < N; j++)
+ System.out.print(" " + board[i][j]
+ + " ");
+ System.out.println();
+ }
+ }
+}
diff --git a/Recursion/Parenstheses/build.xml b/Recursion/Parenstheses/build.xml
new file mode 100644
index 0000000..e39d6c8
--- /dev/null
+++ b/Recursion/Parenstheses/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project Parenstheses.
+
+
+
diff --git a/Recursion/Parenstheses/manifest.mf b/Recursion/Parenstheses/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/Parenstheses/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/Parenstheses/nbproject/build-impl.xml b/Recursion/Parenstheses/nbproject/build-impl.xml
new file mode 100644
index 0000000..4a54f48
--- /dev/null
+++ b/Recursion/Parenstheses/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/Parenstheses/nbproject/genfiles.properties b/Recursion/Parenstheses/nbproject/genfiles.properties
new file mode 100644
index 0000000..709a137
--- /dev/null
+++ b/Recursion/Parenstheses/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=b54f3b94
+build.xml.script.CRC32=699180b3
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=b54f3b94
+nbproject/build-impl.xml.script.CRC32=ff0fdd9f
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/Parenstheses/nbproject/project.properties b/Recursion/Parenstheses/nbproject/project.properties
new file mode 100644
index 0000000..2264e68
--- /dev/null
+++ b/Recursion/Parenstheses/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Parenstheses.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=parenstheses.Parenstheses
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/Parenstheses/nbproject/project.xml b/Recursion/Parenstheses/nbproject/project.xml
new file mode 100644
index 0000000..e40c10e
--- /dev/null
+++ b/Recursion/Parenstheses/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ Parenstheses
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/Parenstheses/src/parenstheses/Parenstheses.java b/Recursion/Parenstheses/src/parenstheses/Parenstheses.java
new file mode 100644
index 0000000..a0c7d2f
--- /dev/null
+++ b/Recursion/Parenstheses/src/parenstheses/Parenstheses.java
@@ -0,0 +1,60 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package parenstheses;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Implement an algorithm to print all valid(i.e. properly opened and closed)
+ * combinations of n pairs of parentheses
+ * @author souravpalit
+ */
+public class Parenstheses {
+
+ /**
+ * Here thee solution will produce duplicates. So we are using set to
+ * remove the duplicates
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ Set parens = generateParen(3);
+
+ for (String paren : parens) {
+ System.out.println(paren);
+ }
+ }
+
+ public static Set generateParen(int n) {
+ Set set = new HashSet();
+
+ if (n == 0) {
+ set.add("");
+ } else {
+ Set prev = generateParen(n - 1);
+
+ for (String str : prev) {
+ for (int i = 0; i < str.length(); i++) {
+ if (str.charAt(0) == '(') {
+ String s = insertInside(str, i);
+ set.add(s);
+ }
+ }
+
+ set.add("()" + str);
+ }
+ }
+
+ return set;
+ }
+
+ public static String insertInside(String str, int leftIndex) {
+ String left = str.substring(0, leftIndex + 1);
+ String right = str.substring(leftIndex + 1, str.length());
+ return left + "()" + right;
+ }
+
+}
diff --git a/Recursion/Parenstheses/src/parenstheses/ParenthesesOptimized.java b/Recursion/Parenstheses/src/parenstheses/ParenthesesOptimized.java
new file mode 100644
index 0000000..da70cd6
--- /dev/null
+++ b/Recursion/Parenstheses/src/parenstheses/ParenthesesOptimized.java
@@ -0,0 +1,51 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package parenstheses;
+
+import java.util.ArrayList;
+import java.util.Set;
+import static parenstheses.Parenstheses.generateParen;
+
+/**
+ * Implement an algorithm to print all valid(i.e. properly opened and closed)
+ * combinations of n pairs of parentheses
+ * @author souravpalit
+ */
+public class ParenthesesOptimized {
+
+ public static void main(String[] args) {
+
+ ArrayList parenthese = generateParen(3);
+ for (String paren : parenthese) {
+ System.out.println(paren);
+ }
+ }
+
+ public static ArrayList generateParen(int count) {
+ ArrayList list = new ArrayList();
+ char [] brackets = new char [count * 2];
+ addParen(list, count, count, brackets, 0);
+ return list;
+ }
+
+ public static void addParen(ArrayList list,
+ int leftRem, int rightRem, char [] brackets, int index) {
+ if (leftRem < 0 || rightRem < leftRem) return; // invalid expression
+
+ if (leftRem == 0 && rightRem == 0) {
+ list.add(String.copyValueOf(brackets));
+ } else {
+ brackets[index] = '(';
+ addParen(list, leftRem - 1, rightRem, brackets, index + 1);
+
+ brackets[index] = ')';
+ addParen(list, leftRem, rightRem - 1, brackets, index + 1);
+ }
+
+ }
+
+
+}
diff --git a/Recursion/Permutation/build.xml b/Recursion/Permutation/build.xml
new file mode 100644
index 0000000..b830bb3
--- /dev/null
+++ b/Recursion/Permutation/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project Permutation.
+
+
+
diff --git a/Recursion/Permutation/manifest.mf b/Recursion/Permutation/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/Permutation/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/Permutation/nbproject/build-impl.xml b/Recursion/Permutation/nbproject/build-impl.xml
new file mode 100644
index 0000000..346720d
--- /dev/null
+++ b/Recursion/Permutation/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/Permutation/nbproject/genfiles.properties b/Recursion/Permutation/nbproject/genfiles.properties
new file mode 100644
index 0000000..f78449a
--- /dev/null
+++ b/Recursion/Permutation/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=b907ccc6
+build.xml.script.CRC32=af089939
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=b907ccc6
+nbproject/build-impl.xml.script.CRC32=25bbd6c5
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/Permutation/nbproject/project.properties b/Recursion/Permutation/nbproject/project.properties
new file mode 100644
index 0000000..b64482a
--- /dev/null
+++ b/Recursion/Permutation/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Permutation.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=permutation.Permutation
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/Permutation/nbproject/project.xml b/Recursion/Permutation/nbproject/project.xml
new file mode 100644
index 0000000..be39ef3
--- /dev/null
+++ b/Recursion/Permutation/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ Permutation
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/Permutation/src/permutation/Permutation.java b/Recursion/Permutation/src/permutation/Permutation.java
new file mode 100644
index 0000000..241757f
--- /dev/null
+++ b/Recursion/Permutation/src/permutation/Permutation.java
@@ -0,0 +1,58 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package permutation;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * @author souravpalit
+ */
+public class Permutation {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ String input = "ABC";
+ ArrayList allPermutation = calculate(input, input.length());
+
+ for (String item : allPermutation) {
+ System.out.println(item);
+ }
+ }
+
+ public static ArrayList calculate(String input, int n) {
+
+ if (n == 1) {
+ ArrayList list = new ArrayList();
+ list.add(String.valueOf(input.charAt(n-1)));
+ return list;
+ }
+
+ ArrayList items = calculate(input, n-1);
+ ArrayList newItems = insert(items, input.charAt(n-1));
+ return newItems;
+ }
+
+
+ public static ArrayList insert(ArrayList items, char c) {
+ ArrayList newItems = new ArrayList<>();
+
+ for (String item : items) {
+ // Loop will go from 0 to length because we need to add at the end also
+ for (int i = 0; i <= item.length(); i++) {
+ newItems.add(addChar(item, c, i));
+ }
+ }
+
+ return newItems;
+ }
+
+ public static String addChar(String str, char ch, int position) {
+ return str.substring(0, position) + ch + str.substring(position);
+ }
+}
diff --git a/Recursion/Permutation/src/permutation/PermutationAlternate.java b/Recursion/Permutation/src/permutation/PermutationAlternate.java
new file mode 100644
index 0000000..6f432f0
--- /dev/null
+++ b/Recursion/Permutation/src/permutation/PermutationAlternate.java
@@ -0,0 +1,41 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package permutation;
+
+/**
+ *
+ * @author souravpalit
+ */
+public class PermutationAlternate {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ String input = "ABCD";
+
+ calculate(input, 0, input.length());
+ }
+
+ public static void calculate(String input, int left, int right) {
+ if (left == right) {
+ System.out.println(input);
+ } else {
+ for (int i = left; i < right; i++) {
+ String swapped = swap(input, left, i);
+ calculate(swapped, left + 1, right);
+ }
+ }
+ }
+
+ public static String swap(String input, int first, int second) {
+ char [] inputChars = input.toCharArray();
+ char temp = inputChars[first];
+ inputChars[first] = inputChars[second];
+ inputChars[second] = temp;
+ return String.valueOf(inputChars);
+ }
+}
diff --git a/Recursion/PowerSet/build.xml b/Recursion/PowerSet/build.xml
new file mode 100644
index 0000000..1236204
--- /dev/null
+++ b/Recursion/PowerSet/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project PowerSet.
+
+
+
diff --git a/Recursion/PowerSet/manifest.mf b/Recursion/PowerSet/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/PowerSet/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/PowerSet/nbproject/build-impl.xml b/Recursion/PowerSet/nbproject/build-impl.xml
new file mode 100644
index 0000000..763095b
--- /dev/null
+++ b/Recursion/PowerSet/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/PowerSet/nbproject/genfiles.properties b/Recursion/PowerSet/nbproject/genfiles.properties
new file mode 100644
index 0000000..f158930
--- /dev/null
+++ b/Recursion/PowerSet/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=77f50b43
+build.xml.script.CRC32=67a3b60e
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=77f50b43
+nbproject/build-impl.xml.script.CRC32=efbccc41
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/PowerSet/nbproject/project.properties b/Recursion/PowerSet/nbproject/project.properties
new file mode 100644
index 0000000..48501f9
--- /dev/null
+++ b/Recursion/PowerSet/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/PowerSet.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=powerset.PowerSet
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/PowerSet/nbproject/project.xml b/Recursion/PowerSet/nbproject/project.xml
new file mode 100644
index 0000000..ccdb5e8
--- /dev/null
+++ b/Recursion/PowerSet/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ PowerSet
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/PowerSet/src/powerset/PowerSet.java b/Recursion/PowerSet/src/powerset/PowerSet.java
new file mode 100644
index 0000000..e566a7b
--- /dev/null
+++ b/Recursion/PowerSet/src/powerset/PowerSet.java
@@ -0,0 +1,66 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package powerset;
+
+import java.util.ArrayList;
+
+/**
+ * Power Set: Write a method to return all subsets of a set.
+ * @author souravpalit
+ */
+public class PowerSet {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+
+ ArrayList set = new ArrayList<>();
+ set.add("a");
+ set.add("b");
+ set.add("c");
+
+ ArrayList> allSubsets = getSubsets(set, 0);
+
+ for (ArrayList subset : allSubsets) {
+
+ if (subset.size() == 0) {
+ System.out.println("{}");
+ } else {
+ System.out.print("{");
+ for (String element : subset) {
+ System.out.print(" " + element + " ");
+ }
+ System.out.println("}");
+ }
+
+ }
+ }
+
+ private static ArrayList> getSubsets(ArrayList set, int index) {
+ ArrayList> allSubsets;
+
+ if (set.size() == index) {
+ allSubsets = new ArrayList<>();
+ allSubsets.add(new ArrayList<>());
+ } else {
+ allSubsets = getSubsets(set, index + 1);
+ String item = set.get(index);
+ ArrayList> moreSubsets = new ArrayList<>();
+
+ for (ArrayList subset : allSubsets) {
+ ArrayList newSubset = new ArrayList<>();
+ newSubset.addAll(subset);
+ newSubset.add(item);
+ moreSubsets.add(newSubset);
+ }
+
+ allSubsets.addAll(moreSubsets);
+ }
+
+ return allSubsets;
+ }
+}
diff --git a/Recursion/PowerSet/src/powerset/PowerSetAlternate.java b/Recursion/PowerSet/src/powerset/PowerSetAlternate.java
new file mode 100644
index 0000000..c84d9e7
--- /dev/null
+++ b/Recursion/PowerSet/src/powerset/PowerSetAlternate.java
@@ -0,0 +1,64 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package powerset;
+
+import java.util.ArrayList;
+
+/**
+ * Power Set: Write a method to return all subsets of a set.
+ * @author souravpalit
+ */
+public class PowerSetAlternate {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+
+ ArrayList set = new ArrayList<>();
+ set.add("a");
+ set.add("b");
+ set.add("c");
+ ArrayList> moreSubsets = new ArrayList<>();
+ moreSubsets.add(new ArrayList());
+ ArrayList> allSubsets = getSubsets(set,moreSubsets, 0);
+
+ for (ArrayList subset : allSubsets) {
+
+ if (subset.size() == 0) {
+ System.out.println("{}");
+ } else {
+ System.out.print("{");
+ for (String element : subset) {
+ System.out.print(" " + element + " ");
+ }
+ System.out.println("}");
+ }
+
+ }
+ }
+
+ private static ArrayList> getSubsets(ArrayList set,
+ ArrayList> allSubsets, int index) {
+ if (index < set.size()) {
+ String item = set.get(index);
+ ArrayList> moreSubsets = new ArrayList<>();
+
+ for (ArrayList subset : allSubsets) {
+ ArrayList newSubset = new ArrayList<>();
+ newSubset.addAll(subset);
+ newSubset.add(item);
+ moreSubsets.add(newSubset);
+ }
+
+ allSubsets.addAll(moreSubsets);
+
+ getSubsets(set, allSubsets, index + 1);
+ }
+
+ return allSubsets;
+ }
+}
diff --git a/Recursion/PowerSet/src/powerset/PowerSetBitModificationSolution.java b/Recursion/PowerSet/src/powerset/PowerSetBitModificationSolution.java
new file mode 100644
index 0000000..94da0cd
--- /dev/null
+++ b/Recursion/PowerSet/src/powerset/PowerSetBitModificationSolution.java
@@ -0,0 +1,36 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package powerset;
+
+import java.util.ArrayList;
+
+/**
+ * Power Set: Write a method to return all subsets of a set.
+ * @author souravpalit
+ */
+public class PowerSetBitModificationSolution {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+
+ ArrayList set = new ArrayList<>();
+ set.add("a");
+ set.add("b");
+ set.add("c");
+
+ for (int i = 0; i < 1 << set.size(); i++) {
+ System.out.print("{");
+ for (int j = 0; j < set.size(); j++) {
+ if ((i & (1 << j)) > 0) {
+ System.out.print(set.get(j));
+ }
+ }
+ System.out.println("}");
+ }
+ }
+}
diff --git a/Recursion/README.md b/Recursion/README.md
new file mode 100644
index 0000000..9c8ba74
--- /dev/null
+++ b/Recursion/README.md
@@ -0,0 +1 @@
+# Java-DataStructure-Algorithm-Problem
\ No newline at end of file
diff --git a/Recursion/RecursiveMultiply/build.xml b/Recursion/RecursiveMultiply/build.xml
new file mode 100644
index 0000000..67a4fb9
--- /dev/null
+++ b/Recursion/RecursiveMultiply/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project RecursiveMultiply.
+
+
+
diff --git a/Recursion/RecursiveMultiply/manifest.mf b/Recursion/RecursiveMultiply/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/RecursiveMultiply/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/RecursiveMultiply/nbproject/build-impl.xml b/Recursion/RecursiveMultiply/nbproject/build-impl.xml
new file mode 100644
index 0000000..00498f5
--- /dev/null
+++ b/Recursion/RecursiveMultiply/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/RecursiveMultiply/nbproject/genfiles.properties b/Recursion/RecursiveMultiply/nbproject/genfiles.properties
new file mode 100644
index 0000000..df8aab9
--- /dev/null
+++ b/Recursion/RecursiveMultiply/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=c300008b
+build.xml.script.CRC32=bfcba090
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=c300008b
+nbproject/build-impl.xml.script.CRC32=7c52ce99
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/RecursiveMultiply/nbproject/project.properties b/Recursion/RecursiveMultiply/nbproject/project.properties
new file mode 100644
index 0000000..3416e24
--- /dev/null
+++ b/Recursion/RecursiveMultiply/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/RecursiveMultiply.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=recursivemultiply.RecursiveMultiply
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/RecursiveMultiply/nbproject/project.xml b/Recursion/RecursiveMultiply/nbproject/project.xml
new file mode 100644
index 0000000..7a5315f
--- /dev/null
+++ b/Recursion/RecursiveMultiply/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ RecursiveMultiply
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/RecursiveMultiply/src/recursivemultiply/RecursiveMultiply.java b/Recursion/RecursiveMultiply/src/recursivemultiply/RecursiveMultiply.java
new file mode 100644
index 0000000..af05e7e
--- /dev/null
+++ b/Recursion/RecursiveMultiply/src/recursivemultiply/RecursiveMultiply.java
@@ -0,0 +1,47 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package recursivemultiply;
+
+/**
+ * RecursiveMulltiply
+ * @author souravpalit
+ */
+public class RecursiveMultiply {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ // TODO code application logic here
+ int a = 7;
+ int b = 17;
+ System.out.print("Multiplication result of " + a + " and " + b +" is : ");
+ multiply(a,b,0);
+ }
+
+ private static void multiply(int a, int b, int result) {
+ if (result == 0 && (a == 0 || b == 0)) {
+ System.out.println("0");
+ } else if (result == 0 && a == 1) {
+ System.out.println(b);
+ } else if (b == 1 && result == 0) {
+ System.out.println(a);
+ } else if (b == 0) {
+ System.out.println(result);
+ } else {
+
+ if ( b % 2 == 1) {
+ result = result + a;
+ }
+ a = a << 1;
+ b = b >> 1;
+
+
+
+ multiply(a,b,result);
+ }
+ }
+}
diff --git a/Recursion/RecursiveMultiply/src/recursivemultiply/RecursiveMultiplyAlternate.java b/Recursion/RecursiveMultiply/src/recursivemultiply/RecursiveMultiplyAlternate.java
new file mode 100644
index 0000000..c2290e7
--- /dev/null
+++ b/Recursion/RecursiveMultiply/src/recursivemultiply/RecursiveMultiplyAlternate.java
@@ -0,0 +1,49 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package recursivemultiply;
+
+/**
+ * RecursiveMulltiply
+ * @author souravpalit
+ */
+public class RecursiveMultiplyAlternate {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ // TODO code application logic here
+ int a = 5;
+ int b = 13;
+ int result = minProduct(a,b);
+
+ System.out.print("Multiplication result of " + a + " and " + b +" is : " + result);
+ }
+
+ static int minProduct(int a, int b) {
+ int bigger = a < b ? b : a;
+ int smaller = a < b ? a : b;
+ return minProductHelper(smaller, bigger);
+ }
+
+ static int minProductHelper(int smaller, int bigger) {
+ if (smaller == 0) {
+ return 0;
+ } else if (smaller == 1) {
+ return bigger;
+ }
+
+ int s = smaller >> 1;
+ int side1 = minProduct(s, bigger);
+ int side2 = side1;
+ if (smaller % 2 == 1) {
+ side2 = minProductHelper(smaller - s, bigger);
+ }
+
+ return side1 + side2;
+ }
+
+}
diff --git a/Recursion/RobotOnGrid/build.xml b/Recursion/RobotOnGrid/build.xml
new file mode 100644
index 0000000..05ab4f2
--- /dev/null
+++ b/Recursion/RobotOnGrid/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project RobotOnGrid.
+
+
+
diff --git a/Recursion/RobotOnGrid/manifest.mf b/Recursion/RobotOnGrid/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/RobotOnGrid/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/RobotOnGrid/nbproject/build-impl.xml b/Recursion/RobotOnGrid/nbproject/build-impl.xml
new file mode 100644
index 0000000..c25d70e
--- /dev/null
+++ b/Recursion/RobotOnGrid/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/RobotOnGrid/nbproject/genfiles.properties b/Recursion/RobotOnGrid/nbproject/genfiles.properties
new file mode 100644
index 0000000..2fe2d65
--- /dev/null
+++ b/Recursion/RobotOnGrid/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=9c1d725c
+build.xml.script.CRC32=5e8cdf20
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=9c1d725c
+nbproject/build-impl.xml.script.CRC32=9d8dd32e
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/RobotOnGrid/nbproject/project.properties b/Recursion/RobotOnGrid/nbproject/project.properties
new file mode 100644
index 0000000..4fe73bc
--- /dev/null
+++ b/Recursion/RobotOnGrid/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/RobotOnGrid.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=robotongrid.RobotOnGrid
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/RobotOnGrid/nbproject/project.xml b/Recursion/RobotOnGrid/nbproject/project.xml
new file mode 100644
index 0000000..c086f91
--- /dev/null
+++ b/Recursion/RobotOnGrid/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ RobotOnGrid
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/RobotOnGrid/src/robotongrid/RobotOnGrid.java b/Recursion/RobotOnGrid/src/robotongrid/RobotOnGrid.java
new file mode 100644
index 0000000..4f02a42
--- /dev/null
+++ b/Recursion/RobotOnGrid/src/robotongrid/RobotOnGrid.java
@@ -0,0 +1,85 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package robotongrid;
+
+/**
+ * Imagine a robot sitting on the left corner of grid with r rows and c columns.
+ * The robot can only move in two directions, right and down, but certain cells are
+ * "off limits" such that the robot cannot step on them. Design an algorithm to find
+ * a path for the robot from the top left to the bottom right.
+ *
+ * Lets consider cell value 0 means empty cell and 2 means blocked cell and 1 is
+ * valid move.
+ * @author souravpalit
+ */
+public class RobotOnGrid {
+
+ public static void main(String[] args) {
+ // TODO code application logic here
+
+ /*int board [][] = {
+ {0,0,0,0},
+ {0,0,0,2},
+ {0,2,0,2},
+ {2,0,0,0}};*/
+
+ int board [][] = {
+ {0,0,0,0},
+ {0,0,2,0},
+ {2,0,0,2},
+ {0,2,0,0}};
+
+ /*int board [][] = {
+ {0,2,0,0},
+ {0,2,2,0},
+ {0,0,0,2},
+ {0,0,0,0}};*/
+
+ if (hasPath(board, 0, 0)) {
+ printSolution(board);
+ } else {
+ System.out.println("There is no way to reach the desinatioon");
+ }
+ }
+
+ private static boolean hasPath(int board[][], int row, int col) {
+
+ if (col >= board[0].length || board[row][col] != 0) {
+ return false;
+ }
+
+ for (int i = row; i < board.length; i++) {
+ board[i][col] = 1;
+
+ if (isAtDestination(board, i, col) ||
+ hasPath(board, i, col + 1) ||
+ hasPath(board, i+ 1, col)) {
+ return true;
+ } else {
+ // We are setting 3 so that next time we don't need to visit or calculate for this position as
+ // we already visited
+ board[i][col] = 3;
+ return false;
+ }
+ }
+
+ return false;
+ }
+
+ private static boolean isAtDestination(int[][] board, int row, int col) {
+ return row == board.length -1 && col == board[0].length -1;
+ }
+
+ /* A utility function to print solution */
+ private static void printSolution(int board[][]) {
+ for (int i = 0; i < board.length; i++) {
+ for (int j = 0; j < board[0].length; j++)
+ System.out.print(" " + board[i][j]
+ + " ");
+ System.out.println();
+ }
+ }
+}
diff --git a/Recursion/StackOfBoxes/build.xml b/Recursion/StackOfBoxes/build.xml
new file mode 100644
index 0000000..e3d262f
--- /dev/null
+++ b/Recursion/StackOfBoxes/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project StackOfBoxes.
+
+
+
diff --git a/Recursion/StackOfBoxes/manifest.mf b/Recursion/StackOfBoxes/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/StackOfBoxes/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/StackOfBoxes/nbproject/build-impl.xml b/Recursion/StackOfBoxes/nbproject/build-impl.xml
new file mode 100644
index 0000000..5d53da4
--- /dev/null
+++ b/Recursion/StackOfBoxes/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/StackOfBoxes/nbproject/genfiles.properties b/Recursion/StackOfBoxes/nbproject/genfiles.properties
new file mode 100644
index 0000000..34b3f1a
--- /dev/null
+++ b/Recursion/StackOfBoxes/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=6b3bdedf
+build.xml.script.CRC32=b8e9f917
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=6b3bdedf
+nbproject/build-impl.xml.script.CRC32=f2fe1c9b
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/StackOfBoxes/nbproject/project.properties b/Recursion/StackOfBoxes/nbproject/project.properties
new file mode 100644
index 0000000..503868c
--- /dev/null
+++ b/Recursion/StackOfBoxes/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/StackOfBoxes.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=stackofboxes.StackOfBoxes
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/StackOfBoxes/nbproject/project.xml b/Recursion/StackOfBoxes/nbproject/project.xml
new file mode 100644
index 0000000..c3da4e3
--- /dev/null
+++ b/Recursion/StackOfBoxes/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ StackOfBoxes
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/StackOfBoxes/src/stackofboxes/Box.java b/Recursion/StackOfBoxes/src/stackofboxes/Box.java
new file mode 100644
index 0000000..0d019e3
--- /dev/null
+++ b/Recursion/StackOfBoxes/src/stackofboxes/Box.java
@@ -0,0 +1,51 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package stackofboxes;
+
+/**
+ *
+ * @author souravpalit
+ */
+public class Box {
+
+ private int length;
+ private int width;
+ private int height;
+
+ public Box(int length, int width, int height) {
+ this.length = length;
+ this.width = width;
+ this.height = height;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public void setLength(int length) {
+ this.length = length;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ public boolean canPlaceAbove(Box box) {
+ return (box.length >= length && box.width >= width && box.height >= height);
+ }
+}
diff --git a/Recursion/StackOfBoxes/src/stackofboxes/BoxComparator.java b/Recursion/StackOfBoxes/src/stackofboxes/BoxComparator.java
new file mode 100644
index 0000000..cc366c0
--- /dev/null
+++ b/Recursion/StackOfBoxes/src/stackofboxes/BoxComparator.java
@@ -0,0 +1,21 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package stackofboxes;
+
+import java.util.Comparator;
+
+/**
+ *
+ * @author souravpalit
+ */
+public class BoxComparator implements Comparator {
+
+ @Override
+ public int compare(Box o1, Box o2) {
+ return o2.getHeight() - o1.getHeight();
+ }
+
+}
diff --git a/Recursion/StackOfBoxes/src/stackofboxes/StackOfBoxes.java b/Recursion/StackOfBoxes/src/stackofboxes/StackOfBoxes.java
new file mode 100644
index 0000000..dda6615
--- /dev/null
+++ b/Recursion/StackOfBoxes/src/stackofboxes/StackOfBoxes.java
@@ -0,0 +1,59 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package stackofboxes;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ * @author souravpalit
+ */
+public class StackOfBoxes {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ ArrayList boxes = new ArrayList();
+ boxes.add(new Box(4, 5, 5));
+ boxes.add(new Box(4, 6, 6));
+ boxes.add(new Box(5, 5, 7));
+ boxes.add(new Box(7, 7, 8));
+ boxes.add(new Box(4, 4, 6));
+
+ System.out.println(createStack(boxes));
+ }
+
+ public static int createStack(ArrayList boxs) {
+ Collections.sort(boxs, new BoxComparator());
+ int maxHeight = 0;
+
+ for ( int i = 0; i < boxs.size(); i++) {
+ int height = createStack(boxs, i);
+ maxHeight = Math.max(maxHeight, height);
+ }
+
+ return maxHeight;
+ }
+
+ public static int createStack(ArrayList boxs, int index) {
+ Box bottom = boxs.get(index);
+ int maxHeight = 0;
+
+ for (int i = index + 1; i < boxs.size(); i++) {
+ if (boxs.get(i).canPlaceAbove(bottom)) {
+ int height = createStack(boxs, i);
+ maxHeight = Math.max(height, maxHeight);
+ }
+ }
+
+ maxHeight += bottom.getHeight();
+ return maxHeight;
+ }
+
+}
diff --git a/Recursion/StackOfBoxes/src/stackofboxes/StackOfBoxesOptimized.java b/Recursion/StackOfBoxes/src/stackofboxes/StackOfBoxesOptimized.java
new file mode 100644
index 0000000..0a4ed49
--- /dev/null
+++ b/Recursion/StackOfBoxes/src/stackofboxes/StackOfBoxesOptimized.java
@@ -0,0 +1,65 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package stackofboxes;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ * @author souravpalit
+ */
+public class StackOfBoxesOptimized {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ ArrayList boxes = new ArrayList();
+ boxes.add(new Box(4, 5, 5));
+ boxes.add(new Box(4, 6, 6));
+ boxes.add(new Box(5, 5, 7));
+ boxes.add(new Box(7, 7, 8));
+ boxes.add(new Box(4, 4, 6));
+
+ System.out.println(createStack(boxes));
+ }
+
+ public static int createStack(ArrayList boxes) {
+ Collections.sort(boxes, new BoxComparator());
+ int maxHeight = 0;
+ int [] memory = new int [boxes.size()];
+
+ for ( int i = 0; i < boxes.size(); i++) {
+ int height = createStack(boxes, i, memory);
+ maxHeight = Math.max(maxHeight, height);
+ }
+
+ return maxHeight;
+ }
+
+ public static int createStack(ArrayList boxes, int index, int [] memory) {
+ if (index < boxes.size() && memory[index] > 0) {
+ return memory[index];
+ }
+
+ Box bottom = boxes.get(index);
+ int maxHeight = 0;
+
+ for (int i = index + 1; i < boxes.size(); i++) {
+ if (boxes.get(i).canPlaceAbove(bottom)) {
+ int height = createStack(boxes, i, memory);
+ maxHeight = Math.max(height, maxHeight);
+ }
+ }
+
+ maxHeight += bottom.getHeight();
+ memory[index] = maxHeight;
+ return maxHeight;
+ }
+
+}
diff --git a/Recursion/TowerOfHanoi/build.xml b/Recursion/TowerOfHanoi/build.xml
new file mode 100644
index 0000000..fe261f8
--- /dev/null
+++ b/Recursion/TowerOfHanoi/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project TowerOfHanoi.
+
+
+
diff --git a/Recursion/TowerOfHanoi/manifest.mf b/Recursion/TowerOfHanoi/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/TowerOfHanoi/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/TowerOfHanoi/nbproject/build-impl.xml b/Recursion/TowerOfHanoi/nbproject/build-impl.xml
new file mode 100644
index 0000000..dabb7a8
--- /dev/null
+++ b/Recursion/TowerOfHanoi/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/TowerOfHanoi/nbproject/genfiles.properties b/Recursion/TowerOfHanoi/nbproject/genfiles.properties
new file mode 100644
index 0000000..a1c836d
--- /dev/null
+++ b/Recursion/TowerOfHanoi/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=6249ae19
+build.xml.script.CRC32=0ff16481
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=6249ae19
+nbproject/build-impl.xml.script.CRC32=8d56eb3c
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/TowerOfHanoi/nbproject/project.properties b/Recursion/TowerOfHanoi/nbproject/project.properties
new file mode 100644
index 0000000..4ea4802
--- /dev/null
+++ b/Recursion/TowerOfHanoi/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/TowerOfHanoi.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=towerofhanoi.TowerOfHanoi
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/TowerOfHanoi/nbproject/project.xml b/Recursion/TowerOfHanoi/nbproject/project.xml
new file mode 100644
index 0000000..72eab17
--- /dev/null
+++ b/Recursion/TowerOfHanoi/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ TowerOfHanoi
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/TowerOfHanoi/src/towerofhanoi/TowerOfHanoi.java b/Recursion/TowerOfHanoi/src/towerofhanoi/TowerOfHanoi.java
new file mode 100644
index 0000000..29de85a
--- /dev/null
+++ b/Recursion/TowerOfHanoi/src/towerofhanoi/TowerOfHanoi.java
@@ -0,0 +1,50 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package towerofhanoi;
+
+import java.util.Stack;
+
+/**
+ * TowerOfHanoi classic problem
+ * @author souravpalit
+ */
+public class TowerOfHanoi {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ // To make the variable name similar to tower we use A,B,C
+ // instead of a,b,c.
+ Stack A = new Stack();
+ A.push(4);
+ A.push(3);
+ A.push(2);
+ A.push(1);
+
+ printStack(towerOfHanoi(A.size(), A, new Stack(), new Stack()));
+ }
+
+ private static Stack towerOfHanoi(int n, Stack A,
+ Stack C, Stack B) {
+ if (n == 1) {
+ C.push(A.pop());
+ return C;
+ }
+
+ towerOfHanoi(n-1, A, B, C);
+ C.push(A.pop());
+ towerOfHanoi(n-1, B, C, A);
+
+ return C;
+ }
+
+ private static void printStack(Stack stack) {
+ while (!stack.isEmpty()) {
+ System.out.println(stack.pop());
+ }
+ }
+}
diff --git a/Recursion/Triple Step/build.xml b/Recursion/Triple Step/build.xml
new file mode 100644
index 0000000..5c94b1e
--- /dev/null
+++ b/Recursion/Triple Step/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project Triple Step.
+
+
+
diff --git a/Recursion/Triple Step/manifest.mf b/Recursion/Triple Step/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Recursion/Triple Step/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Recursion/Triple Step/nbproject/build-impl.xml b/Recursion/Triple Step/nbproject/build-impl.xml
new file mode 100644
index 0000000..a0d2dda
--- /dev/null
+++ b/Recursion/Triple Step/nbproject/build-impl.xml
@@ -0,0 +1,1424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/Triple Step/nbproject/genfiles.properties b/Recursion/Triple Step/nbproject/genfiles.properties
new file mode 100644
index 0000000..bb4a6c3
--- /dev/null
+++ b/Recursion/Triple Step/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=a5d60bf6
+build.xml.script.CRC32=23bf0cd6
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=a5d60bf6
+nbproject/build-impl.xml.script.CRC32=fff19b6f
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/Recursion/Triple Step/nbproject/project.properties b/Recursion/Triple Step/nbproject/project.properties
new file mode 100644
index 0000000..2c134d8
--- /dev/null
+++ b/Recursion/Triple Step/nbproject/project.properties
@@ -0,0 +1,78 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Triple_Step.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.kotlin-runtime.jar=/Users/souravpalit/Library/Application Support/NetBeans/8.2/kotlinc/lib\\kotlin-runtime.jar
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+kotlinc.classpath=${file.reference.kotlin-runtime.jar}
+main.class=triple.step.TripleStep
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${kotlinc.classpath}:
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Recursion/Triple Step/nbproject/project.xml b/Recursion/Triple Step/nbproject/project.xml
new file mode 100644
index 0000000..23f8729
--- /dev/null
+++ b/Recursion/Triple Step/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ Triple Step
+
+
+
+
+
+
+
+
+
diff --git a/Recursion/Triple Step/src/triple/step/TripleStep.java b/Recursion/Triple Step/src/triple/step/TripleStep.java
new file mode 100644
index 0000000..9b58a73
--- /dev/null
+++ b/Recursion/Triple Step/src/triple/step/TripleStep.java
@@ -0,0 +1,38 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package triple.step;
+
+/**
+ * Problem Statement: A child is running up a staircase with n steps and can climb
+ * either 1 step, 2 step or 3 steps at a time. Implement a method to determine how
+ * many possible ways the child can run up the stairs
+ * @author souravpalit
+ */
+public class TripleStep {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ // TODO code application logic here
+ long stairCount = 37;
+
+ System.out.println("Number of ways the child can run up the stairs is : " + countWays(stairCount));
+ }
+
+ public static long countWays(long n) {
+
+ if (n == 0) {
+ return 1;
+ } else if (n < 0) {
+ return 0;
+ } else {
+ return countWays(n-1) + countWays(n-2) + countWays(n-3);
+ }
+
+ }
+
+}
diff --git a/Recursion/Triple Step/src/triple/step/TripleStepWithMemorization.java b/Recursion/Triple Step/src/triple/step/TripleStepWithMemorization.java
new file mode 100644
index 0000000..1308af0
--- /dev/null
+++ b/Recursion/Triple Step/src/triple/step/TripleStepWithMemorization.java
@@ -0,0 +1,39 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package triple.step;
+
+import java.util.Arrays;
+
+/**
+ *
+ * @author souravpalit
+ */
+public class TripleStepWithMemorization {
+
+ public static void main(String [] args) {
+
+ int stairCount = 5;
+
+ int[] memo = new int[stairCount + 1];
+ Arrays.fill(memo, -1);
+
+ System.out.println("Number of ways the child can run up the stairs is : " + countWays(stairCount, memo));
+ }
+
+ public static int countWays(int n, int [] memo) {
+
+ if (n < 0) {
+ return 0;
+ } else if (n == 0) {
+ return 1;
+ } else if(memo[n] > -1) {
+ return memo[n];
+ } else {
+ memo[n] = countWays(n-1, memo) + countWays(n-2, memo) + countWays(n-3, memo);
+ return memo[n];
+ }
+ }
+}