Question: Write a program in C++ language A shrinkable word is a word with more than two characters that can be reduced down to a two-character

Write a program in C++ language


A shrinkable word is a word with more than two characters that can be reduced down to a two-character c-string by deleting one character at a time such that, at each stage, the remaining c-string is a word that must be found in a two-dimensional c-string array.


For example, to check if the word startling is shirnkable we start by deleting one character; it could be any character in the word. When trying to delete the character 'l', the c-string becomes starting which is a c-string found int the two-dimensional array dictionary. Next, we continue by trying to delete another character which turns out to be the second 't' and the c-string becomes staring. In the same fashion, the c-string becomes string, sting, sing, sin, and finally in which must also be found in the dictionary. At this point, the original word (i.e. startling) is considered shrinkable.


An example of non-shrinkable word is table. When trying to delete one character, we get the c-string able. However, when trying to remove another character, none of the generated c-strings can be found in the dictionary (i.e. ble, ale, abe, abl). Hence, the word table is considered non-shrinkable.


Complete the function given below which has three formal parameters:


A c-string (i.e. word) which contains the word to be tested if it is shrinkable or not.

A two-dimensional c-string array (i.e. dictionary) which contains the list of words that are checked against during the shrinking process.

An integer variable (i.e. rows) which represents the numbers of rows in the dictionary array.

The function must output the new shrinked c-string at each stage on a new line. The function must return true if the word is shrinkable to a two-letter c-string, or false otherwise.



No modifications are permitted to the function header

The function can be coded in two ways: as a recursive function or a normal function

You can assume that the c-string "word" and array "dictionary" only contains lower case alphabetical characters

Step by Step Solution

3.41 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include include using namespace std int shrnkbl char word50 int n char dic5050 in... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

60d02c4503fdf_215705.pdf

180 KBs PDF File

Word file Icon

60d02c4503fdf_215705.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!