Lab 06

SORT Sort

 

Objective:

 

I really like the word SORT! SORT SORT SORT SORT!  All SORTS of SORTS! Anyways, I like it so much that I want you to write a program to analyze some strings inputted from the user, count the number of times SORT (case doesn’t matter) appears in each string, then sort them from least number of SORT’s to most number of SORT’s!

 

Requirements:

 

 

Example Dialog:

Enter any number of strings and I will sort by SORT’s.  Once you’re done entering sentences enter “quit”.

 

Sort

asdf

asdfsort

asdfasdfsortSortSORTsort

sortsortsortsortSORTSORTSORTSORT

qwertqwertqwertqwertsortSORT

sortzilla

quit

sort SORTED!

asdf

Sort

asdfsort

sortzilla

qwertqwertqwertqwertsortSORT

asdfasdfsortSortSORTsort

sortsortsortsortSORTSORTSORTSORT

 

Would you like to sort more Strings?

No

Goodbye!

 

Lab Report Questions:

  1. Create a section named “Problem” and describe this lab’s problem in your own words. (10pts).
  2. Create a section named “Solution Description” and describe how the code solves the problem in your own words. (10pts).
  3. Create a section named “Problems Encountered” and describe the various syntax, run-time, and logic errors that were encountered while implementing the solution. (10pts)
  4. Is f(n) = n, O(n2)? Describe why or why not.
  5. Is f(n) = 2,000n3 + 1,000,000n2 + 200n + 4, O(n3)? Desribe why or why not.
  6. Is f(n) = n!, O(2n)? Describe why or why not.
  7. What is the Big O time complexity for bubble sort?
  8. What is the Big O time complexity for quick sort?
  9. What is the Big O time complexity for merge sort?
  10. In relation to time complexity, which is considered more efficient, Selection Sort or Merge Sort? Describe why.

 

Finally

Upload the Lab Solution’s source code (.JAVA file(s)) and the Lab Report’s text file to the CSCE Dropbox.