Category: Algorithms

  • Priority Queue

    Priority Queues are used to short heaps. Priority queues are used in operating system for load balancing and interrupt handling. Priority queues are used in huffman codes for data compression. In traffic light, depending upon the traffic, the colors will be given priority. Difference b/w priority queue and normal queue: In a queue, the first-in-first-out rule is

    Read article →

  • Algorithm Analysis

    Algorithm Analysis

    Runtime Analysis of an Algorithm

    Read article →

  • Binary Search

    Binary Search

    Binary search is used to search a key element from multiple elements. Binary search is faster than linear search. In case of binary search, array elements must be in ascending order. If you have unsorted array, you can sort the array using Arrays. public class BinarySearch { public static void main(String str[]) { int[] elements = new int[]{11,17,18,45,50,71,95,98}; int index = binarySearch(elements,

    Read article →

  • Linear Search

    Linear Search

    The list of array is traversed sequentially and every element is checked. In this type of searching, we simply traverse the list completely and match each element of the list with the item whose location is to be found. If the match found then location of the item is returned otherwise the algorithm return NULL.

    Read article →