Intro to Interfaces

  1. Different sorting algorithms:

  2. Bubble sort on integers:

    Bubble sort algorithm for an integer array:
       input: A = array of integers 
              N = number of elements in A
    
       arrayIsSorted = false;
       while ( ! arrayIsSorted )
       {
          arrayIsSorted = true;
    
          for (i = 0; i < N-1; i++)
          {
             if ( A[i] & A[i+1] are out of place )   
    	 {  swap A[i] & A[i+1]
    	    arrayIsSorted = false;
    	 }
          }
       }
    
    

  3. Bubble sort on Strings:

    Bubble sort algorithm for a String array:
       input: A = array of String
              N = number of elements in A
    
       arrayIsSorted = false;
       while ( ! arrayIsSorted )
       {
          arrayIsSorted = true;
    
          for (i = 0; i < N-1; i++)
          {
             if ( A[i] & A[i+1] are out of place )   
    	 {  swap A[i] & A[i+1]
    	    arrayIsSorted = false;
    	 }
          }
       }
    
    

  4. Conclusion:

  5. $6,000,000 Question: