Presentation is loading. Please wait.

Presentation is loading. Please wait.

PROGRAMMING ASSIGNMENT I

Similar presentations


Presentation on theme: "PROGRAMMING ASSIGNMENT I"— Presentation transcript:

1 PROGRAMMING ASSIGNMENT I
Write a program to implement Shell Sort Write in a functional style—functions for shell sort, making a call to a function which is a modification of insertion to sort sublists of size k (and when k=1, we do regular insertion sort), and a function printArray that will print out the array before and after sorting The array does not need to be entered by the user; rather, declare it of fixed size and generate a random array of elements:

2 Generate array of random numbers
double a[] = new double[15]; for (int j = 0; j < a.length; j++) a[j] = Math.random()*10;

3 My main program public static void main(String args[]){
//Generate an array of length 15 of random nums double a[] = new double[15]; for (int j = 0; j < a.length; j++) a[j] = Math.random()*10; System.out.println("Before sorting"); printArray(a); shellSort(a); System.out.println("After sorting"); printArray(a); }

4 Function call In my program, the function shellSort calls a function that performs the modified insertion sort Program is due Tues., June 12, 5 p.m.


Download ppt "PROGRAMMING ASSIGNMENT I"

Similar presentations


Ads by Google