<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Programming &#8211; Blackbams Blog</title>
	<atom:link href="https://blog.blackbam.at/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.blackbam.at</link>
	<description>development - digital arts - internet</description>
	<lastBuildDate>Wed, 23 Jan 2013 08:38:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>Java RMI five Minutes tutorial</title>
		<link>https://blog.blackbam.at/2013/01/23/java-rmi-5-minutes-tutorial/</link>
					<comments>https://blog.blackbam.at/2013/01/23/java-rmi-5-minutes-tutorial/#respond</comments>
		
		<dc:creator><![CDATA[Blackbam]]></dc:creator>
		<pubDate>Wed, 23 Jan 2013 08:38:47 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[rmi]]></category>
		<category><![CDATA[Tutorial]]></category>
		<guid isPermaLink="false">https://blog.blackbam.at/?p=2030</guid>

					<description><![CDATA[This ultra short tutorial is just a summary of how Java RMI (remote method invocation) works. For explanation please check one of the other tutorials which you will find easily easily your favorite search engine. 1. Write RMI-Server Interface extends package java.rmi.Remote provide all methods to be called remotely each methods must through a remote [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>This ultra short tutorial is just a summary of how Java RMI (remote method invocation) works. For explanation please check one of the other tutorials which you will find easily easily your favorite search engine.</p>
<h2>1. Write RMI-Server Interface</h2>
<ul>
<li>extends package java.rmi.Remote</li>
<li>provide all methods to be called remotely</li>
<li>each methods must through a remote exception</li>
</ul>
<pre lang="java">
import java.rmi.*;
 
public interface ServerInterface extends Remote {
     public void method1() throws RemoteException;
     public int method2() throws RemoteException;
     // ...
}</pre>
<h2>2. Write Server Class</h2>
<ul>
<li>implements RMI-Server Interface</li>
<li>extends UnicastRemoteObject (at least for simple RMI)</li>
<li>Constructor throws java.rmi.RemoteException</li>
<li>must be registered at local registry</li>
</ul>
<p>&nbsp;</p>
<pre lang="java"> 
import java.rmi.*;
import java.net.MalformedURLExcpetion;
import java.rmi.registry.*;
import java.rmi.server.UnicastRemoteObject;
 
public class MyServer extends UnicastRemoteObject implements ServerInterface {
 
  MyServer() throws RemoteException {
    super();
  }
 
  public static void main(String[] args) {

    try {
      LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
    } catch (RemoteException ex) {
      System.out.println(ex.getMessage());
    }
    try {
      Naming.rebind("MyServer", new MyServer());
    } catch (MalformedURLException ex) {
      System.out.println(ex.getMessage());
    }
    catch (RemoteException ex) {
      System.out.println(ex.getMessage());
    }
  }
  // ...
}</pre>
<h2>3. Write a client</h2>
<ul>
<li>get remote reference</li>
<li>call remote methods</li>
<li>be careful with rmi-specific problems (a more detailed tutorial will explain to you)</li>
</ul>
<p>&nbsp;</p>
<pre lang="java">// any class, ...
// url expects String in url format (e.g. http://127.0.0.1/MyServer for local testing)
 
try {
      ServerInterface server = (ServerInterface) Naming.lookup(url);
      server.method1();
      int calculated_by_server = server.method2();
      // ...
} catch (Exception ex) {

}</pre>
<p>&nbsp;</p>
<p><strong>API reference:</strong></p>
<ul>
<li>RMI: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/Remote.html" rel="nofollow">Remote API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/server/UnicastRemoteObject.html" rel="nofollow">UnicastRemoteObject API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/registry/Registry.html" rel="nofollow">Registry API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/registry/LocateRegistry.html" rel="nofollow">LocateRegistry API</a></li>
<li>Properties: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/util/Properties.html" rel="nofollow">Properties API</a></li>
<li>IO: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/io/package-summary.html" rel="nofollow">IO Package API</a></li>
</ul>
<p>&nbsp;</p>
<p><strong>Further reading:</strong><br />
<a href="http://docs.oracle.com/javase/tutorial/rmi/index.html">http://docs.oracle.com/javase/tutorial/rmi/index.html</a></p>
<p><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fblog.blackbam.at%2F2013%2F01%2F23%2Fjava-rmi-5-minutes-tutorial%2F&#038;title=Java%20RMI%20five%20Minutes%20tutorial" data-a2a-url="https://blog.blackbam.at/2013/01/23/java-rmi-5-minutes-tutorial/" data-a2a-title="Java RMI five Minutes tutorial"><img src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.blackbam.at/2013/01/23/java-rmi-5-minutes-tutorial/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Learning Java networking and concurrency</title>
		<link>https://blog.blackbam.at/2013/01/22/learning-java-concurrency/</link>
					<comments>https://blog.blackbam.at/2013/01/22/learning-java-concurrency/#comments</comments>
		
		<dc:creator><![CDATA[Blackbam]]></dc:creator>
		<pubDate>Tue, 22 Jan 2013 18:12:19 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[rmi]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://blog.blackbam.at/?p=2025</guid>

					<description><![CDATA[This tutorial is written while learning for a university test in distributed systems. The aim of this article is to remember the most important facts and steps to understand distributed programming in the Java language. This tutorial is useful for programmers which are able to use Java, but want to learn more about concurrency.   [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>This tutorial is written while learning for a university test in distributed systems. The aim of this article is to remember the most important facts and steps to understand distributed programming in the Java language. This tutorial is useful for programmers which are able to use Java, but want to learn more about concurrency.   As oracle provides everything you need to learn that in detail, including examples, this is just a collection of other tutorials you should learn step by step. This collection is adapted from the course of the distributed systems group of the technical university of vienna.</p>
<h2>1. Learning the Basics of Network communication</h2>
<ul>
<li><a href="http://java.sun.com/docs/books/tutorial/networking/overview/networking.html" rel="nofollow">Networking Basics</a>: Short explanation of networking basics like TCP, UDP and ports.</li>
<li><a href="http://java.sun.com/docs/books/tutorial/essential/io/index.html" rel="nofollow">Java IO Tutorial</a>: It&#8217;s absolutely necessary to be familiar with I/O and streams to do sockets operations!</li>
<li><a href="http://java.sun.com/docs/books/tutorial/networking/sockets/index.html" rel="nofollow">Java TCP Sockets Tutorial</a>: A very useful introduction to (TCP) sockets programming.</li>
<li><a href="http://java.sun.com/docs/books/tutorial/networking/datagrams/index.html" rel="nofollow">Java Datagrams Tutorial</a>: Provides all the information you need to send and receive datagram packets using UDP.</li>
<li><a href="http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html" rel="nofollow">Java Concurrency Tutorial</a>: A tutorial about concurrency that covers threads, thread-pools and synchronization.</li>
<li>Java Programmierhandbuch und Referenz &#8211; Section <a href="http://dpunkt.de/java//Programmieren_mit_Java/Netzwerkprogrammierung/16.html" rel="nofollow">13.2.3</a>: German tutorial for using datagram sockets. (optional)</li>
</ul>
<h4>Important Java-API Classes:</h4>
<ul>
<li>IO: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/io/package-summary.html" rel="nofollow">IO Package API</a></li>
<li>Concurrency: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/lang/Thread.html" rel="nofollow">Thread API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/lang/Runnable.html" rel="nofollow">Runnable API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/util/concurrent/ExecutorService.html" rel="nofollow">ExecutorService API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/util/concurrent/Executors.html" rel="nofollow">Executors API</a></li>
<li>Java TCP Sockets: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/net/ServerSocket.html" rel="nofollow">ServerSocket API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/net/Socket.html" rel="nofollow">Socket API</a></li>
<li>Java Datagrams: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/net/DatagramSocket.html" rel="nofollow">DatagramSocket API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/net/DatagramPacket.html" rel="nofollow">DatagramPacket API</a></li>
</ul>
<h2>2. Learning RMI</h2>
<ul>
<li><a href="http://java.sun.com/docs/books/tutorial/rmi/index.html" rel="nofollow">Java RMI Tutorial</a>: A short introduction into RMI.</li>
<li><a href="http://java.sun.com/developer/onlineTraining/rmi/RMI.html" rel="nofollow">JGuru RMI Tutorial</a>: A more detailed tutorial about RMI.</li>
<li><a href="http://sws.bfh.ch/~amrhein/Swing/javainsel7/javainsel_18_002.htm#mj86a2f66f92fc91213a3690e4c513bb4e" rel="nofollow">JavaInsel RMI Tutorial</a>: German introduction into RMI programming. (optional)</li>
</ul>
<h4>Important Java-API Classes:</h4>
<ul>
<li>RMI: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/Remote.html" rel="nofollow">Remote API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/server/UnicastRemoteObject.html" rel="nofollow">UnicastRemoteObject API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/registry/Registry.html" rel="nofollow">Registry API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/registry/LocateRegistry.html" rel="nofollow">LocateRegistry API</a></li>
<li>Properties: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/util/Properties.html" rel="nofollow">Properties API</a></li>
<li>IO: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/io/package-summary.html" rel="nofollow">IO Package API</a></li>
</ul>
<p>&nbsp;</p>
<h2>3. Security</h2>
<ul>
<li>Chapter 9 &#8211; Security from the book <em>Distributed Systems: Principles and Paradigms (2nd edition)</em></li>
<li><a href="http://download.oracle.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html" rel="nofollow">Java Cryptography Architecture (JCA) Reference Guide</a>: Tutorial about the Java Cryptography Architecture (JCA)</li>
<li><a href="http://www.cacr.math.uwaterloo.ca/hac/" rel="nofollow">Handbook of Applied Cryptography</a> (free version) (optional)</li>
</ul>
<h4>Important Java-API Classes:</h4>
<ul>
<li>Java SE 6: <a href="http://download.oracle.com/javase/6/docs/api/javax/crypto/Cipher.html" rel="nofollow">Cipher</a>, <a href="http://download.oracle.com/javase/6/docs/api/java/security/SecureRandom.html" rel="nofollow">SecureRandom</a>, and <a href="http://download.oracle.com/javase/6/docs/api/java/security/Signature.html" rel="nofollow">Signature</a> classes</li>
<li>Bouncy Castle: <a href="http://www.bouncycastle.org/docs/docs1.6/org/bouncycastle/openssl/PEMReader.html" rel="nofollow">PEMReader</a> and <a href="http://www.bouncycastle.org/docs/docs1.6/org/bouncycastle/util/encoders/Base64.html" rel="nofollow">Base64</a></li>
</ul>
<p>&nbsp;</p>
<p><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fblog.blackbam.at%2F2013%2F01%2F22%2Flearning-java-concurrency%2F&#038;title=Learning%20Java%20networking%20and%20concurrency" data-a2a-url="https://blog.blackbam.at/2013/01/22/learning-java-concurrency/" data-a2a-title="Learning Java networking and concurrency"><img src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.blackbam.at/2013/01/22/learning-java-concurrency/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>AVL tree implementation in Java</title>
		<link>https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/</link>
					<comments>https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/#comments</comments>
		
		<dc:creator><![CDATA[Blackbam]]></dc:creator>
		<pubDate>Fri, 04 May 2012 20:38:17 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[algorithms and data structures]]></category>
		<category><![CDATA[AVL tree]]></category>
		<guid isPermaLink="false">https://blog.blackbam.at/?p=1891</guid>

					<description><![CDATA[In the course of my studies I had to implement an AVL-Tree (balanced binary search tree) in Java. When learning the basics of algorithms and data structures, one will probably have to learn about this topic. I want to present my implementation with some useful comments here, be free to use it, if you need. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In the course of my studies I had to implement an AVL-Tree (balanced binary search tree) in Java. When learning the basics of algorithms and data structures, one will probably have to learn about this topic. I want to present my implementation with some useful comments here, be free to use it, if you need. If you <a href="http://en.wikipedia.org/wiki/AVL_tree">want to learn more about AVL-Trees</a>, check Wikipedia. There is also <a href="http://people.ksp.sk/~kuko/bak/">a very useful Java-application</a>, to demonstrate AVL-trees and more.</p>
<p>&nbsp; </p>
<pre lang="java">
import java.util.ArrayList;

/**
 * This class is the complete and tested implementation of an AVL-tree.
 */
public class AvlTree {
	
	protected AvlNode root; // the root node
	
/***************************** Core Functions ************************************/

	/**
	 * Add a new element with key "k" into the tree.
	 * 
	 * @param k
	 *            The key of the new node.
	 */
	public void insert(int k) {
		// create new node
		AvlNode n = new AvlNode(k);
		// start recursive procedure for inserting the node
		insertAVL(this.root,n);
	}
	
	/**
	 * Recursive method to insert a node into a tree.
	 * 
	 * @param p The node currently compared, usually you start with the root.
	 * @param q The node to be inserted.
	 */
	public void insertAVL(AvlNode p, AvlNode q) {
		// If  node to compare is null, the node is inserted. If the root is null, it is the root of the tree.
		if(p==null) {
			this.root=q;
		} else {
			
			// If compare node is smaller, continue with the left node
			if(q.key<p.key) {
				if(p.left==null) {
					p.left = q;
					q.parent = p;
					
					// Node is inserted now, continue checking the balance
					recursiveBalance(p);
				} else {
					insertAVL(p.left,q);
				}
				
			} else if(q.key>p.key) {
				if(p.right==null) {
					p.right = q;
					q.parent = p;
					
					// Node is inserted now, continue checking the balance
					recursiveBalance(p);
				} else {
					insertAVL(p.right,q);
				}
			} else {
				// do nothing: This node already exists
			}
		}
	}
	
	/**
	 * Check the balance for each node recursivly and call required methods for balancing the tree until the root is reached.
	 * 
	 * @param cur : The node to check the balance for, usually you start with the parent of a leaf.
	 */
	public void recursiveBalance(AvlNode cur) {
		
		// we do not use the balance in this class, but the store it anyway
		setBalance(cur);
		int balance = cur.balance;
		
		// check the balance
		if(balance==-2) {
			
			if(height(cur.left.left)>=height(cur.left.right)) {
				cur = rotateRight(cur);
			} else {
				cur = doubleRotateLeftRight(cur);
			}
		} else if(balance==2) {
			if(height(cur.right.right)>=height(cur.right.left)) {
				cur = rotateLeft(cur);
			} else {
				cur = doubleRotateRightLeft(cur);
			}
		}
		
		// we did not reach the root yet
		if(cur.parent!=null) {
			recursiveBalance(cur.parent);
		} else {
			this.root = cur;
			System.out.println("------------ Balancing finished ----------------");
		}
	}

	/**
	 * Removes a node from the tree, if it is existent.
	 */
	public void remove(int k) {
		// First we must find the node, after this we can delete it.
		removeAVL(this.root,k);
	}
	
	/**
	 * Finds a node and calls a method to remove the node.
	 * 
	 * @param p The node to start the search.
	 * @param q The KEY of node to remove.
	 */
	public void removeAVL(AvlNode p,int q) {
		if(p==null) {
			// der Wert existiert nicht in diesem Baum, daher ist nichts zu tun
			return;
		} else {
			if(p.key>q)  {
				removeAVL(p.left,q);
			} else if(p.key<q) {
				removeAVL(p.right,q);
			} else if(p.key==q) {
				// we found the node in the tree.. now lets go on!
				removeFoundNode(p);
			}
		}
	}
	
	/**
	 * Removes a node from a AVL-Tree, while balancing will be done if necessary.
	 * 
	 * @param q The node to be removed.
	 */
	public void removeFoundNode(AvlNode q) {
		AvlNode r;
		// at least one child of q, q will be removed directly
		if(q.left==null || q.right==null) {
			// the root is deleted
			if(q.parent==null) {
				this.root=null;
				q=null;
				return;
			}
			r = q;
		} else {
			// q has two children --> will be replaced by successor
			r = successor(q);
			q.key = r.key;
		}
		
		AvlNode p;
		if(r.left!=null) {
			p = r.left;
		} else {
			p = r.right;
		}
		
		if(p!=null) {
			p.parent = r.parent;
		}
		
		if(r.parent==null) {
			this.root = p;
		} else {
			if(r==r.parent.left) {
				r.parent.left=p;
			} else {
				r.parent.right = p;
			}
			// balancing must be done until the root is reached.
			recursiveBalance(r.parent);
		}
		r = null;
	}
	
	/**
	 * Left rotation using the given node.
	 * 
	 * 
	 * @param n
	 *            The node for the rotation.
	 * 
	 * @return The root of the rotated tree.
	 */
	public AvlNode rotateLeft(AvlNode n) {
		
		AvlNode v = n.right;
		v.parent = n.parent;
		
		n.right = v.left;
		
		if(n.right!=null) {
			n.right.parent=n;
		}
		
		v.left = n;
		n.parent = v;
		
		if(v.parent!=null) {
			if(v.parent.right==n) {
				v.parent.right = v;
			} else if(v.parent.left==n) {
				v.parent.left = v;
			}
		}
		
		setBalance(n);
		setBalance(v);
		
		return v;
	}
	
	/**
	 * Right rotation using the given node.
	 * 
	 * @param n
	 *            The node for the rotation
	 * 
	 * @return The root of the new rotated tree.
	 */
	public AvlNode rotateRight(AvlNode n) {
		
		AvlNode v = n.left;
		v.parent = n.parent;
		
		n.left = v.right;
		
		if(n.left!=null) {
			n.left.parent=n;
		}
		
		v.right = n;
		n.parent = v;
		
		
		if(v.parent!=null) {
			if(v.parent.right==n) {
				v.parent.right = v;
			} else if(v.parent.left==n) {
				v.parent.left = v;
			}
		}
		
		setBalance(n);
		setBalance(v);
		
		return v;
	}
	/**
	 * 
	 * @param u The node for the rotation.
	 * @return The root after the double rotation.
	 */
	public AvlNode doubleRotateLeftRight(AvlNode u) {
		u.left = rotateLeft(u.left);
		return rotateRight(u);
	}
	
	/**
	 * 
	 * @param u The node for the rotation.
	 * @return The root after the double rotation.
	 */
	public AvlNode doubleRotateRightLeft(AvlNode u) {
		u.right = rotateRight(u.right);
		return rotateLeft(u);
	}
	
/***************************** Helper Functions ************************************/
	
	/**
	 * Returns the successor of a given node in the tree (search recursivly).
	 * 
	 * @param q The predecessor.
	 * @return The successor of node q.
	 */
	public AvlNode successor(AvlNode q) {
		if(q.right!=null) {
			AvlNode r = q.right;
			while(r.left!=null) {
				r = r.left;
			}
			return r;
		} else {
			AvlNode p = q.parent;
			while(p!=null && q==p.right) {
				q = p;
				p = q.parent;
			}
			return p;
		}
	}
	
	/**
	 * Calculating the "height" of a node.
	 * 
	 * @param cur
	 * @return The height of a node (-1, if node is not existent eg. NULL).
	 */
	private int height(AvlNode cur) {
		if(cur==null) {
			return -1;
		}
		if(cur.left==null && cur.right==null) {
			return 0;
		} else if(cur.left==null) {
			return 1+height(cur.right);
		} else if(cur.right==null) {
			return 1+height(cur.left);
		} else {
			return 1+maximum(height(cur.left),height(cur.right));
		}
	}
	
	/**
	 * Return the maximum of two integers.
	 */
	private int maximum(int a, int b) {
		if(a>=b) {
			return a;
		} else {
			return b;
		}
	}

	/** 
	 * Only for debugging purposes. Gives all information about a node.
	 
	 * @param n The node to write information about.
	 */
	public void debug(AvlNode n) {
		int l = 0;
		int r = 0;
		int p = 0;
		if(n.left!=null) {
			l = n.left.key;
		}
		if(n.right!=null) {
			r = n.right.key;
		}
		if(n.parent!=null) {
			p = n.parent.key;
		}
		
		System.out.println("Left: "+l+" Key: "+n+" Right: "+r+" Parent: "+p+" Balance: "+n.balance);
		
		if(n.left!=null) {
			debug(n.left);
		}
		if(n.right!=null) {
			debug(n.right);
		}
	}
	
	private void setBalance(AvlNode cur) {
		cur.balance = height(cur.right)-height(cur.left);
	}
	
	/**
	 * Calculates the Inorder traversal of this tree.
	 * 
	 * @return A Array-List of the tree in inorder traversal.
	 */
	final protected ArrayList<AvlNode> inorder() {
		ArrayList<AvlNode> ret = new ArrayList<AvlNode>();
		inorder(root, ret);
		return ret;
	}
	
	/**
	 * Function to calculate inorder recursivly.
	 * 
	 * @param n
	 *            The current node.
	 * @param io
	 *            The list to save the inorder traversal.
	 */
	final protected void inorder(AvlNode n, ArrayList<AvlNode> io) {
		if (n == null) {
			return;
		}
		inorder(n.left, io);
		io.add(n);
		inorder(n.right, io);
	}
}

/** Here is the AVL-Node class for Completenesse **/
public class AvlNode {
	public AvlNode left;
	public AvlNode right;
	public AvlNode parent;
	public int key;
	public int balance;

	public AvlNode(int k) {
		left = right = parent = null;
		balance = 0;
		key = k;
	}
	public String toString() {
		return "" + key;
	}

}


</pre>
<p><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fblog.blackbam.at%2F2012%2F05%2F04%2Favl-tree-implementation-in-java%2F&#038;title=AVL%20tree%20implementation%20in%20Java" data-a2a-url="https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/" data-a2a-title="AVL tree implementation in Java"><img src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/feed/</wfw:commentRss>
			<slash:comments>37</slash:comments>
		
		
			</item>
	</channel>
</rss>
