<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"lang="en-US" xml:lang="en-US" itemscope="itemscope" itemtype="http://schema.org/Article">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" href="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/style.css" type="text/css" media="screen" />
        <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <link rel="stylesheet" href="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/a2-bigmobile.css" type="text/css" media="screen and (max-width: 860px)" />
        <link rel="stylesheet" href="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/a3-smallmobile.css" type="text/css" media="screen and (max-width: 560px)" />
        
        <!--[if lt IE 8]><link rel="stylesheet" href="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/ie.css" type="text/css" media="screen" /><![endif]-->
        <link rel="shortcut icon" href="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/images/favicon.ico" type="image/x-icon" />
        <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="https://blog.blackbam.at/feed/" />
        <link rel="alternate" type="text/xml" title="RSS .92" href="https://blog.blackbam.at/feed/rss/" />
        <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="https://blog.blackbam.at/feed/atom/" />
        <link rel="pingback" href="https://blog.blackbam.at/xmlrpc.php" />
<meta name='robots' content='max-image-preview:large' />
	<style>img:is([sizes="auto" i], [sizes^="auto," i]) { contain-intrinsic-size: 3000px 1500px }</style>
	<link rel='dns-prefetch' href='//www.googletagmanager.com' />
<link rel='dns-prefetch' href='//static.addtoany.com' />
<link rel="alternate" type="application/rss+xml" title="Blackbams Blog &raquo; AVL tree implementation in Java Comments Feed" href="https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/feed/" />
    <meta name="robots" content="all,index,follow,noodp" />
    <!-- BEGIN CIS HEADER -->

    <!-- Standard Tags -->
    <title itemprop="name">AVL tree implementation in Java • algorithms and data structures AVL tree  • Blackbams Blog</title>
    <meta name="description" lang="en-US" content="Java, Programming • 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 [...]" />
    <meta name="author" content="David Stöckl" />
    <meta name="publisher" content="David Stöckl" />

    <!-- Search Engines: Schema -->
    <meta itemprop="description" content="Java, Programming • 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 [...]" />
    <meta itemprop="primaryImageOfPage" content="https://blog.blackbam.at/wp-content/uploads/2019/03/imagex.jpg" />
    
    <!-- Open Graph -->
    <meta property="og:locale" content="en_US"/>
    <meta property="og:site_name" content="Blackbams Blog" />
    <meta property="og:type" content="website" />
    <meta property="og:title" content="AVL tree implementation in Java • algorithms and data structures AVL tree  • Blackbams Blog" />
    <meta property="og:description" content="Java, Programming • 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 [...]" />
    <meta property="og:url" content="https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/" />
    <meta property="og:image" content="https://blog.blackbam.at/wp-content/uploads/2019/03/imagex.jpg" />
    <meta property="og:updated_time" content="2012-12-25T11:52:06+0000" />
    <!-- Twitter -->
    <meta name="twitter:title" content="AVL tree implementation in Java • algorithms and data structures AVL tree  • Blackbams Blog"/>
    <meta name="twitter:description" content="Java, Programming • 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 [...]"/>
    <meta name="twitter:url" content="https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/"/>
    <meta name="twitter:card" content="summary_large_image"/>
    <meta name="twitter:image" content="https://blog.blackbam.at/wp-content/uploads/2019/03/imagex.jpg">
    
    <link rel="pingback" href="https://blog.blackbam.at/xmlrpc.php" />
    <link rel="shortlink" href="" />
            <link itemprop="url" rel="canonical" href="https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/" />
    
    <!-- app colors -->
    <meta name="msapplication-TileColor" content="#272c36">
    <meta name="theme-color" content="#272c36">

    <!-- favicon & app icon -->
                <link rel="apple-touch-icon" sizes="57x57" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=57&h=57&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="60x60" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=60&h=60&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="72x72" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=72&h=72&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="76x76" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=76&h=76&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="114x114" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=114&h=114&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="120x120" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=120&h=120&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="144x144" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=144&h=144&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="152x152" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=152&h=152&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="180x180" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=180&h=180&q=80&zc=1">
                    <link rel="icon" type="image/png" sizes="192x192" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=192&h=192&q=80&zc=1">
                    <link rel="icon" type="image/png" sizes="32x32" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=32&h=32&q=80&zc=1">
                    <link rel="icon" type="image/png" sizes="96x96" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=96&h=96&q=80&zc=1">
                    <link rel="icon" type="image/png" sizes="60x60" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=60&h=60&q=80&zc=1">
            <!-- END CIS HEADER -->
    <link rel='stylesheet' id='cis-gdpr-footer-css' href='https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/addons/gdpr-footer/gdpr-footer.css?ver=173' type='text/css' media='all' />
<link rel='stylesheet' id='wp-block-library-css' href='https://blog.blackbam.at/wp-includes/css/dist/block-library/style.min.css?ver=6.8.1' type='text/css' media='all' />
<style id='classic-theme-styles-inline-css' type='text/css'>
/*! This file is auto-generated */
.wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
</style>
<style id='global-styles-inline-css' type='text/css'>
:root{--wp--preset--aspect-ratio--square: 1;--wp--preset--aspect-ratio--4-3: 4/3;--wp--preset--aspect-ratio--3-4: 3/4;--wp--preset--aspect-ratio--3-2: 3/2;--wp--preset--aspect-ratio--2-3: 2/3;--wp--preset--aspect-ratio--16-9: 16/9;--wp--preset--aspect-ratio--9-16: 9/16;--wp--preset--color--black: #000000;--wp--preset--color--cyan-bluish-gray: #abb8c3;--wp--preset--color--white: #ffffff;--wp--preset--color--pale-pink: #f78da7;--wp--preset--color--vivid-red: #cf2e2e;--wp--preset--color--luminous-vivid-orange: #ff6900;--wp--preset--color--luminous-vivid-amber: #fcb900;--wp--preset--color--light-green-cyan: #7bdcb5;--wp--preset--color--vivid-green-cyan: #00d084;--wp--preset--color--pale-cyan-blue: #8ed1fc;--wp--preset--color--vivid-cyan-blue: #0693e3;--wp--preset--color--vivid-purple: #9b51e0;--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple: linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%);--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan: linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%);--wp--preset--gradient--luminous-vivid-amber-to-luminous-vivid-orange: linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%);--wp--preset--gradient--luminous-vivid-orange-to-vivid-red: linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%);--wp--preset--gradient--very-light-gray-to-cyan-bluish-gray: linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%);--wp--preset--gradient--cool-to-warm-spectrum: linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%);--wp--preset--gradient--blush-light-purple: linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%);--wp--preset--gradient--blush-bordeaux: linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%);--wp--preset--gradient--luminous-dusk: linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%);--wp--preset--gradient--pale-ocean: linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%);--wp--preset--gradient--electric-grass: linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%);--wp--preset--gradient--midnight: linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%);--wp--preset--font-size--small: 13px;--wp--preset--font-size--medium: 20px;--wp--preset--font-size--large: 36px;--wp--preset--font-size--x-large: 42px;--wp--preset--spacing--20: 0.44rem;--wp--preset--spacing--30: 0.67rem;--wp--preset--spacing--40: 1rem;--wp--preset--spacing--50: 1.5rem;--wp--preset--spacing--60: 2.25rem;--wp--preset--spacing--70: 3.38rem;--wp--preset--spacing--80: 5.06rem;--wp--preset--shadow--natural: 6px 6px 9px rgba(0, 0, 0, 0.2);--wp--preset--shadow--deep: 12px 12px 50px rgba(0, 0, 0, 0.4);--wp--preset--shadow--sharp: 6px 6px 0px rgba(0, 0, 0, 0.2);--wp--preset--shadow--outlined: 6px 6px 0px -3px rgba(255, 255, 255, 1), 6px 6px rgba(0, 0, 0, 1);--wp--preset--shadow--crisp: 6px 6px 0px rgba(0, 0, 0, 1);}:where(.is-layout-flex){gap: 0.5em;}:where(.is-layout-grid){gap: 0.5em;}body .is-layout-flex{display: flex;}.is-layout-flex{flex-wrap: wrap;align-items: center;}.is-layout-flex > :is(*, div){margin: 0;}body .is-layout-grid{display: grid;}.is-layout-grid > :is(*, div){margin: 0;}:where(.wp-block-columns.is-layout-flex){gap: 2em;}:where(.wp-block-columns.is-layout-grid){gap: 2em;}:where(.wp-block-post-template.is-layout-flex){gap: 1.25em;}:where(.wp-block-post-template.is-layout-grid){gap: 1.25em;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-color{color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-color{color: var(--wp--preset--color--white) !important;}.has-pale-pink-color{color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-color{color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-color{color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-color{color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-color{color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-color{color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-color{color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-color{color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-color{color: var(--wp--preset--color--vivid-purple) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-background-color{background-color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-pale-pink-background-color{background-color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-background-color{background-color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-background-color{background-color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-background-color{background-color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-background-color{background-color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-background-color{background-color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-background-color{background-color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-background-color{background-color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-background-color{background-color: var(--wp--preset--color--vivid-purple) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-border-color{border-color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-pale-pink-border-color{border-color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-border-color{border-color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-border-color{border-color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-border-color{border-color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-border-color{border-color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-border-color{border-color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-border-color{border-color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-border-color{border-color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-border-color{border-color: var(--wp--preset--color--vivid-purple) !important;}.has-vivid-cyan-blue-to-vivid-purple-gradient-background{background: var(--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple) !important;}.has-light-green-cyan-to-vivid-green-cyan-gradient-background{background: var(--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan) !important;}.has-luminous-vivid-amber-to-luminous-vivid-orange-gradient-background{background: var(--wp--preset--gradient--luminous-vivid-amber-to-luminous-vivid-orange) !important;}.has-luminous-vivid-orange-to-vivid-red-gradient-background{background: var(--wp--preset--gradient--luminous-vivid-orange-to-vivid-red) !important;}.has-very-light-gray-to-cyan-bluish-gray-gradient-background{background: var(--wp--preset--gradient--very-light-gray-to-cyan-bluish-gray) !important;}.has-cool-to-warm-spectrum-gradient-background{background: var(--wp--preset--gradient--cool-to-warm-spectrum) !important;}.has-blush-light-purple-gradient-background{background: var(--wp--preset--gradient--blush-light-purple) !important;}.has-blush-bordeaux-gradient-background{background: var(--wp--preset--gradient--blush-bordeaux) !important;}.has-luminous-dusk-gradient-background{background: var(--wp--preset--gradient--luminous-dusk) !important;}.has-pale-ocean-gradient-background{background: var(--wp--preset--gradient--pale-ocean) !important;}.has-electric-grass-gradient-background{background: var(--wp--preset--gradient--electric-grass) !important;}.has-midnight-gradient-background{background: var(--wp--preset--gradient--midnight) !important;}.has-small-font-size{font-size: var(--wp--preset--font-size--small) !important;}.has-medium-font-size{font-size: var(--wp--preset--font-size--medium) !important;}.has-large-font-size{font-size: var(--wp--preset--font-size--large) !important;}.has-x-large-font-size{font-size: var(--wp--preset--font-size--x-large) !important;}
:where(.wp-block-post-template.is-layout-flex){gap: 1.25em;}:where(.wp-block-post-template.is-layout-grid){gap: 1.25em;}
:where(.wp-block-columns.is-layout-flex){gap: 2em;}:where(.wp-block-columns.is-layout-grid){gap: 2em;}
:root :where(.wp-block-pullquote){font-size: 1.5em;line-height: 1.6;}
</style>
<link rel='stylesheet' id='titan-adminbar-styles-css' href='https://blog.blackbam.at/wp-content/plugins/anti-spam/assets/css/admin-bar.css?ver=7.3.8' type='text/css' media='all' />
<link rel='stylesheet' id='bb-taps-editor-style-shared-css' href='https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/editor-style-shared.css?ver=6.8.1' type='text/css' media='all' />
<style id='akismet-widget-style-inline-css' type='text/css'>

			.a-stats {
				--akismet-color-mid-green: #357b49;
				--akismet-color-white: #fff;
				--akismet-color-light-grey: #f6f7f7;

				max-width: 350px;
				width: auto;
			}

			.a-stats * {
				all: unset;
				box-sizing: border-box;
			}

			.a-stats strong {
				font-weight: 600;
			}

			.a-stats a.a-stats__link,
			.a-stats a.a-stats__link:visited,
			.a-stats a.a-stats__link:active {
				background: var(--akismet-color-mid-green);
				border: none;
				box-shadow: none;
				border-radius: 8px;
				color: var(--akismet-color-white);
				cursor: pointer;
				display: block;
				font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen-Sans', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
				font-weight: 500;
				padding: 12px;
				text-align: center;
				text-decoration: none;
				transition: all 0.2s ease;
			}

			/* Extra specificity to deal with TwentyTwentyOne focus style */
			.widget .a-stats a.a-stats__link:focus {
				background: var(--akismet-color-mid-green);
				color: var(--akismet-color-white);
				text-decoration: none;
			}

			.a-stats a.a-stats__link:hover {
				filter: brightness(110%);
				box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 0 2px rgba(0, 0, 0, 0.16);
			}

			.a-stats .count {
				color: var(--akismet-color-white);
				display: block;
				font-size: 1.5em;
				line-height: 1.4;
				padding: 0 13px;
				white-space: nowrap;
			}
		
</style>
<link rel='stylesheet' id='newsletter-css' href='https://blog.blackbam.at/wp-content/plugins/newsletter/style.css?ver=8.8.5' type='text/css' media='all' />
<link rel='stylesheet' id='addtoany-css' href='https://blog.blackbam.at/wp-content/plugins/add-to-any/addtoany.min.css?ver=1.16' type='text/css' media='all' />
<script type="text/javascript" src="https://blog.blackbam.at/wp-includes/js/jquery/jquery.min.js?ver=3.7.1" id="jquery-core-js"></script>
<script type="text/javascript" src="https://blog.blackbam.at/wp-includes/js/jquery/jquery-migrate.min.js?ver=3.4.1" id="jquery-migrate-js"></script>
<script type="text/javascript" id="cis-js-globals-js-extra">
/* <![CDATA[ */
var CISJSGLOBALS = {"template_url":"https:\/\/blog.blackbam.at\/wp-content\/themes\/SilentWoodsByBlackbam","imageserver_url":"https:\/\/blog.blackbam.at\/wp-content\/mu-plugins\/code-is-passion-libraries-plugin\/imageserver\/imageserver.php","default_image":"https:\/\/blog.blackbam.at\/wp-content\/mu-plugins\/code-is-passion-libraries-plugin\/images\/default.svg"};
/* ]]> */
</script>
<script type="text/javascript" src="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/base/codeispassion-libraries.js?ver=1" id="cis-js-globals-js"></script>
<script type="text/javascript" id="lib-cis-il8n-js-extra">
/* <![CDATA[ */
var CIS_I8 = {"enable":"1","cur":"en","default":"en","lan":["en","de"],"suffixes":["","____de"],"lanmap":{"en":"English","de":"Deutsch"},"sep":"____","qtrans":""};
/* ]]> */
</script>
<script type="text/javascript" src="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/il8n/js/lib_cis_il8n.js?ver=173" id="lib-cis-il8n-js"></script>
<script src='https://www.googletagmanager.com/gtag/js?id=UA-136689836-1&ver=1' async></script><script type="text/javascript" id="cis-seo-google-analytics-header-js-after">
/* <![CDATA[ */
window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-136689836-1');
/* ]]> */
</script>
<script type="text/javascript" id="addtoany-core-js-before">
/* <![CDATA[ */
window.a2a_config=window.a2a_config||{};a2a_config.callbacks=[];a2a_config.overlays=[];a2a_config.templates={};
/* ]]> */
</script>
<script type="text/javascript" defer src="https://static.addtoany.com/menu/page.js" id="addtoany-core-js"></script>
<script type="text/javascript" defer src="https://blog.blackbam.at/wp-content/plugins/add-to-any/addtoany.min.js?ver=1.1" id="addtoany-jquery-js"></script>
<link rel="https://api.w.org/" href="https://blog.blackbam.at/wp-json/" /><link rel="alternate" title="JSON" type="application/json" href="https://blog.blackbam.at/wp-json/wp/v2/posts/1891" /><link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://blog.blackbam.at/xmlrpc.php?rsd" />
<meta name="generator" content="WordPress 6.8.1" />
<link rel='shortlink' href='https://blog.blackbam.at/?p=1891' />
<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="https://blog.blackbam.at/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fblog.blackbam.at%2F2012%2F05%2F04%2Favl-tree-implementation-in-java%2F" />
<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="https://blog.blackbam.at/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fblog.blackbam.at%2F2012%2F05%2F04%2Favl-tree-implementation-in-java%2F&#038;format=xml" />
	<style type="text/css">
		.chi_display_header {
			background-repeat:no-repeat;
			background-position:center center;
		}
	</style>
<style type="text/css">
.qtranxs_flag_de {background-image: url(https://blog.blackbam.at/wp-content/plugins/qtranslate-xt/flags/de.png); background-repeat: no-repeat;}
.qtranxs_flag_en {background-image: url(https://blog.blackbam.at/wp-content/plugins/qtranslate-xt/flags/gb.png); background-repeat: no-repeat;}
</style>
<link hreflang="de" href="https://blog.blackbam.at/de/2012/05/04/avl-tree-implementation-in-java/comment-page-1/" rel="alternate" />
<link hreflang="en" href="https://blog.blackbam.at/en/2012/05/04/avl-tree-implementation-in-java/comment-page-1/" rel="alternate" />
<link hreflang="x-default" href="https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/comment-page-1/" rel="alternate" />
<meta name="generator" content="qTranslate-XT 3.5.3" />
<style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>    </head>
    <body class="wp-singular post-template-default single single-post postid-1891 single-format-standard wp-theme-SilentWoodsByBlackbam">
        <div id="container">
            <div id="content">
                <div id="leftcontent">
                </div>
                <div id="rightcontent">
                </div>
                <div id="ctborder">
                    <div id="incontent">
                        <div id="inincontent">
                            <div id="head">
                                <div id="headings">
                                    <div id="logo">
                                        <img id="logo_img" src="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/images/logo.jpg" width="70" height="70" alt="" />
                                    </div>
                                    <div id="bloginfo">
                                        <h1 id="blogtitle"><a href="https://blog.blackbam.at">Blackbams Blog</a></h1>
                                        <h3 id="blogdescription">development &#8211; digital arts &#8211; internet</h3>
                                    </div>
                                    <!-- bloginfo div -->
									<style type="text/css">
.qtranxs_widget ul { margin: 0; }
.qtranxs_widget ul li
{
display: inline; /* horizontal list, use "list-item" or other appropriate value for vertical list */
list-style-type: none; /* use "initial" or other to enable bullets */
margin: 0 5px 0 0; /* adjust spacing between items */
opacity: 0.5;
-o-transition: 1s ease opacity;
-moz-transition: 1s ease opacity;
-webkit-transition: 1s ease opacity;
transition: 1s ease opacity;
}
/* .qtranxs_widget ul li span { margin: 0 5px 0 0; } */ /* other way to control spacing */
.qtranxs_widget ul li.active { opacity: 0.8; }
.qtranxs_widget ul li:hover { opacity: 1; }
.qtranxs_widget img { box-shadow: none; vertical-align: middle; display: initial; }
.qtranxs_flag { height:12px; width:18px; display:block; }
.qtranxs_flag_and_text { padding-left:20px; }
.qtranxs_flag span { display:none; }
</style>
<div id="sidebar_header">
<ul class="language-chooser language-chooser-both qtranxs_language_chooser" id="qtranslate-5-chooser">
<li><a href="https://blog.blackbam.at/de/2012/05/04/avl-tree-implementation-in-java/comment-page-1/" class="qtranxs_flag_de qtranxs_flag_and_text" title="Deutsch (de)"><span>Deutsch</span></a></li>
<li class="active"><a href="https://blog.blackbam.at/en/2012/05/04/avl-tree-implementation-in-java/comment-page-1/" class="qtranxs_flag_en qtranxs_flag_and_text" title="English (en)"><span>English</span></a></li>
</ul><div class="qtranxs_widget_end"></div>
</div>       
									<div id="daily_featured">
										<p>Knowledge is free. No one may take possession of it.</p>
									</div>
									<div class="clear"> </div>                
                                </div>
                                <!-- headings div -->
                                <div id="picture">
                                    <div id="inpicture">
                                        <!-- background image -->
                                    </div>
                                    <!-- inpicture div -->
                                </div>
                                <!-- picture div -->
                                <div style="clear:both;">
                                </div>
                                <div id="main_navigation" class="wp-nav-menu-wrapper "><ul id="menu-main" class="menu"><li id="menu-item-928" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home cis-level-0 menu-item-928"><a href="https://blog.blackbam.at/">Overview</a></li>
<li id="menu-item-929" class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-929"><a href="https://blog.blackbam.at/blackbams-links/">Linklist</a></li>
<li id="menu-item-930" class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-930"><a href="https://blog.blackbam.at/developer-news/">Developer News</a></li>
<li id="menu-item-932" class="menu-item menu-item-type-custom menu-item-object-custom cis-level-0 menu-item-932"><a href="https://blog.blackbam.at/2010/10/25/core-theme/">WP Core Theme</a></li>
<li id="menu-item-931" class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-931"><a href="https://blog.blackbam.at/impressum/">About this blog</a></li>
</ul></div>                                
                                <div id="menu_mobile" class="mobile-only">
                                    <div id="menu_mobile_bar"></div>
                                    <div id="menu_mobile_inner">
                                        <div class="menu_mobile_closer"></div>
                                            <div id="menu_mobile_actual" class="wp-nav-menu-wrapper "><ul id="menu-main-1" class="menu"><li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home cis-level-0 menu-item-928"><a href="https://blog.blackbam.at/">Overview</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-929"><a href="https://blog.blackbam.at/blackbams-links/">Linklist</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-930"><a href="https://blog.blackbam.at/developer-news/">Developer News</a></li>
<li class="menu-item menu-item-type-custom menu-item-object-custom cis-level-0 menu-item-932"><a href="https://blog.blackbam.at/2010/10/25/core-theme/">WP Core Theme</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-931"><a href="https://blog.blackbam.at/impressum/">About this blog</a></li>
</ul></div>                                    </div>
                                </div>
                                
                                
                                
                            </div>
                            <!-- head div -->
                            <div style="clear:both;">
                            </div>
                            <div id="mainpart">
                                <!-- Ende des Kopfbereichs -->

<div id="single_article">


<div id="single_nav">
			<div class="lfloat">&laquo; <a href="https://blog.blackbam.at/2012/06/25/custom-header-images-plugin-for-wordpress/" rel="next">Custom Header Images Plugin for WordPress</a></div>
			<div class="rfloat"><a href="https://blog.blackbam.at/2012/03/23/wordpress-and-mailchimp-custom-newsletter-subscription-form/" rel="prev">WordPress and Mailchimp: Custom Newsletter Subscription Form</a> &raquo;</div>
</div><!-- single_nav div -->
<div style="clear:both;"></div>
<div id="single_bord1"></div>

	<div id="post-1891">
			<div class="wp_article_head">
         	  <div class="date_auth">
          		 <div class="date">
           		  4. May 2012          	     </div><!-- date div -->
            	 <div class="author">
            	 von Blackbam           	     </div><!-- author div -->
             </div><!-- date_auth div -->
             <div class="art_head">
               <h1>|| <a href="https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/" rel="bookmark" title="Permalink: AVL tree implementation in Java">AVL tree implementation in Java</a></h1>
            </div><!-- art_head div -->
            </div><!-- wp_article_head div -->
           <div class="art_seperator">
           </div> <!-- art_seperator div -->
           <div class="art_content">
           		<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>
<div class="addtoany_share_save_container addtoany_content addtoany_content_bottom"><div class="a2a_kit a2a_kit_size_32 addtoany_list" data-a2a-url="https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/" data-a2a-title="AVL tree implementation in Java"><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share"><img src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></div></div>            </div><!-- art_content div -->
                
                
			<div id="single_zusatz">
				<p>
				
												Dieser Eintrag wurde am 4. May 2012 um 22:22 in der Kategorie <a href="https://blog.blackbam.at/category/programming/java/" rel="category tag">Java</a>, <a href="https://blog.blackbam.at/category/programming/" rel="category tag">Programming</a> ver&ouml;ffentlicht.						You can book the comments for this article <a href='https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/feed/'>RSS 2.0</a>. 
													Feedback, discussion, commendation and critics are welcome: <a href=\"#respond\">Write a comment</a> or <a href=\"https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/trackback/\" rel=\"trackback\">trackback</a>.
						                    
                                       <!-- pruefen ob externe links zu dem Thema existieren und sie ausgeben, benoetigt ext_related_links plugin -->
                    
                    
                   </p>
               <br/><p>Tags: <a href="https://blog.blackbam.at/tag/algorithms-and-data-structures/" rel="tag">algorithms and data structures</a>, <a href="https://blog.blackbam.at/tag/avl-tree/" rel="tag">AVL tree</a></p>  
   		   </div> <!-- single_zusatz div -->		   		   	</div> <!-- single_article div -->

    	

<div id="comments">
<h3 id="cmt_head">Already 37 comments belonging to "AVL tree implementation in Java": </h3>
<p id="cmt_und"><a href="https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/feed/">Kommentare abonnieren (RSS)</a> or <a href="https://blog.blackbam.at/2012/05/04/avl-tree-implementation-in-java/trackback/">URL Trackback</a></p>





<div id="comment-1333" class="kommentar">
	
	<div class="gravatar">
		<img alt='' src='https://secure.gravatar.com/avatar/6b94bb9c2aeb622387fcb2fea48a4cb5fdf1904c81f91c2aabca36b6bc44c448?s=48&#038;d=mm&#038;r=r' srcset='https://secure.gravatar.com/avatar/6b94bb9c2aeb622387fcb2fea48a4cb5fdf1904c81f91c2aabca36b6bc44c448?s=96&#038;d=mm&#038;r=r 2x' class='avatar avatar-48 photo' height='48' width='48' decoding='async'/>	</div>
	
	<div class="outer_comment_box">
		<div class="comment_box">
		<h4> <a href="mailto:eva.wolfe@hotmail.com">Random Student</a><a href="mailto:eva.wolfe@hotmail.com">&#160;<img src="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/images/mail.jpg" width="11" height="12" alt="" /></a>&#160;&#160;says: </h4>
		
		<p id="cmt_infozst">on 05. September 2012 at 10:31 on clock </p>
		<br />
		Thanks! This really helped me a lot!		</div><!-- comment_box div -->
		
		<div style="clear:both;"></div>
		</div>
	<div style="clear:both;"></div>

</div><!-- kommentar div -->






<div id="comment-1619" class="kommentar">
	
	<div class="gravatar">
		<img alt='' src='https://secure.gravatar.com/avatar/c39e033e56139fd1e9fa05c7a9e109364d22ef6201609b7d56a9a5695ddb6836?s=48&#038;d=mm&#038;r=r' srcset='https://secure.gravatar.com/avatar/c39e033e56139fd1e9fa05c7a9e109364d22ef6201609b7d56a9a5695ddb6836?s=96&#038;d=mm&#038;r=r 2x' class='avatar avatar-48 photo' height='48' width='48' decoding='async'/>	</div>
	
	<div class="outer_comment_box">
		<div class="comment_box">
		<h4> <a href="mailto:Gshapir@gmail.com">Gil</a><a href="mailto:Gshapir@gmail.com">&#160;<img src="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/images/mail.jpg" width="11" height="12" alt="" /></a>&#160;&#160;says: </h4>
		
		<p id="cmt_infozst">on 21. November 2012 at 17:31 on clock </p>
		<br />
		There is a typo in the debug helper method:
if(n.right!=null) {
   l = n.right.key;
  }

Should be r - not l		</div><!-- comment_box div -->
		
		<div style="clear:both;"></div>
		</div>
	<div style="clear:both;"></div>

</div><!-- kommentar div -->






<div id="comment-1620" class="kommentar">
	
	<div class="gravatar">
		<img alt='' src='https://secure.gravatar.com/avatar/d5a5c9cf6d94c8c10375b6fb48c0cc28e9df3c4d446ca18611bb544b274dd20e?s=48&#038;d=mm&#038;r=r' srcset='https://secure.gravatar.com/avatar/d5a5c9cf6d94c8c10375b6fb48c0cc28e9df3c4d446ca18611bb544b274dd20e?s=96&#038;d=mm&#038;r=r 2x' class='avatar avatar-48 photo' height='48' width='48' decoding='async'/>	</div>
	
	<div class="outer_comment_box">
		<div class="comment_box">
		<h4> <a href="mailto:blackbam@hotmail.de">Blackbam</a><a href="mailto:blackbam@hotmail.de">&#160;<img src="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/images/mail.jpg" width="11" height="12" alt="" /></a> <a href="https://blog.blackbam.at/">&#160;<img src="<error>
    <code>internal_server_error</code>
    <title><![CDATA[WordPress &amp;rsaquo; Error]]></title>
    <message><![CDATA[&lt;p&gt;There has been a critical error on this website.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://wordpress.org/documentation/article/faq-troubleshooting/&quot;&gt;Learn more about troubleshooting WordPress.&lt;/a&gt;&lt;/p&gt;]]></message>
    <data>
        <status>500</status>
    </data>
</error>
