Mergesort in java

Mergesort is a divide and conquer algorithm. It works by breaking an array into sub-arrays and then recursively sorting the sub-arrays. Steps for Mergesort Divide the list with n elements into n sublists with each sublist having 1 element. We will divide list into 2 sublists by dividing in the middle and then recursively dividing … [Read more…]

How to take input from user in java

The simplest and the easiest way to read the user input in java is by using the Java scanner class. What is scanner class? java.util.Scanner is a simple text scanner that can parse primitive types and strings using regular expressions. The input to Scanner class is broken into tokens using a delimiter pattern, which by … [Read more…]

Autoboxing and its pitfalls

Autoboxing What is Autoboxing? Autoboxing is a feature of Java language introduced in Java 1.5.  When Java compiler makes automatic conversion between the primitive types and their corresponding object wrapper class, it is called autoboxing.  The process of creating a Wrapper class like Float from a primitive type like float is called boxing.  And the process of creating … [Read more…]

Java interview questions, coding in a team

When a programmer joins a team, he is at least expected to have a basic understanding of the process of handling  code within a team. And the following questions have been taken from real world interviews and groups discussions Q. How can a team work on a code that is used by a team of … [Read more…]

Eclipse, svn folder properties

Changes in properties of a folder. When you are adding a file to svn ignore list then you need to commit the top folder. Because you have changed the properties of the folder. svn:ignore list is not a local list. I always thought so. The svn ignore list is in the properties of that folder that exists in … [Read more…]

Quicksort in Java

Quicksort is a divide and conquer algorithm. It works by breaking an array into two sub-arrays and then recursively sort the sub-arrays. Steps for QuickSort Select the pivot element.  Any element that you choose would be called the pivot element. All the elements that are smaller than the pivot element are kept in one array … [Read more…]

Delete nodes from a Tree in Java

In this tutorial we will see how to delete nodes from a Tree. In my last tutorial create and traverse java tree tutorial I showed how to create a tree and then we also looked at an example of traversing the tree. Reference Tree The image below shows the Tree that we will use in this … [Read more…]

Java Tree implementation

In this tutorial I am going to show a simple Tree data structure implemented in Java.We will see how to create Tree data structure and also a mechanism of traversing the tree in a very easy way. The Tree which we will create in this tutorial will be the java representation of the image shown … [Read more…]