# 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 http://en.wikipedia.org/wiki/Bubble_sort. Complexity… Read More »

## Binary Search java code

Binary Search finds the position of a specified value (key) in a sorted array.In each step it discards half of the elements to search , thus the worst case running time of binary search is O(log n).Believe it or not 80 out of 100 of the programmers fail to write the correct code for binary… Read More »

## Reading Input Java Code

We identified various patterns of reading the input which you may encounter while solving a problem on online judge. So whenever you have to read input don’t waste your effort and time writing it again we know you know it , just copy it from here and focus more on the algorithm.We will keep adding… 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 »