Skip to content

Instantly share code, notes, and snippets.

Avatar
🛠️
building stuff

Andreas Ioannou xnorcode

🛠️
building stuff
View GitHub Profile
View GitAdd.sh
#Add single file
git add README.md
git add original.txt
#Add all files
git add .
@xnorcode
xnorcode / BinarySearchTreeDFSPostOrder.java
Created Oct 7, 2018
Depth-First Search Post-Order traversal
View BinarySearchTreeDFSPostOrder.java
...
// 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);
@xnorcode
xnorcode / BinraySearchTreeDFSPreOrder.java
Created Oct 7, 2018
Depth-First Search Pre-Order traversal
View BinraySearchTreeDFSPreOrder.java
...
// 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);
@xnorcode
xnorcode / BinarySearchTreeDFSInOrder.java
Last active Oct 7, 2018
Depth-First Search In-Order traversal
View BinarySearchTreeDFSInOrder.java
...
// 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);
@xnorcode
xnorcode / BinarySearchTreeDeleteNode.java
Created Oct 4, 2018
Find and delete a given node in a BST and then reorganise it
View BinarySearchTreeDeleteNode.java
...
// 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){
@xnorcode
xnorcode / BinarySearchTreeFindNode.java
Last active Oct 3, 2018
Find given node in a BST
View BinarySearchTreeFindNode.java
...
// 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){
@xnorcode
xnorcode / BinarySearchTreeAddNode.java
Last active Oct 3, 2018
Add new node method in BST
View BinarySearchTreeAddNode.java
...
public class BinarySearchTree {
// BST Root Node
private Node root;
// Add new node to the BST
public void add(int val){
@xnorcode
xnorcode / BinaryTreeNode.java
Last active Sep 26, 2018
A Binary Tree Node Class
View BinaryTreeNode.java
...
class Node{
int data;
Node left;
Node right;
@xnorcode
xnorcode / RemoveDuplicatesHashMap.java
Last active Aug 29, 2018
Remove duplicate nodes with the use of a HashMap array
View RemoveDuplicatesHashMap.java
...
// Node class
static class Node {
int data;
Node next;
public Node(int data){
@xnorcode
xnorcode / TreeBreadthFirstSearch.java
Last active Jul 30, 2018
Check for path in a tree in a BFS method
View TreeBreadthFirstSearch.java
...
// custom node class
public static class Node {
int id;
Node left;
Node right;