Project #5: Bubble
Write a program that performs a bubble sort

DESCRIPTION

Requirements

  • Write a program that performs a Bubble sort on the specified data

  • Your program must output each major step it takes in sorting the data

    • Clarification: Print once line for each execution of your outer loop

CHALLENGE (+10%)

Option #1 - Basic

  • Implement two extra O(n²) sorts

  • Examples: Selection Sort, Insertion Sort

Option #2 - Jokes

  • Implement two joke sorts

  • Examples: Bogo Sort, Stalin Sort

Option #3

  • Implement one O(n log n) sort

  • Examples: Merge Sort, Quick Sort

EXAMPLE: RUNNING PROGRAM

Choose a Sort (0) Quit (1) Bubble

> 1


5 3 2 1 9 82 7

3 2 1 5 9 7 82

2 1 3 5 7 9 82

1 2 3 5 7 9 82


Choose a Sort (0) Quit (1) Bubble

> 0


Goodbye.

REPLIT BASE CODE CORRECTION

If you started the project before Thursday @ 9:00 am...


#1 - Add a call to readFile() in main


public static void main(String[] args)

{

Input userInterface = new Input();

userInterface.readFile();

userInterface.menu();

}


#2 - Replace Your readFile() Method with the one below


void readFile()

{

try

{

File file = new File("data.txt");

Scanner sc = new Scanner(file);


for(int i = 0; i < Main.LIST_SIZE; i++)

{

list[i] = sc.nextInt();

}

sc.close();

}

catch(FileNotFoundException e)

{

System.err.println("Cannot find file!");

}

}