Category Archives: Code Snippets

posts in this category contain code for some popular problems which can help you while coding an algorithm.

Bubble Sort java code

Bubble sort  is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in wrong order. We make several passes over the list till no swaps are needed, which indicates that the list is sorted. For more information on bubble sort visit Complexity… Read More »

Merge Sort Code

Merge Sort belongs to category of divide and conquer algorithms. Which means it divides the problem into  small subproblems, solves them and then combine the solutions of these subproblems to generate solution  of the original problem.Merge Sort compares elements with each other for sorting the list. The steps followed to mergesort are are: Divide the unsorted list… Read More »