Creating a binary search tree with Neo4j
One of the powerful use cases of the Neo4j graph database is to create scalable in-graph data structures, such as linked lists, trees, and so on. In this recipe, you will learn how to create a binary search tree from the Neo4j graph database.
Getting ready
Install the Neo4j graph database on the host machine using the recipe described in Chapter 1, Getting Started with Neo4j. This installation process will depend on your preference for the machine OS type.
How to do it...
By definition, a data structure should have nodes, where each node has a comparable key and an associated value. If any node satisfies the restriction that the key in any node is larger than the keys in all the nodes, then this becomes the node's left subtree. The keys that are smaller than the keys in all the nodes become the node's right subtree.
Let's create a root node and its children using the following command:
CREATE (root { name: 'ROOT',value: 10 }) CREATE...