### Find missing number between 1 to 100 in unsortedArray - consume less memory in java

In this core java programming tutorial we will write a program to Find missing number between 1 to 100 in unsortedArray - consume less memory in java.

Logic>
First, we will use mergeSort to sort the array. Then, we will iterate from 1 to 100 (keep it in variable i) and compare i with sorted array and find out missing numbers.

Complexity of using merge sort will be O(nlogn)
complexity of iterating from 1 to 100 will  be O(n).

so overall complexity of our operation will be O(nlogn) +  O(n).
And we won’t be consuming any extra memory (though we will consume bit of extra memory used by mergeSort in sorting).

Full Program/SourceCode / Example in java to Find missing number between 1 to 100 in unsorted Array - consume less memory >
 /** Copyright (c), AnkitMittal  JavaMadeSoEasy.com */ public class FindMissingNumberInUnSortedArray{    static int ar[]={3,7,5,8,44,24};  //given array       public static void main(String[] args) {           System.out.print("given array : ");           for (int j = 0; j < ar.length; j++)                  System.out.print(ar[j] +" "); // display it                     mergeSortWrapper();           displayMissing();          }       static void mergeSortWrapper(){           int ar2[]=new int[ar.length];           mergeSort(ar2,0,ar.length-1);            }       static void mergeSort(int ar2[],int lowBound,int highBound){           int mid;                     if(lowBound==highBound)                  return;           else                  mid=(lowBound+highBound)/2;                     mergeSort(ar2, lowBound, mid); //sort lower           mergeSort(ar2, mid+1, highBound);//sort upper                     merging(ar2,lowBound,mid+1,highBound);    }       static void merging(int  ar2[],int lowBound,int highPtr,int highBound){                     int j=lowBound;           int lowptr=highPtr-1;           int n=highBound-lowBound+1;           int lowBoundCount=lowBound;                     while(lowBound<=lowptr && highPtr<=highBound){                  if(ar[lowBound]

Having any doubt? or you you liked the tutorial! Please comment in below section.