This file contains hidden or 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 InOrder { | |
| public void traverse(Node root) { | |
| if (root == null) { | |
| return; | |
| } | |
| traverse(root.getLeft()); | |
| System.out.print(root.getValue()+" > "); | |
| traverse(root.getRight()); | |
| } |
This file contains hidden or 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 PostOrderTraversal { | |
| public void traverse(Node root) { | |
| if (root == null) { | |
| return; | |
| } | |
| traverse(root.getLeft()); | |
| traverse(root.getRight()); | |
| System.out.print(root.getValue()+" > "); | |
| } |
This file contains hidden or 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 PreOrder { | |
| public void traverse(Node root) { | |
| if (root == null) { | |
| return; | |
| } | |
| System.out.print(root.getValue()+" > "); | |
| traverse(root.getLeft()); | |
| traverse(root.getRight()); | |
| } |
This file contains hidden or 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
| import static com.trees.SimpleTreeFactory.*; | |
| public class TreeHigh { | |
| public int find(Node root) { | |
| if (root == null) | |
| return 0; | |
| return 1 + Math.max(find(root.getLeft()), find(root.getRight())); | |
| } | |
| public static void main(String[] args) { |
This file contains hidden or 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 SimpleTreeFactory { | |
| public static Node get() { | |
| //the left part of the tree | |
| Node leaf7 = new Node(null, null, 7); | |
| Node leaf0 = new Node(null, null, 0); | |
| Node node5 = new Node(leaf7, leaf0, 5); |
This file contains hidden or 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
| package com; | |
| import java.lang.reflect.Field; | |
| /** | |
| * Created by adelin.ghanayem@cayetanogaming.com on 2/17/16. | |
| */ | |
| public class MakeImmutableMutable { | |
This file contains hidden or 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
| package com; | |
| import java.util.Iterator; | |
| import java.util.Set; | |
| import java.util.TreeSet; | |
| import java.util.function.Consumer; | |
| /** | |
| * Created by adelin.ghanayem@cayetanogaming.com on 2/17/16. |
This file contains hidden or 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
| package com; | |
| /** | |
| * Created by adelin.ghanayem@cayetanogaming.com on 2/16/16. | |
| */ | |
| public final class User { | |
| private final String name; | |
| private final boolean isActive; |
This file contains hidden or 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
| package com; | |
| /** | |
| * Created by adelin.ghanayem@cayetanogaming.com on 2/16/16. | |
| */ | |
| public class Address { | |
| private int number; | |
| private String address; |
This file contains hidden or 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 DefaultCassandraDriver { | |
| //only one session per key space | |
| // we may provide a Map of Keyspace and their respective sessions ! | |
| private static Session SESSION; | |
| public DefaultCassandraDriver(String clusterName, String... contactPoints) { | |
| createSession(Cluster.builder().withClusterName(clusterName).addContactPoints(contactPoints).build()); | |
| } |