CS320 Quizzes

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Lexical analysis is also known as -------------------------------

Scanner

Javac command in Java language triggers the ----------------- in Java

Static compiler

What is the output? Matcher m = Pattern.compile("[A-Z](\\w*?\\s*?){1,10}?[.?!]") .matcher("This is a paragraph. That's it."); while(m.find()){ System.out.println(m.group()+ " at "+m.start() + " - " +m.end()); }

This is a paragraph. at 0 - 20

Which of these will match the strings revolution, revolutionary, and revolutionaries? revolution[a-z]? revolution[a-z]* revolution[a-z]+

revolution[a-z]*

What do we put after a character to match strings where that character appears two to four times in sequence? {2-4} {2,4} [2,4]

{2,4}

L1={w|w does not contain the string tr} L2={w|w does contain the string tr} Given language over {t, r}, the difference of the minimum number of states required to form L1 and L2? 0 1 2 Cannot be said

0

The set of all strings over Sigma = {a,b} in which all strings having bbbb as a substring is (a|b)* bbbb (a|b)* (a|b)* bb (a|b)*bb bbbb (a|b)* bb (a|b)*

(a|b)* bbbb (a|b)*

Number of states require to accept string ends with 101. 2 can't be represented. 3 4

4

How many components context-free grammar has? 5 4 3 2

4 A context-free grammar has four components: non-terminals, terminal symbols, productions, and start symbol.

Finite State Machine is _______ tuple machine. 4 6 unlimited 5

5

Which of the following called the left side of the production? Both A and B None of the above B. sequence of tokens and/or terminals A. production consists of a non-terminal

A. production consists of a non-terminal Each production consists of a non-terminal called the left side of the production, an arrow, and a sequence of tokens and/or on- terminals, called the right side of the production.

Lexical analysis input is -----------A1--------------------, and the output is ------------------A2-----------

A1) Character stream A2) Set of tokens

The first 3 phases in a compiler known as ----------A1---------------. it can be shared by --------------A2-----------------

A1) Front end A2) A compilers for more than one machine(target language)

In a compiler, keywords of a language are recognized during ____ A1 ______ With ______ A2 _______ programming, you tell the compiler what you want to happen, step by step ____ A3 _____ object is the engine that interprets the pattern and performs match operations against an input string. The compilation during the execution of a program is called __ A4 _____

A1) Lexical analysis A2) imperative A3) matcher A4) JIT

The parse tree represents higher-level constructs (statements, expressions, subroutines, and so on). Each construct is a --------A1-------in the tree; its constituents are its ----------A2---------------. The root of the tree is the program. The leaves from left to right are------A3------------------

A1) Node A2) children A3) the tokens

Based on your understanding of how the FSM system works, which of the following are examples of a finite machine system? Traffic light Control Mechanism of elevator Digital Watches Combinational locks

ALL OF THE ABOVE Traffic light Control Mechanism of elevator Digital Watches Combinational locks

Consider the following regular expression. a*(ba*ba*)* List 3 examples for accepted and 3 examples for rejected strings by the regex above

Accepted: 1. abaaba 2. aaabba 3. aabaab Rejected: 1. aaab 2. ababab 3. bbb

S -> aSa|bSb|a|b; The language generated by the above grammar over the alphabet {a,b} is the set of All palindromes All even length palindromes All odd length palindromes

All odd length palindromes The possible palindrome generated by the above grammar can be of odd length only as there is no rule for S -> For example generated palindromes are aba, aaa, bab, ababa, aaaaa, ...

Grammar that produce more than one leftmost or rightmost Parse tree for same sentence is ___________ Complementation Ambiguous Concatenation Intersection Unambiguous

Ambiguous An ambiguous grammar is one for which there is more than one parse tree for a single sentence.

A regular Grammar is a? English Grammar Non of the mentioned Non CFG CFG This is correct. Regular Grammar is a subset of CFG

CFG This is correct. Regular Grammar is a subset of CFG

-------------- is a program that translates a program from high level language (the source) to another (the target) and then goes away

Compiler

------------------------------ are the semantics rules that must be checked at run time (or in the later phases of an interpreter.

Dynamic semantics

Which of these does not belong to CFG? Start symbol End Symbol Terminal Symbol Non terminal Symbol

End Symbol

Which of the following statement is true? Every language defined by finite automata can also be defined by regular expression We can convert regular expressions into finite automata Every language that is defined by regular expression can also be defined by finite automata None of the mentioned

Every language defined by finite automata can also be defined by regular expression We can convert regular expressions into finite automata Every language that is defined by regular expression can also be defined by finite automata

Is PatternSyntaxException a checked Exception? True False

False PatternSyntaxException is unchecked Exception

The generators of language are____________ Regular Expression FSM ALL Grammars

Grammars

Which capturing group can represent the entire expression? group 0 group * group * or group 0 None of the mentioned

Group 0 is a special group that represents the entire expression.

What is the significance of the Matcher class for a regular expression in Java? Interprets pattern in the string None of the mentioned. Interpreted both pattern and performs match operations in the string Performs match in the string

Interpreted both pattern and performs match operations in the string matcher() method is invoked using matcher object which interprets pattern and performs match operations in the input string.

The -------A1-------- is a computer program that links and merges various object files together in order to make an executable file. All these files might have been compiled by separate assemblers. Also, its major task is to search and locate the referenced module/routines in a program and to determine the memory location where these codes will be loaded, making the program instruction to have absolute references.

Linker

The finite automata are called NFA when there exists_________ for specific input from the current state to the next state Single path None Multiple paths Only two paths

Multiple paths

Which of the following option is correct? NFA is slower to process and its representation uses less memory than DFA DFA is faster to process and its representation uses less memory than NFA NFA is slower to process and its representation uses more memory than DFA DFA is slower to process and its representation uses less memory than NFA

NFA is slower to process and its representation uses less memory than DFA NFA, while computing string, take parallel paths, make different copies of input, and goes along different paths in order to search for the result. This creates a difference in the processing speed of DFA and NFA.

Which of the following is a graphical depiction of a derivation? Parse Tree Ambiguity Tree Analyzers Tree

Parse Tree A parse tree is a graphical depiction of a derivation. It is convenient to see how strings are derived from the start symbol.

The object of which class is used to compile regular expression in Java? Pattern class PatternSyntaxException Matcher class None of the mentioned

Pattern class the object of Pattern class can represent compiled regular expression.

Regular expressions are used to represent which language Recursive language Context free language Regular language All of these

Regular language

Which one of the following grammars generates the language L = {a^i b^j | i ≠ j} A->AC | CB C->aCb | a | b A->aA | ε B->Bb| ε S->aS | Sb | a | b S->AC | CB C->aCb | ε A->aA | a B->Bb | b A->AC | CB C->aCb | ε A->aA | ε B->Bb | ε

S->AC | CB C->aCb | ε A->aA | a B->Bb | b

------------------------ it is the type of compiler that produces the same output unless the code it takes as an input is changed. Therefore, they are capable of faster execution and code generation.

Static compiler

------------------------------are the semantics rules that can be checked at compile-time (or in the front end of an interpreter).

Static semantics

NFA, in its name, has 'non-deterministic' because of: The result is undertermined All of the mentioned The choice of path is non-determinstic The input to be transited next is non-deterministic

The choice of path is non-determinstic Non-deterministic or deterministic depends upon the definite path defined for the transition from one state to another or undefined(multiple paths).

Which of the following statements about the java regex API are true? None of the above Instances of the Pattern class are used to match character sequences against a given pattern The package java.util.regex includes an exception called PatternSyntaxException Instances of Matcher class are used to represent regular expressions in the form of String type

The package java.util.regex includes an exception called PatternSyntaxException

Which of the following matches nonword character using regular expression in java? \s \S \W \w

\W \W matches nonword characters. [0-9], [A-Z] ,[a-z] and _ (underscore) are word characters. All other than these characters are nonword characters.

What is java regex for below string S? S must be of length: 6 First character: 1, 2 or 3 Second character: 1, 2 or 0 Third character: x, s or 0 Fourth character: 3, 0, A or a Fifth character: x, s or u Sixth character: . or, ^([1-3][0-2][x,s,0][3,0,A,a][x,s,u][\.\,])$ ([1-3][0-2][xs0][30Aa][xsu][.,]){6} ^([1-3][0-2][xs0][30Aa][xsu][.,])$

^([1-3][0-2][xs0][30Aa][xsu][.,])$

Find a regular expression that matches an even number. The following formats are an example for even numbers 42 -44 +4356 -99912 99912

^[+-]\d*[02468]$

Consider the CFG with {S,A,B) as the non-terminal alphabet, {a,b) as the terminal alphabet, S is the start symbol and the following set of production rules are: S --> aB S --> bA B --> b A --> a B --> bS A --> aS B --> aBB A --> bAA Which of the following strings is generated by the grammar? abbbba aabbab aaaabb aabbbb

aabbab We can derive aabbab using the below sequence S -> aB [Using S --> aB] -> aaBB [Using B --> aBB] -> aabB [Using B --> b] -> aabbS [Using B --> bS] -> aabbaB [Using S --> aB] -> aabbab [Using B --> b]

What is the output of the following code? Matcher m = Pattern.compile("([a-z])+?\\1") .matcher("happiness is Apple"); while(m.find()){ System.out.println(m.group()+ " at "+m.start() + " - " +m.end()); }

happ at 0 - 4 iness at 4 - 9 pp at 14 - 16

Consider the following regular expression: "^[^aeiou].*[aeiou]$" When you use to match the following input file improve duck meeting joke domineer test unite truthful provide tease striped glamorous Please list all the matching words below, and explain why.

provide, joke, tease Please note [^a] means anything except a(not an a). it should match only provide, joke and tease

Using the-------------------------, the semantic analyzer enforces a large variety of rules that are not captured by the hierarchical structure of the context-free grammar and the parse tree.

symbol table

A set of tokens, known as? start symbol productions non-terminals terminal symbols A set of tokens, known as terminal symbols

terminal symbols A set of tokens, known as terminal symbols

In parse tree, leaf nodes are called? non-terminals half-terminals terminals sub-terminals

terminals In a parse tree: All leaf nodes are terminals and All interior nodes are non-terminals.

If brackets are used to define a group, what would match the regular expression (,\s[0-9]{1,4}){4},\s[0-9]{1,3}\.[0-9]? , 135, 1155, 915, 513, 188 , 135, 11557, 915, 513, 18.8 , 135, 1155, 915, 513, 18.8

, 135, 1155, 915, 513, 18.8

In a typical compiler, compilation proceeds through a series of well-defined phases, they are known as --------------------, --------------------------, -------------------------, ----------------------, ------------------------ and ----------------------(phases 1-6)

1) Scanner (lexical analysis) 2) Parser (syntax analysis) 3) Semantic analysis and intermediate code generation 4) Machine- independent code improvement 5) Target code generation 6) Machine specific code improvement

For the String "aabbab" that can be generated using the grammar below S --> aB S --> bA B --> b A --> a B --> bS A --> aS B --> aBB A --> bAA Where: {S,A,B) as the non-terminal alphabet, {a,b) as the terminal alphabet, S as the start symbol How many derivation trees are there? 2 3 1 0

2 When it asks about the no of derivations tree, we should consider either left most derivation(LMD) or rightmost derivations(RMD), but not both. Here two left most derivations are possible for the string "aabbab" from the given grammar. grammar. LMD-1 S -> aB [Using S --> aB] -> aaBB [Using B --> aBB] -> aabB [Using B --> b] -> aabbS [Using B --> bS] -> aabbaB [Using S --> aB] -> aabbab [Using B --> b] LMD-2 S -> aB [Using S --> aB] -> aaBB [Using B --> aBB] -> aabSB [Using B --> bS] -> aabbAB [Using S --> bA] -> aabbaB [Using A --> a] -> aabbab [Using B --> b]

The last 3 phases in a compiler known as ----------A1-----------, can be shared by ------------A2--------------------

A1) Back end A2) Compiler for more than one source language

Both compiler and interpreters designed to follow ---------------------------- Architecture

Pipeline

The interpretation process shares some of the compilation process phases, but the interpretation Back-end phase which is called------------------------ is different than the Back-end compilation phases.

Tree walk routines

Which of the following language accepted by a Pushdown Automata? Type 3 Type 2 Type 0 Type 1

Type 2 It a known fact that type 2 grammar(CFG) is accepted by PDA.

Can a DFA simulate NDFA? Depends on NDFA Yes No Sometimes

Yes For every NDFA there is an equivalent DFA that can recognize the same language.

How do you match the word Confidential appearing at the beginning of a line? ^Confidential\w ^Confidential\b ^Confidential\d

^Confidential\b

Lexical analysis and Parsing serve to recognize the structure of the program --------------------------------

but they do not recognize its meaning


Set pelajaran terkait

Exploring Storage Devices and Ports

View Set

UDayton ACC 208 Block Exam 2 Study Guide

View Set

Simulation Lab 10.2: Module 10 Install Linux in VM

View Set

Life and Health Insurance Review

View Set

Patho 606 Week 3 Quiz Study Guide

View Set

PET4312 Applied Biomechanics Final

View Set

Special Segments in Triangles Review, Special Segments in Triangles, Unit 4 - Special Segments in Triangles, Special Segments in Triangles

View Set

Final 1 acute 1 Ch. 48, 49, and 53

View Set