How to Create a Max Heap using an Array in Java

A Heap/Binary Heap is a data structure that takes the form of Binary Tree. Heaps are commonly used to implement priority queues (check out the PriorityQueue class in Java). Priority queues are great ways to identify the highest (or lowest) priority items in a collection. A Max Heap is a binary tree data structure in

read more

How to Create a Hash Table in Java (Chaining Example)

Knowing how to create a hash table is helpful when using built-in HashTable and HashMap implementations in various languages. Questions about hash tables are commonly asked in programming interviews, and often people are asked to create an implementation from scratch. Below is an example of how to create a hash table in Java using “chaining”

read more

How to Reverse a Linked List

A common algorithm question is “How to Reverse a Linked List”. Below the SimpleLinkedList (Java) class contains a simple example to follow. The class SimpleLinkedList contains one field, head, which is used to keep track of the head (first) node of the linked list.

The nested class Node is the class used to create

read more

Java Binary Search Tree Implementation

The Binary Search Tree is commonly used data structure in Computer Science. Below is a complete binary search tree implementation, including the standard methods used to find, insert, and delete nodes from the tree. In addition are methods to print tree structure as well as track of the number nodes (so the tree size can

read more