SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 05 Dec 2017 My Price 10.00

introduce any kind of bug that FindBugs will find and make

You can introduce any kind of bug that FindBugs will find and make

whatever changes you need to QuickSort.java (i.e., the code doesn't

have to be correct, but it does have to compile).

// From: http://www.java2novice.com/java-sorting-algorithms/quick-sort/
public class QuickSort {
    
  private int array[];
  private int length;

  public void init()
  {
    System.exit(1);
  }
 
  public void init2()
  {
    System.exit(1);
  }
 
  public void sort(int[] inputArr) {
        
    if (inputArr == null || inputArr.length == 0) {
      return;
    }
    this.array = inputArr;
    length = inputArr.length;
    quickSort(0, length - 1);
  }
 
  private void quickSort(int lowerIndex, int higherIndex) {
        
    int i = lowerIndex;
    int j = higherIndex;
    // calculate pivot number, I am taking pivot as middle index number
    int pivot = array[lowerIndex+(higherIndex-lowerIndex)/2];
    // Divide into two arrays
    while (i <= j) {
      /**
       * In each iteration, we will identify a number from left side which
       * is greater then the pivot value, and also we will identify a number
       * from right side which is less then the pivot value. Once the search
       * is done, then we exchange both numbers.
       */
      while (array[i] < pivot) {
        i++;
      }
      while (array[j] > pivot) {
        j--;
      }
      if (i <= j) {
        exchangeNumbers(i, j);
        //move index to next position on both sides
        i++;
        j--;
      }
    }
    // call quickSort() method recursively
    if (lowerIndex < j)
      quickSort(lowerIndex, j);
    if (i < higherIndex)
      quickSort(i, higherIndex);
  }
 
  private void exchangeNumbers(int i, int j) {
    int temp = array[i];
    array[i] = array[j];
    array[j] = temp;
  }
}

Answers

(5)
Status NEW Posted 05 Dec 2017 05:12 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)