Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

While passwords generally have few restrictions, they are normally not totally f

ID: 3786845 • Letter: W

Question

While passwords generally have few restrictions, they are normally not totally free. Suppose that in a certain system passwords can be of arbitrary length, but must contain at least one letter, a...z and one number 0...9. Construct a grammar that generates the set of such legal passwords. Part 2: Suppose that in some programming language numbers are restricted as follows: (a) a number may be signed or unsigned. (b) the value Sled consists of two nonempty parts, separated by a decimal point. (c) there is an optional exponent Sled. If present this Sled must contain the letter e, followed by a signed two-digit integer. Design a grammar for the such numbers. Part-3: Suppose that a certain programming language permits only identifiers that begin with a letter, contain at least one but no more than three digits, and can have any number of letters. Give a grammar and an accepted for such a set of denoisers.

Explanation / Answer

1) Consider the following specialized grammar for the number and digit values
password12 can be represented as follows
l8d2 -- > Letters 8 and the digits are two


2)Consider the following specialized grammar
V = simple structure: {(LDS,1.0)} complete structures: {(l3d2s1,0.75), (l3d1s1,0.25)}
= Non-terminals groups
18
words: {cat, dog, at}
digits: {(99,0.9),(00,0.1),(1,1.0)}
symbols: {(!,1.0)}

R = List of production rules
–>LDS 1.0
LDS –>l3d2s1 0.75
LDS –>l3d1s1 0.25
= (, 1.0)

The following list outlines the creation of the password
structures:
–>LDS –>l3d2s1 –>l399s1 –>l399!
1.0 1.0 0.75 0.9 1.0 = 0.675
–>LDS –>l3d2s1 –>l300s1 –>l300!
1.0 1.0 0.75 0.1 1.0 = 0.075
–>LDS –>l3d1s1 –>l31s1 –>l31!
1.0 1.0 0.25 1.0 1.0 1.0 = 0.25

C) Consider the below example for the OPTION or acceptor and Grammar

char *dictionary; 40
int rc;
char buf[MAXLEN],buf2[MAXLEN];
float prob,dummy; /* holds the probability of a particular value */
struct timeval tv; /* for timing purposes */
time t start time, end time;
int total time;
static int populate;
static int clean;
char ch; /* used to parse command line options */ 50
poptContext opt con; /* context for parsing command-line options */
static struct poptOption options table[ ] = {
{ "clean", ’c’, POPT ARG NONE, &clean,
’c’, "clean the words/ and tmp/ directories",NULL},
{ "populate", ’p’, POPT ARG NONE, &populate,
’p’, "only populate the words from the input dictionary", NULL},
{ "procs", ’n’, POPT ARG INT, &np,
’n’, "number of processes to create", "val>1"},
{ "threshold", ’t’, POPT ARG FLOAT, &threshold, 60
’t’, "set minimum threshold", "val"},
{ "verbose", ’v’, POPT ARG NONE, &verbose,
’v’, "enable verbose logging", NULL},
{ "format", 0, POPT ARG NONE, &format,
0, "input file in the form: <word> <probability>", NULL},
POPT AUTOHELP
{ NULL, 0, 0, NULL, 0 } /* end-of-list terminator */
};
opt con = poptGetContext(NULL, argc, (const char **)argv, options table, 0); 70
poptSetOtherOptionHelp(opt con, "[OPTIONS]* <input dictionary>");
/* process the command line options */
/*ch = poptGetNextOpt(opt con);*/

/* only use the below if we need to do some option processing */


while((ch = poptGetNextOpt(opt con))>=0) {
switch(ch) {
case ’?’: poptPrintHelp(opt con,stderr,0); break;
} 80
}
if(ch < 1) { /* if there was an error with the command
line arguments that was missed, it would be caught here */
poptPrintHelp(opt con,stderr,0);
return 0;
}
if((np)&&(np<2)) { /* error checking with the number of processes */
poptPrintHelp(opt con,stderr,0); 90
return 0;
}
dictionary = (char *)poptGetArg(opt con); /* get the input file */
if((dictionary == NULL)&&(!clean)) {
poptPrintHelp(opt con,stderr,0);
38
return 0;
}