From 5ec507a32d00400aa98d1d47588f260bada6e905 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Tue, 4 May 2021 16:38:59 +0530 Subject: [PATCH] #Modification 29 --- backtracking/Word_Break_PUB.java | 41 +++++ binaryTree/BT_Problem_06_a.java | 2 +- binaryTree/BT_Problem_06_b.java | 110 ++++-------- binaryTree/BT_Problem_07.java | 15 -- binaryTree/BT_Problem_07_a.java | 55 ++++++ binaryTree/BT_Problem_07_b.java | 52 ++++++ binaryTree/BT_Problem_08.java | 10 -- binaryTree/BT_Problem_08_a.java | 90 ++++++++++ binaryTree/BT_Problem_08_b.java | 47 ++++++ dataStructures/graphs/Graph.class | Bin 1785 -> 0 bytes dataStructures/graphs/Graph.java | 41 ----- queues/ArrayDequeDemo.class | Bin 1272 -> 0 bytes stack/stack/Postfix.class | Bin 2162 -> 0 bytes .../Stack_Queue_Problem_03.class | Bin 1840 -> 0 bytes ...java_c181a202ca338689c15dd0c5b3b84d60.prob | 1 - string/Append.class | Bin 879 -> 0 bytes ...java_99fbe9a6d479d3fea744cafd49bd01c0.prob | 1 - ...java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob | 1 - trees/BST_Deletion$Node.class | Bin 569 -> 0 bytes trees/BST_Deletion.class | Bin 2628 -> 0 bytes trees/BST_Deletion.java | 158 ------------------ trees/BT_Traversal$Node.class | Bin 494 -> 0 bytes trees/BT_Traversal.class | Bin 2089 -> 0 bytes trees/BT_Traversal.java | 82 --------- trees/BinarySearchTree$Node.class | Bin 593 -> 0 bytes trees/BinarySearchTree.class | Bin 1542 -> 0 bytes trees/BinarySearchTree.java | 83 --------- trees/BinaryTreeNode.class | Bin 596 -> 0 bytes trees/BinaryTreeNode.java | 13 -- trees/BinaryTreeUse.class | Bin 2177 -> 0 bytes trees/BinaryTreeUse.java | 51 ------ trees/BinaryTree_LOT.class | Bin 1756 -> 0 bytes trees/BinaryTree_LOT.java | 99 ----------- trees/BinaryTree_Traversal$Node.class | Bin 617 -> 0 bytes trees/BinaryTree_Traversal.class | Bin 2227 -> 0 bytes trees/BinaryTree_Traversal.java | 96 ----------- trees/Binary_Tree_01.class | Bin 1756 -> 0 bytes trees/Binary_Tree_01.java | 89 ---------- ...truct_Tree_from_Preorder_and_Inorder.class | Bin 1436 -> 0 bytes ...struct_Tree_from_Preorder_and_Inorder.java | 69 -------- trees/Count_leaf_nodes$BinaryTreeNode.class | Bin 1617 -> 0 bytes trees/Count_leaf_nodes.class | Bin 400 -> 0 bytes trees/Count_leaf_nodes.java | 29 ---- trees/FindFullNodesInABinaryTree.class | Bin 1406 -> 0 bytes trees/FindFullNodesInABinaryTree.java | 55 ------ trees/Insertion_In_BinaryTree$Node.class | Bin 531 -> 0 bytes trees/Insertion_In_BinaryTree.class | Bin 2214 -> 0 bytes trees/Insertion_In_BinaryTree.java | 80 --------- trees/Node.class | Bin 390 -> 0 bytes trees/Problem_01$TreeNode.class | Bin 878 -> 0 bytes trees/Problem_01.class | Bin 1893 -> 0 bytes trees/Problem_01.java | 85 ---------- trees/trees/BinaryTree_Traversal$Node.class | Bin 554 -> 0 bytes trees/trees/BinaryTree_Traversal.class | Bin 2145 -> 0 bytes trees/trees/FindFullNodesInABinaryTree.class | Bin 1159 -> 0 bytes trees/trees/Node.class | Bin 339 -> 0 bytes 56 files changed, 316 insertions(+), 1139 deletions(-) create mode 100644 backtracking/Word_Break_PUB.java delete mode 100644 binaryTree/BT_Problem_07.java create mode 100644 binaryTree/BT_Problem_07_a.java create mode 100644 binaryTree/BT_Problem_07_b.java delete mode 100644 binaryTree/BT_Problem_08.java create mode 100644 binaryTree/BT_Problem_08_a.java create mode 100644 binaryTree/BT_Problem_08_b.java delete mode 100644 dataStructures/graphs/Graph.class delete mode 100644 dataStructures/graphs/Graph.java delete mode 100644 queues/ArrayDequeDemo.class delete mode 100644 stack/stack/Postfix.class delete mode 100644 stack_and_queue/stack_and_queue/Stack_Queue_Problem_03.class delete mode 100644 string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob delete mode 100644 string/Append.class delete mode 100644 trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob delete mode 100644 trees/.cph/.FindFullNodesInABinaryTree.java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob delete mode 100644 trees/BST_Deletion$Node.class delete mode 100644 trees/BST_Deletion.class delete mode 100644 trees/BST_Deletion.java delete mode 100644 trees/BT_Traversal$Node.class delete mode 100644 trees/BT_Traversal.class delete mode 100644 trees/BT_Traversal.java delete mode 100644 trees/BinarySearchTree$Node.class delete mode 100644 trees/BinarySearchTree.class delete mode 100644 trees/BinarySearchTree.java delete mode 100644 trees/BinaryTreeNode.class delete mode 100644 trees/BinaryTreeNode.java delete mode 100644 trees/BinaryTreeUse.class delete mode 100644 trees/BinaryTreeUse.java delete mode 100644 trees/BinaryTree_LOT.class delete mode 100644 trees/BinaryTree_LOT.java delete mode 100644 trees/BinaryTree_Traversal$Node.class delete mode 100644 trees/BinaryTree_Traversal.class delete mode 100644 trees/BinaryTree_Traversal.java delete mode 100644 trees/Binary_Tree_01.class delete mode 100644 trees/Binary_Tree_01.java delete mode 100644 trees/Construct_Tree_from_Preorder_and_Inorder.class delete mode 100644 trees/Construct_Tree_from_Preorder_and_Inorder.java delete mode 100644 trees/Count_leaf_nodes$BinaryTreeNode.class delete mode 100644 trees/Count_leaf_nodes.class delete mode 100644 trees/Count_leaf_nodes.java delete mode 100644 trees/FindFullNodesInABinaryTree.class delete mode 100644 trees/FindFullNodesInABinaryTree.java delete mode 100644 trees/Insertion_In_BinaryTree$Node.class delete mode 100644 trees/Insertion_In_BinaryTree.class delete mode 100644 trees/Insertion_In_BinaryTree.java delete mode 100644 trees/Node.class delete mode 100644 trees/Problem_01$TreeNode.class delete mode 100644 trees/Problem_01.class delete mode 100644 trees/Problem_01.java delete mode 100644 trees/trees/BinaryTree_Traversal$Node.class delete mode 100644 trees/trees/BinaryTree_Traversal.class delete mode 100644 trees/trees/FindFullNodesInABinaryTree.class delete mode 100644 trees/trees/Node.class diff --git a/backtracking/Word_Break_PUB.java b/backtracking/Word_Break_PUB.java new file mode 100644 index 0000000..5b48b5e --- /dev/null +++ b/backtracking/Word_Break_PUB.java @@ -0,0 +1,41 @@ +package backtracking; +import java.util.*; + +public class Word_Break_PUB { + + private static void backtrack(String sentence, String A, String sentence2, ArrayList result) { + + if(A.length() == 0) { + result.add(sentence); + return; + } + + for(int i = 0; i < A.length(); i++) { + + String substring = A.substring(0, i + 1); + + if(sentence2.contains(substring)) { + String newSentence = sentence + " " + substring; + backtrack(newSentence.trim(), A.substring( i + 1, A.length() ), sentence2, result); + } + } + } + + public static ArrayList wordBreak(String A, String sentence) { + ArrayList result = new ArrayList<>(); + backtrack("", A, sentence, result); + return result; + } + + public static void main(String[] args) { + + String sentence = "I Like mango icecream and SamSung Mobile"; + String A = null; + String[] result; + String[] dictionary = {"mobile", "samsung", "sam", "sung", "man", "mango", "icecream", "and", "go", "i", "like", + "icecream"}; + + System.out.println(wordBreak(A,sentence)); + } + +} diff --git a/binaryTree/BT_Problem_06_a.java b/binaryTree/BT_Problem_06_a.java index 9886cdd..6d7c25c 100644 --- a/binaryTree/BT_Problem_06_a.java +++ b/binaryTree/BT_Problem_06_a.java @@ -1,7 +1,7 @@ package binaryTree; import java.util.*; /* - * Problem Title :- In-order Traversal of a tree both using Recursion + * Problem Title :- In-order Traversal of a tree without using Recursion */ // Class to print the in-order traversal public class BT_Problem_06_a { diff --git a/binaryTree/BT_Problem_06_b.java b/binaryTree/BT_Problem_06_b.java index 1bb728f..cdace6c 100644 --- a/binaryTree/BT_Problem_06_b.java +++ b/binaryTree/BT_Problem_06_b.java @@ -1,98 +1,48 @@ package binaryTree; /* - * Problem Title :- In-order Traversal of a tree both using Recursion + * Problem Title :- In-order Traversal of a tree using Recursion */ public class BT_Problem_06_b { - // Root of Binary Tree - Node root; + Node root; + + // Constructor + BT_Problem_06_b(){ + root = null; + } - // Constructor - BT_Problem_06_b(){ - root = null; - } - - /* - * Given a binary tree, - * print its nodes according to the - * "bottom-up" post-order traversal. - */ - void printPostorder(Node node) { - if(node == null) - return; - // first recur on left subtree - printPostorder(node.left); - - // then recur on right subtree - printPostorder(node.right); - - // now deal with the node - System.out.print(node.data + " "); - } - - /* - * Given a binary tree, - * print its nodes in in-order - */ - void printInorder(Node node) { + //Given a binary tree, print its nodes in in-order + void printInorder(Node node) { - if(node == null) return; + if(node == null) return; - /* first recur on left child */ - printPreorder(node.left); + /* first recur on left child */ + printInorder(node.left); - /* then print data of node */ - System.out.print(node.data + " "); + /* then print data of node */ + System.out.print(node.data + " "); - /* now recur on right child */ - printPreorder(node.right); - } + /* now recur on right child */ + printInorder(node.right); + } - /* - * Given a binary tree, - * print its nodes in preorder - */ - void printPreorder(Node node) { - - if(node == null) return; - - /* first print data of node */ - System.out.print(node.data + " "); - - /* then recur on left subtree */ - printPreorder(node.left); - - /* now recur on right subtree */ - printPreorder(node.right); - } + // Wrappers over above recursive function + void printInorder() { printInorder(root); } - // Wrappers over above recursive functions - void printPostorder() { printPostorder(root);} - void printInorder() { printInorder(root); } - void printPreorder() { printPreorder(root); } - // Driver method - public static void main(String[] args) { + // Driver method + public static void main(String[] args) { - BT_Problem_06_b tree = new BT_Problem_06_b(); - - tree.root = new Node(1); - tree.root.left = new Node(2); - tree.root.right = new Node(3); - tree.root.left.left = new Node(4); - tree.root.left.right = new Node(5); - - System.out.println("Preorder traversal of binary tree is "); - tree.printPreorder(); + BT_Problem_06_b tree = new BT_Problem_06_b(); - System.out.println("\nInorder traversal of binary tree is "); - tree.printInorder(); + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); - System.out.println("\nPostorder traversal of binary tree is "); - tree.printPostorder(); - - } - - + System.out.println("\nInorder traversal of binary tree is "); + tree.printInorder(); + } } diff --git a/binaryTree/BT_Problem_07.java b/binaryTree/BT_Problem_07.java deleted file mode 100644 index 6d2485b..0000000 --- a/binaryTree/BT_Problem_07.java +++ /dev/null @@ -1,15 +0,0 @@ -package binaryTree; -/* Problem Title :- Write a Java program to find Left View of a tree - * - * Left View of a tree :- - * The left view of a binary tree, is set of nodes visible when tree is visited from left side - * between two end nodes. - */ - -public class BT_Problem_07 { - - public static void main(String[] args) { - - } - -} diff --git a/binaryTree/BT_Problem_07_a.java b/binaryTree/BT_Problem_07_a.java new file mode 100644 index 0000000..0c42b27 --- /dev/null +++ b/binaryTree/BT_Problem_07_a.java @@ -0,0 +1,55 @@ +package binaryTree; +import java.util.*; + +/* + * Problem Title :- Preorder Traversal of a tree without using Recursion or Iteratively + */ +public class BT_Problem_07_a { + + // Root of Binary Tree + Node root; + + // Given a binary tree, print its nodes in pre-order + void preorder() { + + if(root == null) return; + + Stack s = new Stack<>(); + s.push(root); + + // traverse the tree + while(s.empty() == false) { + + Node mynode = s.peek(); + System.out.print(mynode.data + " "); + + s.pop(); + + //Push right child of popped node to stack + if(mynode.right != null) + s.push(mynode.right); + + //Push left child of popped node to stack + if(mynode.left != null) + s.push(mynode.left); + + } + } + + // Driver method + public static void main(String[] args) { + + // creating a binary tree and entering the nodes + BT_Problem_07_a tree = new BT_Problem_07_a(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + tree.preorder(); + + } + +} diff --git a/binaryTree/BT_Problem_07_b.java b/binaryTree/BT_Problem_07_b.java new file mode 100644 index 0000000..bb10987 --- /dev/null +++ b/binaryTree/BT_Problem_07_b.java @@ -0,0 +1,52 @@ +package binaryTree; + +/* + * Problem Title :- Pre-order Traversal of a tree using Recursion + */ +public class BT_Problem_07_b { + // Root of Binary Tree + Node root; + + // Constructor + BT_Problem_07_b(){ + root = null; + } + + /* + * Given a binary tree, + * print its nodes in preorder + */ + void printPreorder(Node node) { + + if(node == null) return; + + /* first print data of node */ + System.out.print(node.data + " "); + + /* then recur on left subtree */ + printPreorder(node.left); + + /* now recur on right subtree */ + printPreorder(node.right); + } + + // Wrappers over above recursive function + void printPreorder() { + printPreorder(root); + } + + //Driver Code + public static void main(String[] args) { + BT_Problem_07_b tree = new BT_Problem_07_b(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Preorder traversal of binary tree is "); + tree.printPreorder(); + } + +} diff --git a/binaryTree/BT_Problem_08.java b/binaryTree/BT_Problem_08.java deleted file mode 100644 index c894fb8..0000000 --- a/binaryTree/BT_Problem_08.java +++ /dev/null @@ -1,10 +0,0 @@ -package binaryTree; -// Post-order Traversal of a tree both using recursion and Iteration -public class BT_Problem_08 { - - public static void main(String[] args) { - // TODO Auto-generated method stub - - } - -} diff --git a/binaryTree/BT_Problem_08_a.java b/binaryTree/BT_Problem_08_a.java new file mode 100644 index 0000000..3c20961 --- /dev/null +++ b/binaryTree/BT_Problem_08_a.java @@ -0,0 +1,90 @@ +package binaryTree; +import java.util.*; +/* + * Post-order Traversal of a tree both using recursion and Iteration + */ +public class BT_Problem_08_a { + + Node root; + ArrayList list = new ArrayList(); + + // An iterative function to do postorder traversal + // of a given binary tree + ArrayList postOrderIterative(Node node) + { + Stack S = new Stack(); + + // Check for empty tree + if (node == null) + return list; + S.push(node); + Node prev = null; + while (!S.isEmpty()) + { + Node current = S.peek(); + + /* go down the tree in search of a leaf an if so process it + and pop stack otherwise move down */ + if (prev == null || prev.left == current || + prev.right == current) + { + if (current.left != null) + S.push(current.left); + else if (current.right != null) + S.push(current.right); + else + { + S.pop(); + list.add(current.data); + } + + /* go up the tree from left node, if the child is right + push it onto stack otherwise process parent and pop + stack */ + } + else if (current.left == prev) + { + if (current.right != null) + S.push(current.right); + else + { + S.pop(); + list.add(current.data); + } + + /* go up the tree from right node and after coming back + from right node process parent and pop stack */ + } + else if (current.right == prev) + { + S.pop(); + list.add(current.data); + } + + prev = current; + } + + return list; + } + + // Driver program to test above functions + public static void main(String args[]) + { + BT_Problem_08_a tree = new BT_Problem_08_a(); + + // Let us create trees shown in above diagram + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + tree.root.right.left = new Node(6); + tree.root.right.right = new Node(7); + + ArrayList mylist = tree.postOrderIterative(tree.root); + + System.out.println("Post order traversal of binary tree is :"); + System.out.println(mylist); + } + +} diff --git a/binaryTree/BT_Problem_08_b.java b/binaryTree/BT_Problem_08_b.java new file mode 100644 index 0000000..7929743 --- /dev/null +++ b/binaryTree/BT_Problem_08_b.java @@ -0,0 +1,47 @@ +package binaryTree; + +public class BT_Problem_08_b { + + // Root of Binary Tree + Node root; + + // Constructor + BT_Problem_08_b(){ + root = null; + } + + // Given a binary tree, print its nodes according to the "bottom-up" post-order traversal. + void printPostorder(Node node) { + //base case + if(node == null) + return; + // first recur on left subtree + printPostorder(node.left); + + // then recur on right subtree + printPostorder(node.right); + + // now deal with the node + System.out.print(node.data + " "); + } + + // Wrapper over above recursive function + void printPostorder() { + printPostorder(root); + } + + //Driver Code + public static void main(String[] args) { + BT_Problem_08_b tree = new BT_Problem_08_b(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("\nPostorder traversal of binary tree is "); + tree.printPostorder(); + } + +} diff --git a/dataStructures/graphs/Graph.class b/dataStructures/graphs/Graph.class deleted file mode 100644 index 936e873e25aac7bbab364bcb9451ab9495058568..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1785 zcmaJ>-Bue_7~Lm-lZ1f)AwZjirazWIX``rA8;VLxOEiVrAeGjtLuLpAVUjg7Vd;IZ zeTQE4+AbShvg`x&J-qc1#C=Xe2`-iwGiT1vx4-@E{hfLH&mV69+{BKCfI!+be52yK zt*YO0Ew4~>jpnvjxGx6{A%VdiW8Wy$4X0LE-Q2ONzCh40cLc_smep3vx9f$n?d)1+ z+4lURK&)cd97Ey>%$$8{z7wlpOO9{VEVsD8(8#>)*#3e*C|{ad=WwTCT5$x?uOo&5 z=FU&8YZw$5IV*V#0>e7Oh{TaVzd(Y-td-W@rsb{~n{^TzE;p)1ecf;{4YCvad`f(5f&PkbRCga3%`SvynC6mMV}@|PMDB51z(ox?fuR!xyQS*5gv$cj zzEN*kt6Ku2to95=WD)P_xQa<7x+###_Z;i^QJi{0-MmK2tulF^X?ea)_3eg3`SuK( z!)U(ig3_CA+fJ=0b-aGePMKJ#8jfSRF%o znk}EGma$iiV+J2fujT~CyJY`!WNKYz_(aF2xW&2}EwbFvyU9~K0ifj0ijep{2CwQ@C*G{EIPr($USmV*-%1T(5(T@eLpGCW;9ZsXjyc;^6;Hf~=Z*(?!ZSuX1)>)-# z0?%}0kd-3*pyNk*)xy{ME>_PsL2qteXM~$-pqFm+A1d?4JSAIcAotvCKfIgl66N%Rt3f_K+ zir8$rJClq8 ziqU{NoMeU(f~0y_WZ$vKBCl8w6jO>t4AZ#QNhl^+O_X@MhnU%Tg&PO>sQd~yhl_38 zzShPa^;$TD*vK5<{;d%A4pG_|{^|e^vTdvmSK9cdjc<88I2V42v<#YysJC`5l!~OZ zHokiv7O8Od#nE3}|NcbKIf@60(?@xd6lYv1F+t%jV3B?<^Z&Mj%UHt|JmY+eJ3A~# ziv6fV8wNHx>tm}`VX~-kRQO1-vy8R)6=c+1#*VSnC89_x!rV(JVIoA2DPc5aI# V84(RN4KqSWo4{CsZRQEU{uf*Pfdl{m diff --git a/dataStructures/graphs/Graph.java b/dataStructures/graphs/Graph.java deleted file mode 100644 index 2ff08b8..0000000 --- a/dataStructures/graphs/Graph.java +++ /dev/null @@ -1,41 +0,0 @@ -package dataStructures.graphs; -import java.util.*; - -public class Graph { - - private LinkedList adj[]; - - @SuppressWarnings("unchecked") - public Graph(int v) { - //array of Linked List - adj = new LinkedList[v]; - - for(int i=0;i(); - } - } - - public void addEdge(int source, int destination) { - adj[source].add(destination); - adj[destination].add(source); - } - - public static void main(String[] args) { - Scanner sc = new Scanner(System.in); - - System.out.println("Enter number of vertices and edges"); - int v = sc.nextInt(); - int e = sc.nextInt(); - - Graph graph = new Graph(v); - System.out.println("Enter " + e + " edges"); - - for(int i=0;i(2_vbGFW{{WQVF>Lz+~L*af@Nuk8BS4# zmkkMC2LG;hpe0LMWjndHwaW`OL(iOE(d~JLu4pXJ;9WF|TtOFnD!S3b(4W;SeAOv$ zace`{DshHD)+lJDyk_YlZX~_-j$UOL%y#^EiW-+Sy}}TVzRvy!k+UtmvYm<%@Usj9 z?uBFPr6%kO{P4*bU|qh>%K!f+$mnEdFs-a6G~Xo%*IM6Im59E zd|4Mu6Kvhag!r2=0)j@H3wY>6>qb_hC`q1??;byb{K36e$ck&gi(ay7y?}flMLwKC zKV`(@pH$%?|MnRE%_G{@cpz9qC>}WP+6%6|6&tr{h7@kuk*vSx?7j()|#s|+YOiJ(%Q(}V>9=!Yun_edl diff --git a/stack/stack/Postfix.class b/stack/stack/Postfix.class deleted file mode 100644 index 9b2d1c0b7e9f6d54e1885e7829b17130e328d262..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2162 zcmaJ?TTdHD6#mAyHO>;7iwPkiAzW=PanevAF`-Eu2oC1bm_i_JlEn;oVZG~m*A!Z* zPyG>1UJ|trR4NZC4+eqM_PGz0`dFz_)SpqQN_xh&umP(Nb7tnuIdi`AowKvQy*v0B zz#zWz;4=CoTy-PlfeqIrT=&35EX1&c+d@4eHXjMA zJ03LQt{e9xM5=HfqaOG%Cd30F#wA3BMV~l(C{`05#4ssgiorFk>Z&!uU=IZ67#tB} znKO7}s?MjfsU@D7RhBf;IA$_DK~o?Sj51WmEhVu&sicdiXH|Vg-JCUM4AY_oLuVki zrfeu7P0?3FaVw+htKr~j6KlrtF1L(srZe0$ zRf7_(DT9R_&IRPVYPr2LEMw(%$LK0;FD*!0A^|3O< zw@izth%wRB{(`@1gra&nYmq%yQj}n0G1Q3z(e7@YZ(8ExJBj}&m@}anroe7wMY)ec z%+NPh3Q_1%3Q(pdrqaSl(e{qjT&V@a=Cha55-8o3# z;Z=8Y4(hcECNzFu*5CI@+b8_!7>e2q|V4%IKwLetq_ z;myJ43%o*25AACXK>w%M_WQSDLoR&<+fH#yUCDtq-=FaKvlQtYJKKK$tl-&JauRr4 zwe@d~1^TP!%@IX&^zQ>MPzDzX#wC(1L|rQp-A2FR4vY|46GYG>1d*gNY@iok;~HM# zI({JPcgbg;i2a3#{T*Taf!lbCJ9&zm;CY972{s8%_AgplovTd>{sV7gHLB>o?qbp7 zM7x7fbRELKu#1L0oQw73&^Srr{2`jC02iiqaj|zF#QmjG2Q^U@fiaxH1FG&g>hX{g gn4sV>x>EFtjo@z3?4eK=Hj%~oe80G9KR{#fKe%iG6aWAK diff --git a/stack_and_queue/stack_and_queue/Stack_Queue_Problem_03.class b/stack_and_queue/stack_and_queue/Stack_Queue_Problem_03.class deleted file mode 100644 index c55e8e086c1a5f8f86e12a3b1ce7adc6137eb0bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1840 zcmai#ZC4XV6vzLQY)D9!B!Xx)N`nIC!SblZ8tMbFNE8GctjFUEx{wi8lHF}~LrcFv zze3OHJKyw;Z`vd1p*{To{ZKvq&t`>CsGgj?GjnI={^oz@?&j}*_WuGfji+(+A=ixr z^2!vHDJpZd8=qk`hOs!tF%jorGKQ%ruEjZdU7637nO5dTFJsN9-j}@)n2F-HfaaP% zN&!(}*R!38b~8zjArN{_ch`(*ncgi<h||h+|%(D=5*XghI-nwPpn#dT42OgI#vy&x7n5gc!o@{W! zZgIN5ohZ{DTV|F#=1Llkl0csy>8M*E>ZnC^rnoDIoNX9evTR%HhWFI;HreC6<+%z_$sb32FzBQoG>Rpam8!td zVKz)_+ul+sSEbPA%^B;S-Q0=d35#;Uwzpc2fL^gI*(}!$*OffP&z&lR80`y~=RMY? zJJjA-I)2g)&ykHQJB~bId1t}4uddW7KL}Aa>h-GW$x;-&)Zt_LPCA>wz=zkd!V>%* z02&__J1tbb`z=e}Z}}#$?c&4o2;jMh~MWIhRsV4&rVg?8lv81dUHbtG&Yc!ZVJvZ&lLri;zZiNbUpn3`D<6CZI;l&ds^h7xS~h6Q5&A4)uB1klJw zp%)0fNYntKSwaU1y?g}9H#&gU0;NSI=NFuNuWWRtt(IUd^IA!a2NJ`t4>S%S%KixL z6`VqjO7a93F-&M4qdqbWp)$|!LqOaNh+~S#C;aMw8fjA_D#wwJP$zkTQ@p%uq+F-O zX%cVn@8afr>L9wQe>kB26i^@jfyA@eTj&eL*dBU{Y063#(<$F3d=Kw3Nx{WEr1n`M zpzdNici=p=5B~4ad018jmK1QCz&k9ayS(jL7HOHuzsKy%@qG7D!aU2h!efm1`MZLz Z*~WRiWvt*atKtieldPVb^p$*j>tB2Ld6xhH diff --git a/string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob b/string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob deleted file mode 100644 index 7592ea9..0000000 --- a/string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob +++ /dev/null @@ -1 +0,0 @@ -{"name":"Local: Append","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\string\\string\\Append.java","tests":[{"id":1608220330360,"input":"","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\string\\string\\Append.java","group":"local","local":true} \ No newline at end of file diff --git a/string/Append.class b/string/Append.class deleted file mode 100644 index c0bcb24e9df1a980bc85972fdf13a8088ecead52..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 879 zcmZuw+fEZv6kVq+o#`+L_J)Wec)_+%Dk$D+OvJ>e3MQB)#;4QvfJ0_F&2)yOpQR7Q zXyOO>QO0#TjkMTIa&CL=wf1d(|M~F?z%#rwkPukthk?^Qt-a~>RJUUwC9rfR&t=V( zd_8KNsdgxke&uwX@U=j)RBj5S-ufM7A&HEQIiv*^8%|dpMqWz=A7#r`0@;S&mTpr9 zj=ql{Q{fkqrllbFoLO{@wS=hBVT(TTujX+kj0wqBli8pmKEkJ~!eHG#sU%fA>kV%^3D z?y_2PR7`>DEa-pi?#;{ZM%}wy@1I`4Jme zh}9gw_JM5<$*H7Ar5!vnP!q_FYB+7Sv8(emdfLNfTT(JOW!rKynnPnh40d(DuXaPX zm9{Q2ahDE+;=K&EZ?i<;qMmGEYC-R@RzN2`7TiZk28RFjIH$1EkQN1KC yQk!aYO!G6bLc(=eBcV!6hCMtcCW$pX!9JzZSjAJG5=5K)vG!>bcuq_LFa84X0K*~x diff --git a/trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob b/trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob deleted file mode 100644 index 46d1433..0000000 --- a/trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob +++ /dev/null @@ -1 +0,0 @@ -{"name":"Local: BinaryTree_Traversal","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\trees\\BinaryTree_Traversal.java","tests":[{"id":1608219457557,"input":"","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\trees\\BinaryTree_Traversal.java","group":"local","local":true} \ No newline at end of file diff --git a/trees/.cph/.FindFullNodesInABinaryTree.java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob b/trees/.cph/.FindFullNodesInABinaryTree.java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob deleted file mode 100644 index 0a98957..0000000 --- a/trees/.cph/.FindFullNodesInABinaryTree.java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob +++ /dev/null @@ -1 +0,0 @@ -{"name":"Local: FindFullNodesInABinaryTree","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\trees\\FindFullNodesInABinaryTree.java","tests":[{"id":1608875314842,"input":"","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\trees\\FindFullNodesInABinaryTree.java","group":"local","local":true} \ No newline at end of file diff --git a/trees/BST_Deletion$Node.class b/trees/BST_Deletion$Node.class deleted file mode 100644 index 94cb5a54ccfbbacbc951227023a50c8d41b47da5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 569 zcmZ`$$w~u36s*p^jAl`@Xk4NZbOhtggW|!67zpuT2h8JHObKg+`)c<=-K zD6u-^AQ%t*`mObtJJBf%uIq;)y#EVgmU`>&0r? zmNRNz4j$z&5Qsj>R{_x$h}rU5tr$!I#NdyndZyX3L&S+*|;#fHSfuA>~;eI5^_ z*Ruw;6exDwp=I|iPw9A?jA^D^rUE$@$XvP4-cX(^-Cy{v(Y{tjz-T*;^jfy%`_fNh zlc;~yAe>fIAk~$AaN+s^Hpnc>Ux@LLGA%UC$xY%wKCd6im|F9ZbF}k}t~sISs^(sZ zocWG|Sqrgfn&KuzDMaOs#R!&ZixcoHbuc(OhYIZq^Ci{^fZB9j6{{o=A?(^@cAezF O<$7@)Tl5=~eEkQuC~YPH diff --git a/trees/BST_Deletion.class b/trees/BST_Deletion.class deleted file mode 100644 index 33e8c8ada2c76508c5360a5618d213ba57d44578..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2628 zcmah~TW=dh6#h1G;!C!vn`@gGo!BL}J+31r6ZGZ9ydw>}b?lLb2HRX%bYz74bnM3y z8Uh8=${P6`Q*5uEbl6NneA@-?Aj z66dI^Q*;l^vmbsp1xOlfGX!HSL-Wxx%~k|@?u!7wci9q~(>d=I$=-z25Gs3U>a z04{6TlXex2IkvGX?2?g>73X8lqKGY+tHPpL@KT<~RUOx)C%^KPw@TPlKMeEMbr4jZ#Sv%qLrshNcNoa>j-1FC|_`)*+jo#)sX9 zV~`I!5-oBzj5@UzN~|N4(C$P3fz~=Sb8J>8+u>tZ38E9*Y17@^2xAAoAc^si#<;JJ zmgYnvaSwWT8EqTTLTa@e+YnJm9q#T5QnPF$3Y|U7!~C6?GWvY-AsUivk>oveeTUX$ zf|F=Od5GS{q_W@f>^-i%=Pr)QT@Ml9t7lCP?mW7t&i9nD_ddGZIaj+BTu*Y1{_0i! z1I!laA!~d2y$@0LE_N>*!66(+iZ`(jX%@`{25}L`u!JF%SOl389cFBQnE9P1G0 zJb=c=&d#Q$Zq6mDtH-N+%Z#HkqT_cF<~u5<@|}^x!@vKCe9s+jj9p68lk{+kh@j0uaXzaW(PjzgIm($W{D-RVgic4eZpv{!4in^^;(@&8 z-Hra_uSlulCD4yJ@&Lm#Qs|#>VjX8%o-HF?#&{Vo$UQ7j<;)ejg8>5t0u@=7%S`Yl z6D(CR-(PXu?vBFT=V6}6$*=jUl|{8e#7!$pYK0y*tUMz1Dr*IJnWVl!LEl6h z-a;4NW+Qut*W_IszQ+Z@By0D!y*>Iu__FKxB*UOkTVqzw5~EO}=I8@8)B3UgG1E-~RxJ;{a9w diff --git a/trees/BST_Deletion.java b/trees/BST_Deletion.java deleted file mode 100644 index 240dd72..0000000 --- a/trees/BST_Deletion.java +++ /dev/null @@ -1,158 +0,0 @@ -package trees; - -//Java program to demonstrate delete operation in binary search tree -class BST_Deletion{ - - // Class to make a Node - static class Node { - int key; - Node left, right; - - public Node(int item) { - key = item; - left = right = null; - } - } - - // Root of BST - Node root; - - // Constructor - BST_Deletion() { - root = null; - } - - // This method mainly calls deleteRec() - void deleteKey(int key) { - root = deleteRec(root, key); - } - - /* A recursive function to insert a new key in BST */ - Node deleteRec(Node root, int key) { - /* Base Case: If the tree is empty */ - if (root == null) return root; - - /* Otherwise, recur down the tree */ - if (key < root.key) - root.left = deleteRec(root.left, key); - else if (key > root.key) - root.right = deleteRec(root.right, key); - - // if key is same as root's key, then This is the node - // to be deleted - else - { - // node with only one child or no child - if (root.left == null) - return root.right; - else if (root.right == null) - return root.left; - - // node with two children: Get the inorder successor (smallest - // in the right subtree) - root.key = minValue(root.right); - - // Delete the inorder successor - root.right = deleteRec(root.right, root.key); - } - - return root; - } - - int minValue(Node root) - { - int minv = root.key; - while (root.left != null) - { - minv = root.left.key; - root = root.left; - } - return minv; - } - - // This method mainly calls insertRec() - void insert(int key) - { - root = insertRec(root, key); - } - - /* A recursive function to insert a new key in BST */ - Node insertRec(Node root, int key) - { - - /* If the tree is empty, return a new node */ - if (root == null) - { - root = new Node(key); - return root; - } - - /* Otherwise, recur down the tree */ - if (key < root.key) - root.left = insertRec(root.left, key); - else if (key > root.key) - root.right = insertRec(root.right, key); - - /* return the (unchanged) node pointer */ - return root; - } - - // This method mainly calls InorderRec() - void inorder() - { - inorderRec(root); - } - - // A utility function to do inorder traversal of BST - void inorderRec(Node root) - { - if (root != null) - { - inorderRec(root.left); - System.out.print(root.key + " "); - inorderRec(root.right); - } - } - - // Driver Program to test above functions - public static void main(String[] args) - { - BST_Deletion tree = new BST_Deletion(); - - /* Let us create following BST - 50 - / \ - 30 70 - / \ / \ - 20 40 60 80 */ - - tree.insert(50); - tree.insert(30); - tree.insert(20); - tree.insert(40); - tree.insert(70); - tree.insert(60); - tree.insert(80); - - System.out.println("Inorder traversal of the given tree"); - tree.inorder(); - - System.out.println("\nDelete 20"); - tree.deleteKey(20); - - System.out.println("Inorder traversal of the modified tree"); - tree.inorder(); - - System.out.println("\nDelete 30"); - tree.deleteKey(30); - - System.out.println("Inorder traversal of the modified tree"); - tree.inorder(); - - System.out.println("\nDelete 50"); - tree.deleteKey(50); - - System.out.println("Inorder traversal of the modified tree"); - tree.inorder(); - } -} \ No newline at end of file diff --git a/trees/BT_Traversal$Node.class b/trees/BT_Traversal$Node.class deleted file mode 100644 index 8ee6fa80c5b8af8a6c433c03cc99a1179bd0a6a5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 494 zcmZ`#Jx>Bb5Pb^=2YAY-AR>y11zaJeg~mb>BMHI63x$nYaD~O=F4;Xu{8<*n#KIro zk221l6eh-EXJ%jK&3iMSU+*6P&Twoa!BC5o5W0KiJ$Q<*gwotU8HSI-hQ&~r^A+#< zJeYQG$8#}>7?RK8g@N@MEMGhkP#^p=;hZ6*V=Dz{0XeKpD z$Ve<0a(CfUO~kb{{l(u~o|@eloPH1p)$_U5Lfbf`sekvOapoornW50pO{gQZ$XSx^ zXdYRn2xBwOWSlZxiI&@<=+MuDg#_h_`-W||u|~ml+5H-&H7c)!Cs3tWqAn2IqUE#1 kE)%~-NcD${y^TTzb<#8r_G4}X2b6QMW)nx$)r#@vHx0*H-~a#s diff --git a/trees/BT_Traversal.class b/trees/BT_Traversal.class deleted file mode 100644 index b20935e91dd75b58361e6514fe88a2703eb166ab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2089 zcmah}ZBrXn6n<_AY!X)91BJdA3T>0nHq=(BO9R_&K-YyWXbs1kT3V7}mkX3n4@>W?)oc?0+gSaav&ul;xHmCfErRLl_R> zEY2G^_gYi(&nv#%G4VE{tk$ivF_Db!ne8TX3Ra#;teupB3rzT`n^fCQX`yPDiC96J zHgOS`8049JE+Eoj#E>u$e?6V{GBJZI0>++IuFBOdri`WI^{jeQ_1LK}CUH%5JgF>N z@8g9at}|6s8Qw5)6Yp|#*6yx!HU+M>^JoduC_v|$GjR*=3j}?)j(`J;wZ)afT?2On zhTC+?#61PLThCNA=DvvsY8>63UD{UsbI2w#DDPXvXDiljgCeGONIRMWYHCX+KEN;y z>+JC4@lD#qhw3J_j zd(xpw%BWqr9YzXy6Kkp%LqjM#Dr7;y3aZ=B)on0{F9a?glecq7fiD#o>GZY0bgog; zNj~4GdV?&$@=DyI;Wp*+QUMnT=iRDTluNeS#lhz9!8J830W?16GgZYBODfIEbPdoM_fB~8h zqMtgmZcNP}rJ&lyMxbwLrvl9;{zl+M;&+T3VEiS{9Aa{v($oPi@8jywYz^Y%GagyO=x%{j1wW$G3GkWy&Fdo6HU2iv7qf1wV&uF2vVy9h=(VGc=#rWa|Cgo zAff~@Ne~wZVyZI;vbY0?<&!}yzX{?JL0l$?I6))`Vum2DbOu2>HbBhiVQ|tfVK%y4 zpK6%X1taxfR>xA3YGHdv-I->`8+5$conNHT^A`;E~svpw|XRP8E9cW!nKAHZwUD4iKcF8K zohPlLTFjmMdG5LAeSE&X131Ng0uh1D&{ry`UusYK(_1BdXV77$)*e5o1Y!cYp?sEg zS9<;WO>d~2P$2rGrUIfV5OdWd6P4CKC}#o-zU~j$7Y_$IsGSHD{}^Cz{9JoFybvfK z{MFPv>~eL33{xOM3u$E1h$3&n!V38v9Cl4*&B6lW##^_LLeh983kf6zvMueY_GHvk zen<9PC6I589qD$ZuTA`&j2XsUrb9InNZ*bpzN40kS)*|AYdz-oG)@*A!U0u>~% zD^U1d9l{!w1(IzQgxBLB#10uo`8qLvq)rP%cmC%AKrUyFWla5f>>}+FqdQKRxsrV} zL)L!9vR$5G)wad`422nrFDyo|L7Sh0r>RGVqZWz;*<`-JIss7rUROee1R{jpn$K>N Q9Jt&pu40dVZJw`w0Y`m!6aWAK diff --git a/trees/BinarySearchTree.class b/trees/BinarySearchTree.class deleted file mode 100644 index d23e2ae3ec154150feb21ea7d24b9cecfac45aed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1542 zcmaJ>U2hXt5Ixs6INod$gB_D5&L?THcMGPW5Q-B51Olc`3K&H~ecG7YWWiaZ^#&=w zg8zV!`bsP6NJZ*nEA>ZJJ#%*zK9nG9XYZYR=ggd$={rMpWB5u|b2iROTQVK}OC*l3ZG0n+6QRGoLv};0$ZJ1e z_g*B8$@)Pze5yks?AUPet%8;K4C9&OlE;jtfD5>oMeUP$xAuFH-nH=^7D&3g$IPQm zBL}}*dl33T)FOFrw{GEkT*>0HLg9#Gn>s5fWM4=`Cm^p~&*!UD`8h^2;v$qEY}ezd z4GNPb8>dl_)pZ*c3^33Ow<&bS4zH5Ti|?VH9N=2h%`fy(ck@%m z7LBbKyJqZ?u@A)dvHXFo1B>`KNcJ8Z-9Qod`33lqdTjC|uuiHQSinPE!K06=Tx5H1 gFm3=f+@!)pySKPcVHLOemVePWpF3Qy@yW>kf0ol4aR2}S diff --git a/trees/BinarySearchTree.java b/trees/BinarySearchTree.java deleted file mode 100644 index d6a2105..0000000 --- a/trees/BinarySearchTree.java +++ /dev/null @@ -1,83 +0,0 @@ -package trees; - -class BinarySearchTree { - - /* Class containing left and right child of current node and key value*/ - static class Node { - int key; - Node left, right; - - public Node(int item) { - key = item; - left = right = null; - } - } - - // Root of BST - Node root; - - // Constructor - BinarySearchTree() { - root = null; - } - - // This method mainly calls insertRec() - void insert(int key) { - root = insertRec(root, key); - } - - /* A recursive function to insert a new key in BST */ - Node insertRec(Node root, int key) { - - /* If the tree is empty, return a new node */ - if (root == null) { - root = new Node(key); - return root; - } - - /* Otherwise, recur down the tree */ - if (key < root.key) - root.left = insertRec(root.left, key); - else if (key > root.key) - root.right = insertRec(root.right, key); - - /* return the (unchanged) node pointer */ - return root; - } - - // This method mainly calls InorderRec() - void inorder() { - inorderRec(root); - } - - // A utility function to do inorder traversal of BST - void inorderRec(Node root) { - if (root != null) { - inorderRec(root.left); - System.out.println(root.key); - inorderRec(root.right); - } - } - - // Driver Program to test above functions - public static void main(String[] args) { - BinarySearchTree tree = new BinarySearchTree(); - - /* Let us create following BST - 50 - / \ - 30 70 - / \ / \ - 20 40 60 80 */ - tree.insert(50); - tree.insert(30); - tree.insert(20); - tree.insert(40); - tree.insert(70); - tree.insert(60); - tree.insert(80); - - // print inorder traversal of the BST - tree.inorder(); - } -} diff --git a/trees/BinaryTreeNode.class b/trees/BinaryTreeNode.class deleted file mode 100644 index ace45e803d0eb2d26aad134cfd3458cb25629888..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 596 zcmZuuO;5r=6r62~*n)t7_<9g^z#nCt z0+R5thut@C-n=)v`}6zt4d4bBNf-jfC{$`vyVrpXXCC9$xUZ711ac$!CTqS72DPW| zNcAECt1lxdkZ*2McLH`>4+0rYLnUB(9y6A&o+&Cdca0!l-bvJ{ZIDfbdN8DXudV|f zH3W{_?Xi^(3tTGVzMjMzYVIr;n#HRX80 diff --git a/trees/BinaryTreeNode.java b/trees/BinaryTreeNode.java deleted file mode 100644 index fe8e3f1..0000000 --- a/trees/BinaryTreeNode.java +++ /dev/null @@ -1,13 +0,0 @@ -package trees; - -public class BinaryTreeNode { - - public T data; - public BinaryTreeNode left; - public BinaryTreeNode right; - - BinaryTreeNode(T data){ - this.data = data; - } - -} diff --git a/trees/BinaryTreeUse.class b/trees/BinaryTreeUse.class deleted file mode 100644 index e3af7525f6a0db48bb164c3502707854f7296c8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2177 zcma)7TUQ%Z7~Ll%&4t0X;a=Jjdch=IQd%wAAR-ks8lW~bO6zS1Ll_8?IGJGcrvJnz zpW7}4maOGtUCX~@m&^Ulgpxp9t1mfo&e`YN-?zU@{{HumKLJdm9)wS!+p!I!nwmE) z-L9|l`%%>h!mn^)Ti?@DCEY5fR@S$Tf}?P5#YrE@)y{fO5425X6T+mB--8N<4IP^PPW>uj#+lD%=5O(w(BV$!+WE_iUT{miu zSxV&!x@8%5I&tRVG98hZIkRZ#PR%Cs+?&6g@i^R2GnQi%$uXM_qZ_?J^t33Et5+Rk zS3@8AsX|#??Dbxo<SrRtQ$aP|2e0Mi8!Rv}{_%bRr+Y2(AZljRa@J(QpGdX~Hs|I*i3lRVIkH6?#sq zEuuw`z*rE;V^hr8C}6(-x?wWmqsgIHAPKj}Iz-}5!Iv|-p0 zEFdhJWHfw+&l#c@ZL}#N4ZQ`rq+uB=>{z{0F{}-RiRMZ=PE6C=7BW`v7Zj4!x`3Qm zT0LdpxD@}_fV|9W_!3_+H%{5Zvj*eM1=O$-!DD74y}kMKPU_|oM)>yL%cSwYH(z71`4Hel`i^qyC_B8hFl?%E7$CT zv1q!JwPj*YN+cv@keuy+pI;ow{0(xK;;Og?k_QMq=Z6mw{>rsLJNc`50Ipr!g{4=C zy1;KAF1kj3rD-vK`vs!Wfqh&`?jtrcKA7FB6Jb8$z-*Kn0PLDt1 zE5FNl)wL8thzwoi?IBN$OmQ;ZB9C|y^H^{XY3{mk6EpaL-o+5bEbh{u4|y*BdM9%{ z`G_Zs=9NtAuq5}j?;pF2|Int7n4gn>!T5XY-A6Y1U>^_n@hHpvotGGu z+p$9s@on^bUdeF-xqgD2eucF4J5@d{2s`D@Y%+)Q`&; z#C2T4BEOb!1v?mq&G72X=uf!j%F^cr;7S1E3<|VG5st-RaJ-wNeG!BI%7Isy3*zw& z3SwfLNU4N+BZ-4Y7+HIPodcA!40dX1oX*i*TO90o?HbsBotR*DCYh@g1~Ao>qe0ZL aM|>x takeInput(Scanner s){ - int rootdata; - System.out.println("Enter root data: "); - rootdata = s.nextInt(); - - if(rootdata == -1) return null; - - - BinaryTreeNode root = new BinaryTreeNode<>(rootdata); - root.left = takeInput(s); - root.right = takeInput(s); - return root; - - } - - public static void printTree(BinaryTreeNode root) { - if(root == null) return; - String s = root.data+" "; - - if(root.left!=null) - s+="L. "+root.left.data+" ,"; - - if(root.right!=null) - s+="R. "+root.right.data; - - System.out.println(s); - printTree(root.left); - printTree(root.right); - } - - public static void main(String[] args) { - -// BinaryTreeNode root= new BinaryTreeNode(1); -// BinaryTreeNode node1=new BinaryTreeNode(2); -// root.left=node1; -// BinaryTreeNode node2=new BinaryTreeNode(3); -// root.left=node2; - - Scanner s = new Scanner(System.in); - BinaryTreeNode root = takeInput(s); - printTree(root); - s.close(); - - } - -} diff --git a/trees/BinaryTree_LOT.class b/trees/BinaryTree_LOT.class deleted file mode 100644 index 5e39d518a12bb0709539a37fd3a49f23cab50687..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1756 zcmZux-%}e^6#j0qVUw_h3KVD?AV8`4VTrcdS_4#}P|!fC!B}i9E@XkN%ZAx3ndyv= z{s;a8J}}c6r!Vc)#3?gxJT~4o%?v6SHpS9Mj#-6*rz(o4$bNRjd3Mh2YRiwPNK3I;L#b z_GbjbsdSk^b9BcMMyCNC(HI2I8Hk`mpu1qZ*2@0whUKlA8;&K=Q>bp5PTBNqX}6r3 zzhl<~`dcvV+z8mc=h?1buc zaL=w=uFAq<+oG3b9b$*i5+9odlzemZr)6_bF^nOJF&(1<@e?5ojLQ-=$J+8`z=VOT z(h>0jKDu+nO!tCS3>kc&Bikl*>1oZkb`4y^Bn7SRvyux1brW_qcVE_BBBr^U*YTmi zz{wraZM)mE`?fSq) zevmjHM-F*;qf;{C^nSV=1$#gwW#H!qzQ8PR!`$1m+={@pvre2!(qgZ$?i!fKfdh$-g^cCZptj|u2Oa1+q4#JIVrvEV=yU;#V9j|In9C(CrrJGhbTQUT2lzAy?CaH zct-pI;|0ATbn)G#PWD5?0AmNyO`j1&<2>G@1xdA)>1Reuq+}-Z3PuCHQ`+=1bSo>- zz`!pdk+^*D-#;>cSmp00BVd@hM`@1{WfUVE5{Z)xa?P8N$gPp#M}OkuCO+$#Zs1M>a}C^khT(*EfQzb-gjS)Ls+3@PqURX( z0A`r{4r$FIjyaaIz)}`*n{9p<%kOAAe_X_Ts|XT8;aJ-U!jbVyyqsmMw0Jj}Iz))g zLx{B|iiPYUl51KM_t`h3Zb&nt%#kCrLz!2k$!m}S`bj{`6AfahK~JfHZ?g?NIO)Qx zs!vO-t&Bd7%QznJQr1|__w+o%W2|EXrmCzzpvRquq#5P=5&M+?9Q;5#gvb8_9;R4D diff --git a/trees/BinaryTree_LOT.java b/trees/BinaryTree_LOT.java deleted file mode 100644 index 43777cd..0000000 --- a/trees/BinaryTree_LOT.java +++ /dev/null @@ -1,99 +0,0 @@ -package trees; - -//Node of tree -class Node{ - int data; - Node left,right; - - //making public constructor of Node class - public Node(int item) { - data = item; - left = right = null; - } -} - -//main class to find linear order traversal -public class BinaryTree_LOT { - - //root node - Node root; - - //making an constructor - public BinaryTree_LOT() { - root = null; - } - - //function to print level order - void printLevelOrder() { - - //variable to store height which will be received from height function - int h = height(root), i; - - //loop for calculating given level - for(i = 1 ; i<= h ; i++) - printGivenLevel(root, i); - } - - //function to find the height of tree - int height(Node root) { - - //if their is no value at root node or node is empty then simply return 0; - if(root == null) - return 0; - - else { - //declare l-height for height of left & r-height variables for height of right, by using recursive call - int lheight = height(root.left); - int rheight = height(root.right); - - //if(l-height is greater then r-height then return(l-height + 1); - if(lheight > rheight) - return(lheight + 1); - - //else return r-height + 1; - else return(rheight + 1); - } - } - - //function to print the given level of tree - void printGivenLevel(Node root, int level) { - - //if their is no value at root node or node is empty then simply return; - if(root == null) - return; - - //if level is equal to 1 then print the data of root node - if(level == 1) - System.out.print(root.data + " "); - - //else if level is greater then 1, then call the function "RECUSIVELY" for left node & -1th level - else if(level > 1) { - //recursive call for left node at level-1 level - printGivenLevel(root.left, level-1); - - //recursive call for right node at level-1 level - printGivenLevel(root.right, level-1); - } - } - - //main or driver method - public static void main(String[] args) { - - //Making an object of BinaryTree_LOT class - BinaryTree_LOT tree = new BinaryTree_LOT(); - - //setting values of the different nodes of tree with use of tree object of tree classs - tree.root = new Node(1); - tree.root.left = new Node(2); - tree.root.right = new Node(3); - tree.root.left.left = new Node(4); - tree.root.left.right = new Node(5); - - System.out.println("Level order traversal of binary tree is "); - - //calling printLevelOrder() function - tree.printLevelOrder(); - - } - -} diff --git a/trees/BinaryTree_Traversal$Node.class b/trees/BinaryTree_Traversal$Node.class deleted file mode 100644 index 724af57114788265b35a52b121d44b3af4fd1773..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 617 zcmah`O-lk%6g|)HY*Mo?HOnl6njqV?C|VRmg4iMvY7ij#eu`^;3~H0*T(tk4=Oly-zlvH5nRE5f%pL$3%iv-Zd&*n-;ft?n^eYfnq|jJ=N0e*!`qt~149D6 zpZMpo2ZHd%|R zYg_Z3F)@gnsy3raPu6<3O57Q5&Ui)?RgNq0rydMk?~PU;EhSa&UCFfI@d zycz<53yGGvCUD=tj{?yaOj&rK0C(uBvn(#VjGa{o?B$Iad#m0$mcGuqx+PTA9$NSb zQ4HqM6?zhjM>5MKi^}gA)!|Pq{DJ~AE6HH0 zY**N{(F2+3Ly{1~GetP3BYskoX0nR=7Xm{cLB)fQgBtf%<4bygc_wAtsjxl*zbeGx zFkT8=HRJWf4_n!;zk9&ywPJ-GFcw>f6wOdj%5GFsiUsB1opofV*Xr#VQDqjevaTzAO_ik6ka|`~@T{x^Gg7@36$~)bc0Oo=A72vw!~FQV@Fc?B zINJ1`nc9Py5`V&a%hNV=@!zE_dlBM1N6?3JJhN)rIFBzVK@E1@)9=)4Dq_2i*sl>@qNmG58^>8b12Hvp z7}C*uY7rXIM=?nYfhp}lbZ}wMo&;$61R#&f#?4M1Q#ISdNdz;PtvmUjU8FkD-G^A%!(473 zvEhX(^3Owim~RLj%|d6hU^EM13anB0^C}(i?#hLwSQCF+n+caV|##j!kA;% z=GnVXk>)!$jsmeiqg3So1zuqRHWuOFB{uQ8sctTou|gkVtU_|a)aI%TG>o#~&`ciVpVZXz-;JG*<&x#ynqo$r44{{8PCe*&1pnvQ_L zpyygvGrMTlP51fQ3XQc(mvv|Yr=OX7X4Wz5o7rOZnYHc-Xl|pypHc7^EjMabPM~Mr zuG`*qfnYLKX3#CVqX?qcfR1nk0;ddw&?68l*mY}pce`r2D`wTP1o{h&b<-)Et}X43 zQ}ed$rod3A%u#GC7~65}x>vCFET`z!EH}y$g9grEh+wuXdvl8*W6AeXrt&gq#K2jc z>n6Bs?^$(~h0Pv`&dWZ;7T-Kyn+=pabNz=0=8i%bK>`yxE(k;qi7;?cwx~JQh9?82 z3`|Q$$o28)P8XT(`lATa_((_Q2-T(MP0!jkFoRhV+Sp|$X9{X3>_+yX?7PI8=5|iU zC4u3?J)+yLZ!YfI4jGXEt{C_jaU!ajo*BibnA36fXf3tGz-PE7pzoQ^u2tM%y<|S+ zmsFeYC(cEYMNaPMyo@+LpDKqz4TyvcylLPIEOIx@ogJ%Q6PP(^#jzwE^s3fv153Cg z5cV2A0`770L|pf9Uq@bG-~^fsd?^8klw$aIq-e;=wrSU?u;l7747pTUN~JeS3LnXS zzhXEUVS6hANu`%WL&`4Ux#phbHccnd*ho~>38K%k5_Xd;+(X&GV_98S)t$P`TQSg& zFjJcDCN(~A0sv0REL2yivFol|cWil5296$sS=lThQY1Xhf-g^)`m!Fv^h9XQBcSG@ z={BNi@f(a+^ajw!Z=YH@2@O+>okom4!;i*kd_W5lYA4f=jFy!W>GT^IEeyN%*-sbt0TQk2ov!@(_=56u=mx z!U()YpAfwq^Kf^N{LER6o~g`V2nAoJGjA|XJPUF#$-(vb=sxtg_WjFIz6|u?jFA@L zDwocYs2pL;V+1!??j|l!trAw+PyDX^DMc#p3l{%S!5YCSBsmIp0rtG*g(B(a#nJ)z zE3-(dmIzRL71w^j#A~DukgX8m<=^p18=vHtfuA3#*vC>AmYNK~{o9#S`iZb&nv%<-<-qs&QZavNlTei+d4g#8$D&|hld>r4wz z4plgcRyhJOwf^XQ(D$4i{Px(}_raBw);c<4AFvI+QOP%u0VVqR;)Bgb# C)L69u diff --git a/trees/Binary_Tree_01.java b/trees/Binary_Tree_01.java deleted file mode 100644 index 75fd229..0000000 --- a/trees/Binary_Tree_01.java +++ /dev/null @@ -1,89 +0,0 @@ -package trees; - -/* - * Level Order Traversal - */ - -/* - * Algorithm: - * There are basically two functions in this method. - * One is to print all node at a given level(printGIvenLevel), - * and other is to print level order traversal of the tree(printLevelorder). - * printLevelorder makes use of printGivenLevel to print nodes at all levels one by one starting from root. - */ - -//Recursive Java program for level order traversal of Binary Tree - -class Binary_Tree_01 { - - /* Class containing left and right child of current node and key value */ - class Node { - int data; - Node left, right; - - public Node(int item) { - data = item; - left = right = null; - } - } - - // Root of the Binary Tree - Node root; - - public Binary_Tree_01() { - root = null; - } - - /* function to print level order traversal of tree */ - void printLevelOrder() { - int h = height(root); - int i; - for (i = 1; i <= h; i++) - printGivenLevel(root, i); - } - - /* - * Compute the "height" of a tree -- the number of nodes along the longest path - * from the root node down to the farthest leaf node. - */ - int height(Node root) { - if (root == null) - return 0; - else { - /* compute height of each subtree */ - int lheight = height(root.left); - int rheight = height(root.right); - - /* use the larger one */ - if (lheight > rheight) - return (lheight + 1); - else - return (rheight + 1); - } - } - - /* Print nodes at the given level */ - void printGivenLevel(Node root, int level) { - if (root == null) - return; - if (level == 1) - System.out.print(root.data + " "); - else if (level > 1) { - printGivenLevel(root.left, level - 1); - printGivenLevel(root.right, level - 1); - } - } - - /* Driver program to test above functions */ - public static void main(String args[]) { - Binary_Tree_01 tree = new Binary_Tree_01(); - tree.new Node(1); - tree.new Node(2); - tree.new Node(3); - tree.new Node(4); - tree.new Node(5); - - System.out.println("Level order traversal of binary tree is "); - tree.printLevelOrder(); - } -} diff --git a/trees/Construct_Tree_from_Preorder_and_Inorder.class b/trees/Construct_Tree_from_Preorder_and_Inorder.class deleted file mode 100644 index c1bba4f8c538955fcdfd2bb46d78df2eae7029eb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1436 zcmb7E+fEZv6kVsC>6BU&FD>?hc(;IUK?N^GLvM`|^rcUn@WGWZko+SGHWcY`TGMKojVBYCX4#HOs9Q?=L@<6<;7S?zoOWArQ_D zEC^`Rbz8;|Mpqm%JV)(2PR(C+ngYYK|EH=X z&{vhdl75HEcZA<|?T&1LY;Mt9GzU7wQ;utSFBSeCg)+Qr&Z)YV-}0zzWFP4G?C#x7 z*Oyi4l_p9t2po;$7!s_+s;o7nC(xfWO{Ux@X}F=%g%(XNjw^6w|A@VF8^{P8YuD?~ zYsJuqegh{24*w-Oj*~bgU_7^KEqQ-MAem!v{(|vlX`E3#JS&jM{RU_^zBI7VMa20y zE+EIY+m>&s*6tE@a7xQy97DJ$5OrLCLFEmm#Z&}^IEol1K~1i3nv#3BNg*%AaakdC z&#A5w8f6XVe9NOLSVzNgJ3HNRXI#4t2u3$J>{yytuQP&Z)3xOb#yTqN9~1equ``uJ zd&=3n9Rl4HPKHhS16<>60H595b>Scm5!FLGgu?;JBnd+b84eF^Y4+gICmh)b&Ud*k z1YF5B4oUR#TyY<#C76>V|BE%HSj7lcM2Tsp^ILBa&1Bc1i;XWxKgp*HpOD?e=^J`@ zERq>B-l8w1C5%E!e~)ut(f1JpuVEyNvB)b!B#i9(kMAixtu18|5zWr0H0t|+JY9*% zQpVPn=w8b1_(xK@60Ze?C~JMQ|Etm|>LVxXEbMh&F11 Zs9W?LgnmG5qt`%Mh-8T8lk|pg`zPDvM3Ddh diff --git a/trees/Construct_Tree_from_Preorder_and_Inorder.java b/trees/Construct_Tree_from_Preorder_and_Inorder.java deleted file mode 100644 index 0531425..0000000 --- a/trees/Construct_Tree_from_Preorder_and_Inorder.java +++ /dev/null @@ -1,69 +0,0 @@ -package trees; - - -/* - * Code: Construct Tree from Preorder and Inorder - * - * - *Given Pre-order and In-order traversal of a binary tree, - *create the binary tree associated with the traversals. - *You just need to construct the tree and return the root. - * - *Note: Assume binary tree contains only unique elements. - * - * Input format : - * - * Line 1 : n (Total number of nodes in binary tree) - * Line 2 : Pre order traversal - * Line 3 : Inorder Traversal - * - * Output Format : - * - * Elements are printed level wise, each level in new line (separated by space). - * - * Sample Input : - * 12 - * 1 2 3 4 15 5 6 7 8 10 9 12 - * 4 15 3 2 5 1 6 10 8 7 9 12 - * - * Sample Output : - * 1 - * 2 6 - * 3 5 7 - * 4 8 9 - * 15 10 12 - */ -public class Construct_Tree_from_Preorder_and_Inorder { - - public static BinaryTreeNode getTreeFromPreorderAndInorder(int[] pre , int[] in){ - return helper (0, 0, in.length - 1, pre, in); - } - - private static BinaryTreeNode helper(int preStart , int inStart , int inEnd , int[] preorder , int[] inorder){ - - //Base Case - if(preStart > preorder.length || inStart > inEnd) - return null; - - - //get the root node with current pre-order element - BinaryTreeNode root = new BinaryTreeNode(preorder[preStart]); - - //get inIndex; finding preorder's element's index in in-order - int inIndex = 0; - - for(int i = inStart ; i<= inEnd ; i++) { - if(inorder[i] == root.data) - inIndex = i; - } - - //(next, left of inIndex is the end for left subtree) - root.left = helper(preStart + 1, inStart, inIndex - 1, preorder, inorder); - - //(prestart + length of left subtree + 1) - root.right = helper(preStart + inIndex - inStart + 1, inIndex + 1, inEnd, preorder, inorder); - - return root; - } - -} diff --git a/trees/Count_leaf_nodes$BinaryTreeNode.class b/trees/Count_leaf_nodes$BinaryTreeNode.class deleted file mode 100644 index 14510dc638d04dac456cb6da0bc551b1e913def1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1617 zcma)6+fEZv6kVsC(o%+t2ndLZg3t?4yelnKs3J{jeV`%H7d(_B4A!ZcnHup^`~hEl zF%gZL7~f3%5a0X*qpmY8$TcC;nVz%vK5O<~d+qu0=kr$pH;@k_AaK!hlyXzKYR&eR zD@s0DwyUek9iFpn>1>whEOH-)A<(fQU&vHN+H0u?D;uip2^g!=lLDQE{jRh?^P;t8 zORwfAfncdbOQgJRRaPBk3v|~{)I6(_nspqxS+HD>A-TisnZmJ>%jm0w&l$TjK_`&I#^YFi3ekRk6su#GSdu!lO{~GMiE4}i8l1G-dKD|dwNZT z&=f{LgM5ni792$%x^>(c6U~SUv==N}6>HB{lv9!`6*AXZsFr1ANjjF^H;jg^Phj+j z#P>Ci#rEt)*?hi@G6hD5Ij4L4DSF>L@+~J&@XJzr%lJ#3)Asg#@C~= w^xh_FKaAgqh?c)-K`0EtpYGIToy=KA1TfcVNDg^Z)<= diff --git a/trees/Count_leaf_nodes.class b/trees/Count_leaf_nodes.class deleted file mode 100644 index d710deb3830ac3df0f6040238dac0e2bf718de4c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 400 zcmZutO-sW-5Pg#-ji#|*TJb63q zZ1Gfjm^bs@46|?c=lAOyzy&5DJi@+hq%=udx7yAtDW2!Lev&4HPZ%!5QY4koFUdo( zkfkMbuas8yn$S5poe}($ha+^b9V0-OFvygadHYt#W-5wG62@6wifSer<@mqo+gD`> z2ifM=FA33O-8QAXRc^;*-QKx#Mu_jUmQ7j-W1QtN;dt}HqZ_3~^FHNUb9PMVuM53g z8hbCDaf3tff&59}OztqokXf?gKydbntq&GFM2xNtjL>6@S9QR7hgk=GMh^oFIY-Bb5Pb`W2j|JR_yH&}6hI-Rg~mb><0S+O355+=aD~NlFWEax_*oXj#KIro zk221lv}&>QX5Y^2n>U|d?;ilp(6EtUIEl0nVb@ck(2)$(*i+*xskmMZ>7h9Y9)t~x zA-~`+yz6r{>)uWlVj3|dpTvrRc?^~>9*Jo7|NrcqA*JPPPUTw{QpxC&+FM?GM9?EK z2T5dIILMJet3Aqqq2MBgEt8d8WRN!5t_vG!hFo7NF<3rNgdXyVFBppbV9Naw*V5cK zq!rC&$l%-sOFb3W(iGNyF@0*RGPs^nLicwat1P5{NA*zH9X_0pvQPpwG*S-O1ylX-L diff --git a/trees/Insertion_In_BinaryTree.class b/trees/Insertion_In_BinaryTree.class deleted file mode 100644 index 6d80297f4da874b5d4475da6a76f585c816f482d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2214 zcma)7T~`xV6x|mB6T(oCAjp?QK};eVY88}Fszhz00kqIipsfz%1_qLuFqzQu)~EJ2 z^cV1~wt{u7uD-ce|4RQtSKEDOg33p!JTUj;oO{mR=bW8C{{Hnh0HY{ts1fLO9VyF+ zv{jalYueW1wDow>vF zQOFvOsrJ>w`f=~U5NZ+DaS9D8*qT`u=sP(zW~G^y?c}5*a4~wav5zB`Z9pfwHFOD_ z|9{*%dK8dALFU~Mk)74ij*bRIa9+c?1FX(&m&uThehiQryFzA9XFSqPJMqvlEq9jj zjABy5pg_mla`4!+RwpZFfjCrlQ5`YF`N)Rc77*zWhHyp0<%8ioFC7UClZ7p#P?0lv zhK#0TepIj2{@ckAF5s%7_9JC+^gfmi;yOb`l;Nn38@MS@ZX$_ZRP&f~}gcX%w}X^e9Y@m{q8;41#S}MDF9bYQDdPf%REg2%%MOCjQy0W5K zW%IR;Z}3>PeEDv%;*=?@+CG4if- z-f>}U!&#*ygpUa=5Sq0s&WgNeDv{~=4;{RsYDk?*Tb6WE1*2S+d@!K&O`vgFmfb0- zw5p7AOt6;vT7#g{G_Hb5(fF<7DhMTVA?_~ntNyfSXnc;Qr(D*cng8p(i#D`)C*Y2< zR&`47tK911yJ$V^Qs=qoz5&{BnubB8IaTLx5%BJYdOX#Ic4&Vw`3H~q+ zV+>a*7uS%%bq?1EmT(h!+S*8ZKqEeeDo~DZljb8Q z!F{j3);x<#Z`QU&ALpWb4{L0M*7Y~%Z+mM5O-$<+Q@@RFs%ji53iKUJlb|Oo>>5jJ z;XXF;0N+t+zUR#knDJ<8_aUKxBH!3#FZwjq(nGboP2#|55Y#Ne`yd?dRhM@D3qOnW A@&Et; diff --git a/trees/Insertion_In_BinaryTree.java b/trees/Insertion_In_BinaryTree.java deleted file mode 100644 index efdb19a..0000000 --- a/trees/Insertion_In_BinaryTree.java +++ /dev/null @@ -1,80 +0,0 @@ -package trees; -import java.util.*; - -//Java program to insert element in binary tree -public class Insertion_In_BinaryTree { - - /* A binary tree node has key, pointer to - left child and a pointer to right child */ - static class Node { - int key; - Node left, right; - - // constructor - Node(int key){ - this.key = key; - left = right = null; - } - } - static Node root; - static Node temp = root; - - //In-order traversal of a binary tree - static void inorder(Node temp) - { - if (temp == null) - return; - - inorder(temp.left); - - System.out.print(temp.key+" "); - inorder(temp.right); - } - - //function to insert element in binary tree - static void insert(Node temp, int key) - { - Queue q = new LinkedList(); - q.add(temp); - - // Do level order traversal until we find - // an empty place. - while (!q.isEmpty()) { - temp = q.peek(); - q.remove(); - - if (temp.left == null) { - temp.left = new Node(key); - break; - } else - q.add(temp.left); - - if (temp.right == null) { - temp.right = new Node(key); - break; - } - else - q.add(temp.right); - } - } - - // Driver code - public static void main(String args[]) - { - root = new Node(10); - root.left = new Node(11); - root.right = new Node(9); - root.left.left = new Node(7); - root.right.left = new Node(15); - root.right.right = new Node(8); - - System.out.print( "Inorder traversal before insertion:"); - inorder(root); - - int key = 12; - insert(root, key); - - System.out.print("\nInorder traversal after insertion:"); - inorder(root); - } -} diff --git a/trees/Node.class b/trees/Node.class deleted file mode 100644 index e882920baff1cfe8813314b682f14ffb1d88ba51..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 390 zcmYLEO;5r=6r63#N3jYP#1A}pgdXJRLE}La6OslFHXOW|Ev&Glv`Hx@{wxo~#DhP; zA7z|H5)b?4y~&%MH{U;>UjVLfUV$Z0D{`e){b4p$6*vNog?yF$M5eR;C|;;ZA>d49 zAqB*MZK7Vtc;Ub5TA-Bc*_?FwMyI;Cp8x!vNYYjFIJk(GZu)Dpn3xPuqC6rCq z^x&dux+4!2R0ZmxPStR|j8z`VI8g$Am`!9dmbo_bj&zE-UeQ7qYRMFj**c%72W|G7 zcRH2%Tf|_`;V8N^iEu#+o4L)SH!FOk-mStw|z31LL=boA0e}4P|u!pvdoIoShN+q4oIv$1UM1rq942 zo+ulZK;>AT%1$Vw!_KGCu^OiW)_H@zRyTud=!Kets;Ti zykeRLVdtIJ@~j^uDO2|T7w`6OB-Ul)9zTJV^e9N0yN1kiwn4i=6r??YZ8r;N*|&x) zaoO7#);<*|Lg1bQ2X{)yqvl{0bhw9HHb>lw<6i{WVX>y>BUE~__gE}P3HP&$aGdaT|D zhC=!3;$N8|1l+FwCM!-a8xn9nMv>C{p-d8$*l6*&EMEg3z~y_QIZ#RZAx=_kP?tPk zp;;7>o=q!<0(XkF@NZWtMt(*G*DA`)nP*mTmyuI;Fg@11of)d$IqrMy86J2)(fD$X z^%)+0Cz{6-?p0XaJ@(&Wr#7$WC7v=;XHRw@r%nEiWfBv%uT z?U|Ncx-Kv<^qk`HC3?I->#<~HSs<9Qa<=J}U0NJ}iT2c7Bc`P7$((d!aRs5{fIv@G zSoW-ZlyPjx?3`8dLg+@Y1HE`v$3aHe(795UWoe)fhscMS%?gBv_Tbkzi$#{z<--PE z!x0kb%7Sy7UiJ({p4ZheDA3nR%ClG%&@ltAA;l2PLQKaQfrAZuJhtrI`LdPIN;ibl2&&;d1CwCl17@)(ZL)ac zMJ(=#rU@q2jz)bonKmDBaMk5YRZo#OEP>wU2fta|ee`4hZScj z?#EH*F3MSO_7C4j`_ENzh@%n%$I-#js3~yX$6XMwppzh7T(@Dr0ulEJ9pHXv_%Zyx z?T6^TaUVVNBf}36Zo{<^QJa17Eqpcd0Q~}wFfgh0X^(M;`=bKiA+QB!S8)qB`?O#2 z#v?>3c)R}|{Mz;}h(5$=;!adW6};O$RYAOh=?X6T&iJr=JoCfkoxy76c8IaUUF~LuH*5MU)X(y~AHl%iIIN>rJVC#Xfl${I e9232N!DuIdq)HoBk>ebq0|WflxVHFdYX2`xn8}s^ diff --git a/trees/Problem_01.java b/trees/Problem_01.java deleted file mode 100644 index c7bf03c..0000000 --- a/trees/Problem_01.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Check if generic tree contain element x - * - * Send Feedback - * Given a generic tree and an integer x, check if x is present in the given tree or not. - * Return : true :- if x is present, - * Return : false :- otherwise. - * - * Input format : - * Line 1 : Integer x - * Line 2 : Elements in level order form separated by space (as per done in class). - * - * Order is - - * Root_data , n (No_Of_Child_Of_Root) , n children , and so on for every element. - * - * Output format : true or false - * Sample Input 1 : - * 40 - * 10 3 20 30 40 2 40 50 0 0 0 0 - * - * Sample Output 1 : - * true - * - * Sample Input 2 : - * 4 - * 10 3 20 30 40 2 40 50 0 0 0 0 - * - * Sample Output 2: - * false - */ - -package trees; -import java.util.*; - -public class Problem_01 { - // TreeNode class - class TreeNode { - T data; - ArrayList> children; - - TreeNode(T data){ - this.data = data; - children = new ArrayList>(); - } - } - - public static boolean checkIfContainsX(TreeNode root, int x){ - - // Write your code here - if(root==null) - return false; - - // Write your code here - Queue> queue = new LinkedList<>(); - - //added 1st level here - queue.add(root); - queue.add(null); - @SuppressWarnings("unused") - int ans=0; - - // if(x frontNode = queue.remove(); - if(frontNode == null) - { - if(queue.isEmpty()) - break; - - queue.add(null); - } - else{ - if(frontNode.data==x) - return true; - System.out.print(frontNode.data+" "); - - for(int i=0;i473lIei2dIg7^Weup5+e!0gM@<@v)~HFT9VyD!q4*1n0W99 z_@j)kJu4n|W?yz^-n`wf?~hLaXE@40N6CbNafkOjT2JJ51on zs6T%a3|80oh3t4-DWMqZy+8_~+SjhnZ>oCEdxC9Q0u7s>Ufp zWsQjL>ld!?23HKV=DLgB){s(l;#B#b>x=&4btL3~k37n0-p?0uEN9`$xSgxOK+QrPwuMd9Eu@jLkVDpji7Z3)pE()q$gk~jf6~4i&BT}{F8?i}7jCwO zsL`7n^d(7J)R7QTznG~xVB1k9s_8Q*Sb=bhs!LL6#3koA1asbza4I1*$6*g4k|9!W lv1FUD5S!=7JWuo3D3Xna9Xd&17ke=mVG)~TuG9Gj@B=h%cZvW2 diff --git a/trees/trees/BinaryTree_Traversal.class b/trees/trees/BinaryTree_Traversal.class deleted file mode 100644 index 440edb1d157fc0231cea1eac491988f5cc955c97..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2145 zcmah~ZBr9h6n<_9Bw03qC{n0mu)&7J5^W2$f^UG7v>~8DC~CD!xWbxcm+o$8^H2IW z>{#gNOsC&E(;wC8b2mFBfq;|Qd(S=hob#O5n}7a&_a}g_u%+Q65=O?jxR7;^j#^v{H$pkZhe*X%T?Fdm#$}6X{9(V&^2S) zrhiwUBQw56&AGr{Z_%`6skXZ*-Bn}LB0|reYuf&b8}PaTy~zKE@>-i)tCgRUHLfis4%w-=U~u2_=EPS*FeNU1M)a`a8~+ z*V~2VI97B#!s8gqI#%&SM_OsGDQXN?1%^*gvcQ$oFM|riu&(2KY$z9>3XH9UnMl!# zMxj#9tJG#tK=PzanO;f(j|g1TQehsCOB=RZZ<05P{8zj_~#A64>wNBLjgd@U>N zr>G@gaqD!=?H%q-66Lz*%Uw2+Q{%-zqjsi~Ur|lN@=0Ttz1C5cbpcV(@C?rdA|fR) zxNB79oMTrEf8F$VNO`_t`)uNYOkw*7gK`ZFVD6YV_u!VQ*Q|OE)B^PX^t@X;ECQ@5wge&GXhK z-q6IHVOeFDfJ@cjOG4D^i4MR799tOs=br@Z|EWwd#At-kWeNg zfyrTXk-kimBj_Y2NrMBN`ZUMx6W(+{baLY}a2Af%YQH;#)sEwg6DLcY>%^I0@Hc4q zW-|^SnYK7>>@z$)#L&=;4WEW8e=!DC&|lsoxp9b|;(PRN z4^ylb_^%Pi zGMjIOK0d-E9%CM5{+{rGTf<8}?AzEtl_w9+@iSh~{|xma7-!AFli)x6FsXj>dTCQN S@Cz8!9l{r+S=$W6Ja5J*TWY9JcqX`n+Lm`<^sn()p~=&L5a z@S;HwNsLdJ_yK-_UtzqhGsP5QeCR%Vud~kHd+jr)Uw(b~2w)tyHAK-KMg=-lbZYRS zy#meXlBQdlt15cJ2%%S+n2NYYZo9^yFN_5GWjLT=5J?r+1pN72&K1y8Zr(Ht$)#M{ zoD>L7S&rq-2>4?0ha}Ar7N|~Hj=5CKuABK4W8EgAXH0jYXxnqSqQfj?FA7vHyT-=$ zU1P^1sTg8{tYJ9<4Y9Sju9e39o9Ap1Z&bFy37XO#eUEADbkwD(cJmKn(Ey~HAYh!u0;F?(` z%N4m_U&>+SlJ_}gm%}!VEU&iKYw{w@R(2%GcF@7kBg!vL@W%<$`sj1uv<-}|aFu(3 zz9Wb?bObKZ20gHb9*0CRYI<%bEQ2G(Mrhc-|t)YSx)g9nn5-FMyO~)7%kM) zO4~-;fnIcC2wl9#Zp@+wi$qos#~S*uiGEmo9Zfu4k6`#G>Qpp~ALvpMihf5_@zTjL zNR8j9P~rOO1QnE~rxGU!tp<)z`3_2gDrFc^y*T_g4tb#_L+bGu!3z*|OVnRJM&211 zsW?ydc#-f0=!|$)^ew6qhp0Y8q5XB5e=uu&AW!)|_Ar6x P{O(_3np#`QSJ3tch#2l{ diff --git a/trees/trees/Node.class b/trees/trees/Node.class deleted file mode 100644 index 306771cee78f9af2cb76992fbfd929b6870d5b3d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 339 zcmYLEO-sW-6r63+#>UmuwtnG3k8KX-sGtZc6au9lEIoMJG;7@wQ%DoRpXDJ49{d6R zC~>wI4{zq}+nM+A^ZWG;-~z`!TIjaXM9)Is!oG(C4~GJ7s!AmwVy2mXE(PScEVN!n zlU1s(1e%3eys+H5Hn}NpC>zAX8R?$?0>RkidQ!b6x|pgYW5s`5RmEJ7jD4JrOrDOa zEVJF#aejMea#g%fIpKV%-jsyIk%WgWiEa22ZTM{Qzkxu<>Y_~Li|8R)>N$6D2E!T7 zct(o{It==WucJFP7U{CqYj8&s;tYUuT5VM L0sS4;8rb^-@TxjV