diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..0e5c983
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..d8c5dc8
--- /dev/null
+++ b/.project
@@ -0,0 +1,28 @@
+
+
+ Java-Questions-and-Solutions
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
+
+ 1633716613659
+
+ 30
+
+ org.eclipse.core.resources.regexFilterMatcher
+ node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
+
+
+
+
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 3f967d9..8818c0f 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,8 +1,9 @@
{
"java.project.sourcePaths": [
"Sorting",
+ "Pattern_Printing",
"Number Theory",
"Basic Codes",
- "Pattern_Printing"
+ "String Handling"
]
}
\ No newline at end of file
diff --git a/Basic Codes/Factorial.java b/Basic Codes/Factorial.java
index 8ee8b78..c061e71 100644
--- a/Basic Codes/Factorial.java
+++ b/Basic Codes/Factorial.java
@@ -16,4 +16,5 @@ static int factorialRecursion(int i){
return i*factorialRecursion(i-1);
}
+
}
\ No newline at end of file
diff --git a/Basic Codes/RootsOfQuadraticEqn.java b/Basic Codes/RootsOfQuadraticEqn.java
index 4b7ace8..68bf3dc 100644
--- a/Basic Codes/RootsOfQuadraticEqn.java
+++ b/Basic Codes/RootsOfQuadraticEqn.java
@@ -1,7 +1,7 @@
//Find the roots of the quadratic Equation
import java.util.Scanner;
-public class quadratic_roots {
+public class RootsOfQuadraticEqn {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
diff --git a/Data Structure/Trees/Binary Trees/CountingFullNodes.java b/Data Structure/Trees/Binary Trees/CountingFullNodes.java
new file mode 100644
index 0000000..2d0717d
--- /dev/null
+++ b/Data Structure/Trees/Binary Trees/CountingFullNodes.java
@@ -0,0 +1,42 @@
+
+//Question: Count all the full nodes(nodes whose left and right children are not null)
+
+//initializing node class
+class Node{
+ int key;
+ Node left,right;
+ public Node(int data) {
+ key=data;
+ left=right=null;
+ }
+}
+
+public class CountingFullNodes{
+ Node root;
+ CountingFullNodes(){
+ root=null;
+ }
+ //recursive function to get the count of full nodes
+ int getFullCount(Node node) {
+ if(node==null)
+ return 0;
+ int count=0;
+ if(node.left!=null && node.right!=null)
+ count++;
+ count+=(getFullCount(node.left)+getFullCount(node.right));
+ return count;
+ }
+ public static void main(String[] args) {
+ CountingFullNodes bs=new CountingFullNodes();
+ bs.root=new Node(1);
+ bs.root.left = new Node(7);
+ bs.root.right = new Node(3);
+ bs.root.left.right = new Node(6);
+ bs.root.left.right.left = new Node(2);
+ bs.root.left.right.right = new Node(4);
+ bs.root.right.right = new Node(9);
+ bs.root.right.right.left = new Node(11);
+ bs.root.right.right.right = new Node(10);
+ System.out.println(bs.getFullCount(bs.root));
+ }
+}
diff --git a/Number Theory/ArmstrongNumber.java b/Number Theory/ArmstrongNumber.java
index 5b2ea90..2424ba6 100644
--- a/Number Theory/ArmstrongNumber.java
+++ b/Number Theory/ArmstrongNumber.java
@@ -1,3 +1,5 @@
+import java.util.Scanner;
+
//Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers;
/* 153 = (1*1*1)+(5*5*5)+(3*3*3)
where:
@@ -29,6 +31,6 @@ public static void main(String[] args) {
} else {
System.out.println(temp + " is not a armstrong number");
}
-
+ in.close();
}
}
diff --git a/Pattern_Printing/Letter_T.java b/Pattern_Printing/Pattern_Printing/Letter_T.java
similarity index 100%
rename from Pattern_Printing/Letter_T.java
rename to Pattern_Printing/Pattern_Printing/Letter_T.java
diff --git a/Pattern_Printing/Letter_I.java b/Pattern_Printing/pattern_program/Letter_I.java
similarity index 97%
rename from Pattern_Printing/Letter_I.java
rename to Pattern_Printing/pattern_program/Letter_I.java
index ecb5b48..5cc9a6e 100644
--- a/Pattern_Printing/Letter_I.java
+++ b/Pattern_Printing/pattern_program/Letter_I.java
@@ -56,7 +56,7 @@ public static void main(String[] args) {
//taking user input
int patternHeight = sc.nextInt();
- if(height % 2 == 0) {
+ if(patternHeight % 2 == 0) {
System.out.println("Please specify any odd integer for a better view.");
} else {
printI(patternHeight);
diff --git a/Sorting/semisort1.java b/Sorting/semisort1.java
index 76742a7..4bcd1f8 100644
--- a/Sorting/semisort1.java
+++ b/Sorting/semisort1.java
@@ -59,7 +59,6 @@ public static void main(String[] args) throws IOException
{
ar[i]=Integer.parseInt(br.readLine());
}
- semisort1 obj= new semisort1(); //Program by LN11211
- obj.sort(ar,len,styl);
+ semisort1.sort(ar,len,styl);
}
}
\ No newline at end of file
diff --git a/String Handling/isomorphic.java b/String Handling/isomorphic.java
new file mode 100644
index 0000000..235f866
--- /dev/null
+++ b/String Handling/isomorphic.java
@@ -0,0 +1,40 @@
+
+
+class isomorphic {
+
+ static final int CHAR = 26;
+
+ static boolean isoMorphic(String str1, String str2)
+ {
+ int n = str1.length();
+ int m = str2.length();
+
+ if (n != m)
+ return false;
+
+ // For counting the previous appearances of character in both the strings
+ int[] countChars1 = new int[CHAR];
+ int[] countChars2 = new int[CHAR];
+
+ for (int i = 0; i < n; i++) {
+ countChars1[str1.charAt(i) - 'a']++;
+ countChars2[str2.charAt(i) - 'a']++;
+
+ if (countChars1[str1.charAt(i) - 'a']
+ != countChars2[str2.charAt(i) - 'a']) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ public static void main(String[] args)
+ {
+ System.out.println(isoMorphic("aab", "xxy") ? 1
+ : 0);
+ System.out.println(isoMorphic("aab", "xyz") ? 1
+ : 0);
+ }
+}
+
\ No newline at end of file
diff --git a/bin/Welcome.txt b/bin/Welcome.txt
new file mode 100644
index 0000000..e69de29