Lp Quiz Test 4

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Rsoni
R
Rsoni
Community Contributor
Quizzes Created: 1 | Total Attempts: 404
Questions: 10 | Attempts: 404

SettingsSettingsSettings
Lp Quiz Test 4 - Quiz

.


Questions and Answers
  • 1. 

    Construct LL(1) parsing table for the following grammar:                 Program → begin d Semi X end                X → d semi X / s Y                Y → semi s Y / λ  begindsemiends$Program1     X 2  3 Y  45   What will be the entry for 1:

    • A.

      X → d semi X

    • B.

      Program → begin d Semi X end

    • C.

      X → s Y

    • D.

      Y → semi s Y

    Correct Answer
    B. Program → begin d Semi X end
  • 2. 

    Construct LL(1) parsing table for the following grammar:                 Program → begin d Semi X end                X → d semi X / s Y                Y → semi s Y / λ  begindsemiends$Program1     X 2  3 Y  45   What will be the entry for 2:

    • A.

      Program → begin d Semi X end

    • B.

      X → s Y

    • C.

      X → d semi X

    • D.

      Y → semi s Y

    Correct Answer
    C. X → d semi X
    Explanation
    The entry for 2 in the LL(1) parsing table will be X → d semi X. This is because when the parser sees a non-terminal X followed by the terminal "d", it knows that it should use the production X → d semi X to expand X.

    Rate this question:

  • 3. 

    Construct LL(1) parsing table for the following grammar:                 Program → begin d Semi X end                X → d semi X / s Y                Y → semi s Y / λ  begindsemiends$Program1     X 2  3 Y  45   What will be the entry for 3:

    • A.

      Program → begin d Semi X end

    • B.

      X → s Y

    • C.

      Y → semi s Y

    • D.

      Y → λ

    Correct Answer
    B. X → s Y
  • 4. 

    Construct LL(1) parsing table for the following grammar:                 Program → begin d Semi X end                X → d semi X / s Y                Y → semi s Y / λ  begindsemiends$Program1     X 2  3 Y  45   What will be the entry for 4:

    • A.

      Program → begin d Semi X end

    • B.

      X → d semi X

    • C.

      X → s Y

    • D.

      Y → semi s Y

    Correct Answer
    D. Y → semi s Y
  • 5. 

    Construct LL(1) parsing table for the following grammar:                 Program → begin d Semi X end                X → d semi X / s Y                Y → semi s Y / λ  begindsemiends$Program1     X 2  3 Y  45   What will be the entry for 5:

    • A.

      Program → begin d Semi X end

    • B.

      X → d semi X

    • C.

      Y → λ

    • D.

      Y → semi s Y

    Correct Answer
    C. Y → λ
    Explanation
    The entry for 5 in the LL(1) parsing table will be Y → λ. This is because when the parser sees a "semi" token in the input, it can choose to expand Y → λ, which represents an empty production. This allows the parser to skip over the "semi" token and continue parsing the rest of the input.

    Rate this question:

  • 6. 

     Consider the following grammar:                E → E + n / E * n / nfor the sentence n+n*n, the handles in the bottom-up parsing will be:

    • A.

      N, E+n and E+n*n

    • B.

      N, E+n and E+E*n

    • C.

      N, n+n and n+n*n

    • D.

      N, E+n and E*n

    Correct Answer
    D. N, E+n and E*n
    Explanation
    The given grammar is a right-recursive grammar, which means that the rightmost non-terminal in the production rule is expanded first. In the given sentence "n+n*n", the handles are the substrings that match the right side of a production rule and can be reduced to the left side of that rule.

    Starting from the leftmost non-terminal, we can see that the handle "n" matches the right side of the production rule E -> n. This handle can be reduced to E.

    Next, the handle "E+n" matches the right side of the production rule E -> E + n. This handle can be reduced to E.

    Finally, the handle "E*n" matches the right side of the production rule E -> E * n. This handle can also be reduced to E.

    Therefore, the handles in the bottom-up parsing of the given sentence are n, E+n, and E*n.

    Rate this question:

  • 7. 

    Consider the following two statementsa) Every SLR(1) grammar is also LR(0) grammar.b) Every LL(1) grammar is also LL(2) grammar.Which of the following option is correct?

    • A.

      Only a is true

    • B.

      Only b is true

    • C.

      Both are true

    • D.

      Both are false

    Correct Answer
    B. Only b is true
  • 8. 

    Consider the following grammar:S → CCC →cC / dThe above grammar is

    • A.

      LL(1)

    • B.

      SLR(1) but not LL(1)

    • C.

      SLR(1) but not LR(0)

    Correct Answer
    A. LL(1)
    Explanation
    The given grammar is LL(1) because it is a left-to-right, leftmost derivation with one lookahead symbol. In LL(1) parsing, the parser scans the input from left to right, and at each step, it uses a single lookahead symbol to decide which production rule to apply. In this grammar, the non-terminal S can only derive to CCC or cC, and there is no ambiguity or conflict in the productions. Therefore, the grammar is LL(1).

    Rate this question:

  • 9. 

    Consider SLR(1) and LR(0) table for any given CFG. Which one of the following is false?

    • A.

      Error entries in both the tables may be different

    • B.

      Goto of both the tables may be different

    • C.

      Shift entries are identical in both the tables

    • D.

      Reduce entries in both the tables may be different

    Correct Answer
    B. Goto of both the tables may be different
    Explanation
    The Goto entries in the SLR(1) and LR(0) tables may be different. The Goto entries in the SLR(1) table represent the next state to transition to when a non-terminal symbol is encountered, while the Goto entries in the LR(0) table represent the next state to transition to when a production rule is completed. Since the SLR(1) and LR(0) parsing methods have different lookahead sets, it is possible for the Goto entries to differ between the two tables.

    Rate this question:

  • 10. 

    If the parse tree of a word w generated by a Chomsky normal form grammar has no path of length greater than i, then the word w is of length:

    • A.

      No greater than 2 ^ (i+1)

    • B.

      No greater than 2 ^ i

    • C.

      No greater than 2 ^ (i-1)

    • D.

      No greater than i

    Correct Answer
    B. No greater than 2 ^ i
    Explanation
    If the parse tree of a word w generated by a Chomsky normal form grammar has no path of length greater than i, then the word w is of length no greater than 2 ^ i. This is because the Chomsky normal form grammar restricts the length of the paths in the parse tree. Each rule in the grammar either replaces a non-terminal symbol with two non-terminal symbols or with a terminal symbol. Therefore, at each step, the number of symbols in the word doubles. So, if there is no path of length greater than i, then the word can have at most 2 ^ i symbols.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 20, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 01, 2017
    Quiz Created by
    Rsoni
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.