Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that takes in two words, and then it recursively determines if the letters of the first word are contained, in any order,


Write a program that takes in two words, and then it recursively determines if the letters of the first word are contained, in any order, in the second word. If the size of the first word is larger than the second then it should automatically return false. Also if both strings are empty then return true.

You May NOT:

Use any iterative loops. In other words, no for-loops, no while-loops, no do-while-loops, no for-each loops.

Use the string method.contains(String)

You May:

Use the string method.charAt(Index)

Hints:

Recursive methods generally attempt to solve a smaller problem then return the results of those in order to solve the larger one.

Think of how to do this with a loop, and use that to guide what parameters youll need for your recursive method.

Example Dialog:

Enter 2 words. I will determine if the letters of one is contained in the other

elf

self

They are contained!

Example Dialog 2:

Enter 2 words. I will determine if the letters of one is contained in the other

jerky

turkey

They are not contained

Example Dialog 3:

Enter 2 words. I will determine if the letters of one is contained in the other

asdf

fasted

They are contained!







Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Recommended Textbook for

Cryptography And Network Security

Authors: William Stallings

5th Edition

B00F0ZR6PC, 9780136097044

Students also viewed these Programming questions