Skip to content

Instantly share code, notes, and snippets.

View xnorcode's full-sized avatar
🛠️
building stuff

Andreas Ioannou xnorcode

🛠️
building stuff
View GitHub Profile
@xnorcode
xnorcode / GitAdd.sh
Last active September 17, 2021 15:39
Git Basics
#Add single file
git add README.md
git add original.txt
#Add all files
git add .
@xnorcode
xnorcode / BinarySearchTreeDFSPostOrder.java
Created October 7, 2018 22:33
Depth-First Search Post-Order traversal
...
// 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 October 7, 2018 22:13
Depth-First Search Pre-Order traversal
...
// 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 October 7, 2018 22:08
Depth-First Search In-Order traversal
...
// 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 October 4, 2018 12:19
Find and delete a given node in a BST and then reorganise it
...
// 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 October 3, 2018 21:49
Find given node in a BST
...
// 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 October 3, 2018 21:47
Add new node method in BST
...
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 September 26, 2018 11:40
A Binary Tree Node Class
...
class Node{
int data;
Node left;
Node right;
@xnorcode
xnorcode / RemoveDuplicatesHashMap.java
Last active August 29, 2018 16:16
Remove duplicate nodes with the use of a HashMap array
...
// Node class
static class Node {
int data;
Node next;
public Node(int data){
@xnorcode
xnorcode / TreeBreadthFirstSearch.java
Last active July 30, 2018 18:23
Check for path in a tree in a BFS method
...
// custom node class
public static class Node {
int id;
Node left;
Node right;