Learn, Share, Build

October 01, 2017, at 06:17 AM

I'm learning about tree structures and am trying to figure out how to code a Java class for trees with an arbitrary number of children. Based on the code snippet below, would anyone suggest how to implement a method for insertion, removing and searching? I'm looking at a simple B+ tree data structure of order M with the following basic properties (definition by Mark Allen Weiss: Data Structures and Algorithm Analysis in Java):

  1. Data are stored at leaves
  2. Nonleaf nodes store up to M - 1 keys to guide the searching; key i represents the smallest key in subtree i + 1
  3. The root is either a leaf or has between two and M children

I can't find a simple example on arbitrary trees in java on the net. If anyone knows about any good examples, please share.

Based on this basic structure, how would the methods for inserting, removing and searching for items in an arbitrary tree?

public class ArbitraryTree {
    public Node root;
    public int m;
    public ArbitraryTree(int m) {
        this.m = m;
        this.root = null;
    public class Node {
        public int data;
        public int depth;
        public Node parent;
        public Node[] children;
        public int size; // Number of children
        public Node(int data, Node parent, int depth) {
            this.data = data;
            this.size = 0;
            this.children = new Node[m];
            this.parent = parent;
            this.depth = depth;
    /* How would the insert, remove and search methods look like? */
Learn, Share, Build

Learn, Share, Build

I'm trying to write a simple HTTP REST service using Spring 4

Learn, Share, Build

Learn, Share, Build

I have a program that is running in an online game that answers questions as a help botIt reads each message and checks that it contains certain keywords and if it does, the question is answered

Learn, Share, Build

Learn, Share, Build

I created a porfolio webapp with SpringEverything worked fine on localhost, so I uploaded a mvn jar on ovh

Learn, Share, Build

Learn, Share, Build

I am new to develop android application, I have to develop android application with J-Hipster, so is this possible to develop android application with J-Hipster ?