PROGRAMMING ASSIGNMENT I - PowerPoint PPT Presentation

About This Presentation
Title:

PROGRAMMING ASSIGNMENT I

Description:

Write in a functional style functions for shell sort, making a call to a ... to be entered by the user; rather, declare it of fixed size and generate a ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 5
Provided by: University482
Learn more at: http://pirate.shu.edu
Category:

less

Transcript and Presenter's Notes

Title: PROGRAMMING ASSIGNMENT I


1
PROGRAMMING ASSIGNMENT I
  • Write a program to implement Shell Sort
  • Write in a functional stylefunctions for shell
    sort, making a call to a function which is a
    modification of insertion to sort sublists of
    size k (and when k1, 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 double15
  • for (int j 0 j lt a.length j)
  • aj 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 double15
  • for (int j 0 j lt a.length j)
  • aj 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.
Write a Comment
User Comments (0)
About PowerShow.com