This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Add single file | |
git add README.md | |
git add original.txt | |
#Add all files | |
git add . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// DFS post-order print of all values in BST | |
static void printPostOrder(Node current){ | |
// print left child | |
if(current.left != null) printInOrder(current.left); | |
// print right child | |
if(current.right != null) printInOrder(current.right); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// DSF pre-order print of all values in BST | |
static void printPreOrder(Node current){ | |
// print current node data | |
System.out.println(current.data); | |
// print left child | |
if(current.left != null) printInOrder(current.left); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// DFS in-order print of all values of BST | |
static void printInOrder(Node current){ | |
// print left child | |
if(current.left != null) printInOrder(current.left); | |
// print current node data | |
System.out.println(current.data); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// Delete a node in the BST | |
static void delete(int val){ | |
delete(root, val); | |
} | |
// Delete a node in the BST recursive helper method | |
private static Node delete(Node current, int val){ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// Find a node in the BST | |
static Node find(int val){ | |
return find(root, val); | |
} | |
// Find a node in the BST recursive helper method | |
private static Node find(Node current, int val){ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
public class BinarySearchTree { | |
// BST Root Node | |
private Node root; | |
// Add new node to the BST | |
public void add(int val){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
class Node{ | |
int data; | |
Node left; | |
Node right; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// Node class | |
static class Node { | |
int data; | |
Node next; | |
public Node(int data){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// custom node class | |
public static class Node { | |
int id; | |
Node left; | |
Node right; |
NewerOlder