cfg

Control flow graph & cyclometric complexity for folowing procedure

insertion_procedure (int a[], int p [], int N) { int i,j,k; for (i=0; i<=N; i++) p[i] = i; for (i=2; i<=N; i++) { k = p[i]; j = 1; while (a[p[j-1]] > a[k]) {p[j] = p[j-1]; j--} p[j] = k; } } I have to find cyclometric complexity for this code and then suggest some white box test cases...

Determining the maximum stack depth

Imagine I have a stack-based toy language that comes with the operations Push, Pop, Jump and If. I have a program and its input is the toy language. For instance I get the sequence Push 1 Push 1 Pop Pop In that case the maximum stack would be 2. A more complicated example would use branches. Push 1 Push true If .success Pop Jump ....

Getting a CFG form the CFL

Can Any One explain this Language how we converted to CFG Give a CFG for the CFL: {ai bj ck | i ≠ j or j ≠ k } //ai mean a^i I have the answer but I need an explaination (Step By Step) The answer : S --> S1|S2 S1 --> A Eab|Eab B|S1 c A --> a|aA B--> b|bB Eab --> Q|a Eab b S2 --> Eac C|A Eac C --> c|cC Eac --> ...

"Arbitrary" context free grammars?

Long time admirer first time inquirer :) I'm working on a program which derives a deterministic finite-state automata from a context-free grammar, and the paper I have been assigned which explains how to do this keeps referring to "arbitrary probabilistic context-free grammars" but never defines the meaning of "arbitrary" in relation to...

Removing Left Recursion in a Context Free Grammar

Trying to figure out removing left recursion in context free grammars. I'm used to certain forms, but this one has me a bit boggled. S --> S {S} S | (A) | a A --> {S} A | epsilon I also have to design a decent parser, which I can do. However, figuring out this left recursion (especially on the first one) has me confused. ...

Context-free grammar(CFG) & Recursive descent parser(RDP) for id:=expression

Write a Context-free grammar(CFG) that pass all assignment statements of the form id:=expression where expression is an arithmetic expression involving integers,real numbers,identifiers,operators like +,_,*,/,%,^ and parenthesis().use to construct Recursive descent parser(RDP) for the same. ...