Northern Caribbean University Department of Computer & Information Sciences CPTR465-Advanced Application Development Assignment #2 (30pts / 10%) Due Date: June 1, 2014 by 11:59PM
Instruction: Write the program for the problem below. This assignment must be submitted via http://lms.ncu.edu.jm and also presented in class on June 2, 2014.
You have been asked by your project’s manager to use the instrumentation, and profiling feature of the .NET platform to analyze three different sorting algorithms, and write a brief report to document the time taken and number of calls to each function. Based on the data received, you should recommend the best sorting algorithm to be used for the current project (proper justifications should be given).
You are also expected to write at least three (3) test cases for each sort function. Your application should be demonstrated with an array of 10,000 randomly generated numbers between 1 and 5000. You can implement your application in either VB.NET or C#.NET.
N.B.: Please use detailed comments as a documentation methodology to clearly explain each section of your code. Each function should have the following function description:
Description == e.g.: Function to count the number of vowels in a given string (Arguments) return type == e.g.: (string, int) int Precondition == e.g.: String must not be NULL or Empty Postcondition == e.g.: The number of vowels contained in the given string is returned Example (s) == e.g.: string x = “Hello”; Function(x) = 2
Rubric Insertion Sort Implementation 3pts Shell Sort Implementation 3pts Bubble Sort Implementation 3pts Test Cases (3 * 3) 9pts Comments 3pts Report 4pts Demonstration 5pts Total 30pts
Algorithms: • insertionSort • shellSort • bubbleSort
algorithm insertionSort (ref list , val last )
- current = 1
- loop (current <= last)
- hold = list[current]
- walker = current - 1
- loop (walker >= 0 AND hold.key < list[walker].key)
- list[walker + 1] = list[walker]
- walker = walker - 1
- end loop
- list[walker + 1] = hold
- current = current + 1
- end loop
- return end insertionSort
algorithm shellSort (ref list , val last )
- incre = last / 2 Compare keys "increment" elements apart.
- loop (incre not 0)
- current = incre
- loop (current <= last)
- hold = list[current]
- walker = current - incre
- loop (walker >= 0 AND hold.key < list[walker].key) Move larger elements up in list.
- list [walker + incre] = list[walker] Fall back one partition.
- walker = walker - incre
- end loop Insert hold record in proper relative location
- list [walker + incre] = hold
- current = current + 1
- end loop End of pass -- calculate next increment.
- incre = incre / 2
- end loop
- return end shellSort
algorithm bubbleSort (ref list , val last )
- current = 0
- sorted = false
- loop (current <= last AND sorted false) Each iteration is one sort pass.
- walker = last
- sorted = true
- loop (walker > current)
- if (list[walker] < list[walker - 1]) Any exchange means list is not sorted
- sorted = false
- exchange (list, walker, walker - 1)
- end if
- walker = walker - 1
- end loop
- current = current + 1
- end loop
- return end bubbleSort