Talk:AVL tree/Java: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 4: Line 4:


The Java implementation of AVL Trees is a bit different to the C# version in that references to references are not available. This means that functions like RotateLeft and RotateRight return the new node rather than the function updating the reference for you. It is only a cosmetic change to the code. [[User:NNcNannara|NNcNannara]] ([[User talk:NNcNannara|talk]]) 11:25, 16 July 2016 (UTC)
The Java implementation of AVL Trees is a bit different to the C# version in that references to references are not available. This means that functions like RotateLeft and RotateRight return the new node rather than the function updating the reference for you. It is only a cosmetic change to the code. [[User:NNcNannara|NNcNannara]] ([[User talk:NNcNannara|talk]]) 11:25, 16 July 2016 (UTC)

AVL Disk can be implemented in Java (i.e. AVL Databases). There are 12 databases in [http://nncnannara.net/Html/English/Java/persist/index.html|Applied Calculus]. Strangely enough, all 12 databases use the same basic node type on disk. The definition of that node type is shown below.

<lang Java>
public class Node
{
public long Left;
public long Right;
public long Parent;
public long Key;
public State Balance;

public Node()
{
Left = 0;
Right = 0;
Parent = 0;
Balance = State.Header;
Key = 0;
}
public Node(long p)
{
Left = 0;
Right = 0;
Parent = p;
Balance = State.Balanced;
Key = 0;
}

public Boolean IsHeader () { return Balance == State.Header; }
}
</lang>

Latest revision as of 12:05, 23 May 2017

The Java version was ported from C# in 2016. The port of the full Calculus class library took only a week. [User:NNcNannara|NNcNannara]] (talk) 10:20, 11 July 2016 (UTC)

The abbreviated version of Java on the main page will suffer in performance just like the C++ version on the main page - see C++ Talk.

The Java implementation of AVL Trees is a bit different to the C# version in that references to references are not available. This means that functions like RotateLeft and RotateRight return the new node rather than the function updating the reference for you. It is only a cosmetic change to the code. NNcNannara (talk) 11:25, 16 July 2016 (UTC)