A single zip file including the following:
· Your Visual Studio Project directory and associated files, including source files for the Lab.
· The results of your testing. What tests did you run? Did everything work okay? Are there outstanding issues in your program? A short half-page summary of your results is about the right length.
· You do not need to submit your test plan, but it doesn’t mean you shouldn’t have one!
· Remember, for this Lab you must also submit the answers to the Part 5 questions.
If you document any issues, it will be easier to isolate any problems, provide detailed help, and could potentially improve your grade.
In this Lab, you will use recursion and implement an efficient sorting mechanism to solve common problems dealing with strings.
Part 1:Understanding Plindromes
Palindromes are funny little phrases. They can be words, sentences, or even numbers or other characters. Formally, a palindrome is a string that is the same when its characters are reversed. For example, classic palindromes are the following.
· step on no pets
Further, we will define some specific classification for palindromes for the purpose of this assignment.
Type 1 Palindrome: Every character has the same number of occurrences.
Type 2 Palindrome: Characters may have different numbers of occurrences.
· ‘ana’ is a type 2 palindrome because there are 2 ‘a’ characters but only 1 ‘n’ character.
· ‘civic’ is a type 2 palindrome because there are 2 ‘c’ characters, 2 ‘I’ characters, but only 1 ‘v’ character.
· ‘tattarrattat’ is a type 2 palindrome – there are 6 ‘t’ characters, 4 ‘a’ characters and 2 ‘r’ characters.
· ‘deed’ is a type 1 palindrome – there are 2 ‘d’ characters and 2 ‘e’ characters.
Order of a Palindrome: The number of occurrences of the alphabetically first character in a palindrome.
· ‘ana’ is of order 2 because there are 2 ‘a’ characters which are alphabetically before ‘n’.
· ‘deed’ is of order 2 because there are 2 ‘d’ characters and two ‘e’ characters.
· ‘nopapon’ is of order 1 because there is only 1 ‘a’ character which is alphabetically first.
Notice that in a type 1 palindrome, the order will be the number of occurrencesfor all characters.
Go through the list of palindrome examples to ensure that you can describe the type and order of each. Do some web research to find fun palindromes of your own for testing and determine their type and order.
Assumptions: For the purposes of this assignment, in the interest of time, we’ll exclude palindromes that are only palindromes by ignoring spaces and punctuation. For example, “A man, a plan, a canal: Panama” would not be a palindrome for our purposes because there is no matching “:” character, and even if the punctuation is removed, spacing differences invalidate this palindrome. You will also not need to worry about capitalization. For example ‘Ana’ is not a valid palindrome in our world because an ‘A’ is different than an ‘a.’
Part 2: Implement a Palindrome Detector
For this assignment, you will create a test driver that asks for a string from the user and processes this string in several ways. The first of these is to determine whether the string is or is not a palindrome.
First, create a main function that accepts an arbitrary string from the user, makes a call to a recursive palindrome detecting function, and then outputs to the console whether or not the entered string is a palindrome.
Next create a recursive function that detects whether or not a string is a palindrome. Remember to follow the appropriate steps to create a recursive implementation. What are the base cases? What is the recursive case?
For this assignment, you may use the internal string class to read a string from the user and access the string itself; however, you may not use other string functions. It is good general practice to create a class for all of your programming. Even though we are not creating an ADT this week, you should still create a class to hold your palindrome functions
Part 3:Sorting the Input
Next, we want to determine the type and order of the palindrome. Because you’ll need to find out how many characters are present from the alphabetically first character in the string, an efficient sorting mechanism is important.
Implement a function that performs a recursive Merge Sort on the string of characters read from the user. Your textbook describes the programming details of Merge Sort in detail.
For example, if the user inputs the palindrome ‘racecar’, the output should be ‘aaccerr.’
Adjust your main program to make a call to your Merge Sort function and output the sorted string results to the console window.
Part 4: Determining the Order and Type
Now that the string is sorted, it will be easy to determine the order and only slightly more difficult to determine the type.
Implement a function or functions to determine the type and order of the palindrome using the sorted string. Make sure you consider the Big-O run-time and space complexity of the function you are creating with respect to n, the size of the string.
Adjust your main program to make a call to your order/type functions and output the order of the palindrome and whether it is type 1 or type 2.
Part 5: Questions to Answer in Your Lab Write-Up
Your Labwrite-up should always contain the results of your testing, a brief explanation of how you completed the Lab, and it should detail any components that you may not have gotten working so that problems can be isolated and detailedhelp is provided to assist in your understandingandpotentially improve your grade.
In addition, please give short answers to the following questions about the Lab.
1. What is the Big-O run-time of each of these components of the lab individually?
a. Palindrome detector
b. Merge Sort
c. Order and type determination
2. What is the Big-O space complexity (memory) of each of these components of the Lab individually?
a. Palindrome detector
b. Merge Sort
c. Order and type determination
3. What is the Big-O run-time of a complete program ‘loop’ that performs all functions on a user inputted string?
4. What is the Big-O space complexity (memory) of a complete program ‘loop’ that performs all functions on a user inputted string?
General iLab Comments
All coding assignments for this class will be using Microsoft Visual Studio. This is available through the Software Store, which can be found in Course Home. Contact the help desk if you encounter any issues or contact your professor.
*Please note as a reminder that you may not copy code from any web reference to complete this assignment, even if you correctly give credit. You may of course use web references to help you understand, but you must code the assignment yourself. You may use code directly from your textbook where applicable, but do make sure you give credit in your comments if you are doing so.