/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q45P Modify the algorithm for context... [FREE SOLUTION] | 91影视

91影视

Modify the algorithm for context-free language recognition in the proof of Theorem 7.16 to give a polynomial time algorithm that produces a parse tree for a string, given the string and a CFG, if that grammar generates the string.

Short Answer

Expert verified

The algorithm can be modified for context-free language recognition. The modified algorithm is provided.

Step by step solution

01

Step-1: Context-free language

Context free language is generated by the context free grammar. A language is said to be context free , if it is accepted by the push down automata.

02

Explain the given information.

Consider a parse tree of any grammar G=V,T,R,S ,

Where, Sstart symbol is a root abd the V non-terminals are interior nodes and the terminals T represents the leaf nodes of the parse tree.

Each terminal string generated by grammar G has parse tree.

03

 Step 3: Modified Algorithm

The Theorem 7.16 states that every context free languages is a member of class P. The modified algorithm to produce a polynomial time algorithm is as follows,

Modified Algorithm:

D=鈥淥n inputs=s1s2sn and CFG G

ParseTreeInitialStree,Beginningofthestrings

CurrentStatePOP the ParseTree

repeat for i=1,2,3,4,n

if parsing is successful for CurrentState

return TREE(CurrentState)

else

if no nodes to expand

return reject

else

tempApply the CFGrulesonCurrentState

PUSH temp into the Parse Tree

if ParseTree is empty

return reject

else

CurrentStateNEXTParseTree

returnParseTree

The above algorithm takes the string and apply the rules on it. For each part of the string rules are applied and the next node is found.

Each state is added to the tree. If the input is processed completely then it returns the parse tree.

Therefore, the modified algorithm has been provided.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91影视!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Let UNARYSSUM be the subset sum problem in which all numbers are represented in unary. Why does the NP completeness proof for SUBSETSUM fail to show UNARYSSUM is NP complete? Show that UNARYSSUMP

A permutation on the set {1,...,k} is a one-to-one, onto function on this set. When P is a permutation,pt means the composition of p with itself t times. Let

PERMPOWER={hp,q,ti|p=qtwherepandqarepermutationson{1,...,k}andtisabinaryinteger}.

Show thatPERMPOWERP . (Note that the most obvious algorithm doesn鈥檛 run within polynomial time.

Show that ALLDFAisinP.

Let SET-SPLITTINGcollection of subsets of S, for some k>0, such that elements of S can be colored red or blue so that no Ci has all its elements colored with the same color}. Show that SET-SPLITTINGis NP-complete.

This problem investigates resolution, a method for proving the unsatisfiability of cnf-formulas. Let =C1C2Cmbe a formula in cnf, where the Ciare its clauses. Let C=CiCiisaclauseof. In a resolution step, we take two clauses Caand Cbin C, which both have some variable occurring positively in one of the clauses and negatively in the other. Thus, Ca=xy1y2ykand Cb=xz1z2zl, where the and are literals. We form the new clause y1y2ykz1z2zland remove repeated literals. Add this new clause to C. Repeat the resolution steps until no additional clauses can be obtained. If the empty clause ( ) is in C, then declare unsatisfiable. Say that resolution is sound if it never declares satisfiable formulas to be unsatisfiable. Say that resolution is complete if all unsatisfiable formulas are declared to be unsatisfiable.

a. Show that resolution is sound and complete.

b. Use part (a) to show that 2SATP.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.