AVL Tree in Java

An AVL tree is a self-balancing binary tree. That’s all I remember from when I wrote this java implementation of an AVL Tree a few years ago. This code may …

Binary Tree Implementation in Java

This is an implementation of a binary tree in Java. Binary Tree The following java class is the representation of a Binary Tree, which includes common methods such as insert(), …

Checking if a String is a Palindrome in Java

A palindrome is a string which, when reversed, is the same string. The following code contains two implementations of checking if a string is a palindrome: isPalindrome() works by iteratively …

Check Balanced Parantheses in Java

Here’s an function implemented in Java to check whether a string contains balanced parentheses. Examples isBalanced(“((()))”) returns true isBalanced(“(()()())”) returns true isBalanced(“(()()()”) returns false isBalanced(“()())”) returns false Implementation

GCD Algorithm: Greatest Common Divisor in Java

Here are three different implementations of the classic GCD (Greatest Common Divisor) problem. Iterative (Linear) It wouldn’t make sense to ever implement the iterative linear approach due to its time …

Stack Implementation in Java

Unlike the implementation of a double queue, a stack is a collection of items kept in order such that the item last inserted into the stack is the first one …