Skip to content

KKKennedy/CPTR465_Assignment_2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

CPTR465_Assignment_2

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 )

  1. current = 1
  2. loop (current <= last)
  3. hold = list[current]
  4. walker = current - 1
  5. loop (walker >= 0 AND hold.key < list[walker].key)
  6. list[walker + 1] = list[walker]
  7. walker = walker - 1
  8. end loop
  9. list[walker + 1] = hold
  10. current = current + 1
  11. end loop
  12. return end insertionSort

algorithm shellSort (ref list , val last )

  1. incre = last / 2 Compare keys "increment" elements apart.
  2. loop (incre not 0)
  3. current = incre
  4. loop (current <= last)
  5. hold = list[current]
  6. walker = current - incre
  7. loop (walker >= 0 AND hold.key < list[walker].key) Move larger elements up in list.
  8. list [walker + incre] = list[walker] Fall back one partition.
  9. walker = walker - incre
  10. end loop Insert hold record in proper relative location
  11. list [walker + incre] = hold
  12. current = current + 1
  13. end loop End of pass -- calculate next increment.
  14. incre = incre / 2
  15. end loop
  16. return end shellSort

algorithm bubbleSort (ref list , val last )

  1. current = 0
  2. sorted = false
  3. loop (current <= last AND sorted false) Each iteration is one sort pass.
  4. walker = last
  5. sorted = true
  6. loop (walker > current)
  7. if (list[walker] < list[walker - 1]) Any exchange means list is not sorted
  8. sorted = false
  9. exchange (list, walker, walker - 1)
  10. end if
  11. walker = walker - 1
  12. end loop
  13. current = current + 1
  14. end loop
  15. return end bubbleSort

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages