Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this assignment is to assess your ability to: Implement recursive algorithms Communicate details of your solution effectively Recognizing strings based on a

The purpose of this assignment is to assess your ability to:

  • Implement recursive algorithms
  • Communicate details of your solution effectively

Recognizing strings based on a set of restrictions is a common computational problem. A Slop is a string of characters that has certain properties. Your program will read in strings of characters and output whether or not they are Slops.

A Slip is a character string that has the following properties:

  • Its first character is either a 'D' or an 'E'
  • The first character is followed by a string of one or more 'F's
  • The string of one or more 'F's is followed by either a Slip or a 'G'
  • The Slip or 'G' that follows the F's ends the Slip. For example, DFFEFFFG is a Slip since it has a 'D' for its first character, followed by a string of two F's, and ended by the Slip 'EFFFG'
  • Nothing else is a Slip

I need help with part 2{

A Slap is a character string that has the following properties:

  • Its first character is an 'A'
  • If it is a two-character Slap then its second and last character is an 'H'
  • If it is not a two-character Slap, then it is in one of these two forms:
    • 'A' followed by 'B' followed by a Slap, followed by a 'C'
    • 'A' followed by a Slip (see above) followed by a 'C'
  • Nothing else is a Slap }

A Slop is a character string that consists of a Slap followed by a Slip.

Examples:

Slips: DFG, EFG, DFFFFFG, DFDFDFDFG, DFEFFFFFG Not Slips: DFEFF, EFAHG, DEFG, DG, EFFFFDG

Slaps: AH, ABAHC, ABABAHCC, ADFGC, ADFFFFGC, ABAEFGCC, ADFDFGC Not Slaps: ABC, ABAH, DFGC, ABABAHC, SLAP, ADGC

Slops: AHDFG, ADFGCDFFFFFG, ABAEFGCCDFEFFFFFG Not Slops: AHDFGA, DFGAH, ABABCC

Input: The first line contains an integer N between 1 and 100 describing how many strings of characters are represented. The next N lines each contain a string.

Output: The first line of output should read SLOPS OUTPUT. Each of the next N lines of output should consist of either YES or NO depending on whether or not the corresponding input line is a Slop. The last line of output should read: END OF OUTPUT.

The following input data:

2 AHDFG DFGAH

Should produce the following output: SLOPS OUTPUT YES NO END OF OUTPUT

And help with part 3{

Write three recursive methods that determine whether or not a string is a slop. Here are the function signatures:

bool isSlop(string str);

bool isSlap(string str);

bool isSlip(string str);

You will want to write isSlip first, followed by isSlap, and finally isSlop. Make sure that isSlip and isSlap work flawlessly. Do not proceed to isSlop until you are sure that the other two methods work.

}

Be sure to comment on the efficiency of your string processing functions. Test everything carefully.

THIS ASSIGNMENT NEEDS TO BE CODED IN JAVA.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions