Purchase Solution

Language of Words:Strings, Pseudocode and Recursive Function

Not what you're looking for?

Ask Custom Question

Consider a language of words, where each word is a string of dots and dashes. The following grammar describes this language:

< word> = < dot> | < dash> < word> | < word> < dot>
< dot> = .
< dash> = -

a) Write all three-character strings that are in this language.
b) Is the string .... in this language? Explain.
c) Write a seven-character string that contains more dashes than dots and is in the language. Show how you know that your answer is correct.
d) Write pseudocode for a recursive function isIn(str) that returns true if the string str is in this language and returns false otherwise.

Purchase this Solution

Solution Summary

The solution not only provides the required strings, but also gives brief explanations as to how the mentioned strings can be generated.

Solution Preview

a) All the 1 and 2 character strings are shown below so that you can see, following the given grammar, how all the 3 character strings are generated in this language.

Single-character strings in the language:
< dot>

Two-character strings in the language:
< dash>< dot>, < dot>< dot>

Three-character strings in the language:
< dash>< dash>< dot>, < dash>< dot>< dot>, < dot>< dot>< dot>

< dash>< dot>< dot> can be generated via two routes: (< dash>< dot>) < dot> and < dash> (< ...

Purchase this Solution


Free BrainMass Quizzes
C++ Operators

This quiz tests a student's knowledge about C++ operators.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Javscript Basics

Quiz on basics of javascript programming language.