1. Home
  2. Explore
  3. Computer Science
  4. Computational Thinking and Compilers

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Computational Thinking and Compilers

  • 67Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Computational Thinking

What are the two pillars of computational thinking emphasized in the content?

67 questions

  1. 1

    What are the two pillars of computational thinking emphasized in the content?

    1. A

      Measurement and simulation

    2. B

      Hardware and networking

    3. C

      Syntax and compilation

    4. D

      Abstraction and algorithms

    Correct answer
    D

    Abstraction and algorithms

    Explanation

    The content identifies abstractions and algorithms as the two pillars that transformed compiler design from an art into a science.

  2. 2

    Which description best captures computational thinking?

    1. A

      Memorizing programming languages so problems can be solved without formal planning

    2. B

      Formulating problems with abstractions so solutions can be represented as computational steps and algorithms

    3. C

      Representing every real-world problem directly as hardware without using mathematical models

    4. D

      Writing computer programs first and analyzing their behavior only after they fail

    Correct answer
    B

    Formulating problems with abstractions so solutions can be represented as computational steps and algorithms

    Explanation

    Computational thinking involves formulating problems using abstractions so that their solutions can be expressed as computational steps and algorithms.

  3. 3

    Why is there no single standard definition of abstraction across all fields?

    1. A

      Every abstraction must be expressed using a Turing-complete language

    2. B

      Abstractions are used only in computer science and therefore lack broader agreement

    3. C

      Mathematical models cannot be applied consistently to scientific disciplines

    4. D

      Different fields use distinct abstractions to describe their own subject matter

    Correct answer
    D

    Different fields use distinct abstractions to describe their own subject matter

    Explanation

    The content explains that virtually every area of human endeavor uses different abstractions, so no universal definition applies across fields.

  4. 4

    In the presented computer science definition, what two components make up an abstraction?

    1. A

      A compiler and a target machine

    2. B

      A grammar and a parse tree

    3. C

      A data model and a set of operations

    4. D

      A graph and a measurement device

    Correct answer
    C

    A data model and a set of operations

    Explanation

    An abstraction is defined as a mathematical model consisting of a data model and associated operations for manipulating the modeled data.

  5. 5

    What is distinctive about the computer science definition of abstraction compared with many definitions in other fields?

    1. A

      It requires every model to be computationally universal

    2. B

      It includes operations for manipulating the data in the model

    3. C

      It requires the model to describe only physical objects

    4. D

      It excludes any language-like way of interacting with the model

    Correct answer
    B

    It includes operations for manipulating the data in the model

    Explanation

    The distinctive feature is the inclusion of an associated set of operations, which can be viewed as a programming language that need not be Turing-complete.

  6. 6

    Which set of operations belongs to the dictionary abstraction described in the content?

    1. A

      Compile a program, optimize code, and generate instructions

    2. B

      Sort an element, reverse a list, and calculate a path

    3. C

      Measure a state, clone a state, and reverse a measurement

    4. D

      Insert an element, delete an element, and test membership

    Correct answer
    D

    Insert an element, delete an element, and test membership

    Explanation

    The dictionary supports insertion, deletion, and checking whether a given element belongs to the set.

  7. 7

    What is the data model of the dictionary abstraction?

    1. A

      A sequence of tokens and a parse tree that is initially complete

    2. B

      A vector space and a unitary matrix that is initially identity

    3. C

      A graph of basic blocks and a set of control-flow edges

    4. D

      A universal set UUU and a subset SSS of UUU that is initially empty

    Correct answer
    D

    A universal set UUU and a subset SSS of UUU that is initially empty

    Explanation

    The dictionary's data model consists of a universal set UUU and a subset S⊆US \subseteq US⊆U, with SSS initially empty.

  8. 8

    Why can the operations of an abstraction be viewed as a programming language that need not be Turing-complete?

    1. A

      The operations are unrelated to the data model being manipulated

    2. B

      The operations describe only the hardware used to implement the abstraction

    3. C

      The operations must always simulate a universal Turing machine

    4. D

      The operations provide a way to manipulate the model without necessarily expressing every computation

    Correct answer
    D

    The operations provide a way to manipulate the model without necessarily expressing every computation

    Explanation

    An abstraction's operations form an interaction language for its data model, but that language does not need the expressive power of a Turing-complete system.

  9. 9

    Which formal definition of an algorithm is given in the content?

    1. A

      A Turing machine that halts on all inputs

    2. B

      A parser that accepts every syntactically valid string

    3. C

      A program that produces output for at least one input

    4. D

      A mathematical model with no associated operations

    Correct answer
    A

    A Turing machine that halts on all inputs

    Explanation

    Formally, an algorithm is defined as a Turing machine that halts on every input.

  10. 10

    Which category contains dictionaries, stacks, queues, graphs, trees, and classes with methods lacking specifications?

    1. A

      Abstract implementations

    2. B

      Computational abstractions

    3. C

      Declarative abstractions

    4. D

      Fundamental abstractions

    Correct answer
    D

    Fundamental abstractions

    Explanation

    Fundamental abstractions are commonly introduced in first computer science courses and include structures such as dictionaries, stacks, queues, graphs, and trees.

  11. 11

    What is the purpose of an abstract implementation?

    1. A

      To represent the physical state of a quantum system

    2. B

      To specify desired behavior without describing how it is achieved

    3. C

      To provide data structures useful for implementing fundamental abstractions

    4. D

      To model a programming language with Turing-complete operations

    Correct answer
    C

    To provide data structures useful for implementing fundamental abstractions

    Explanation

    Abstract implementations are data structures used to implement fundamental abstractions; hash tables and search trees are examples.

  12. 12

    What characterizes a declarative abstraction?

    1. A

      It always provides a concrete low-level implementation

    2. B

      It specifies what is wanted without specifying how to accomplish it

    3. C

      It consists only of physical circuits and hardware components

    4. D

      It must be Turing-complete and model an entire programming language

    Correct answer
    B

    It specifies what is wanted without specifying how to accomplish it

    Explanation

    Declarative abstractions describe desired results or relationships without prescribing an implementation procedure, and they need not be Turing-complete.

  13. 13

    What distinguishes computational abstractions from the other categories?

    1. A

      They more closely model programming languages and are Turing-complete

    2. B

      They are used exclusively to implement hash tables and search trees

    3. C

      They specify results while deliberately excluding computational procedures

    4. D

      They can represent only sets with insertion and deletion operations

    Correct answer
    A

    They more closely model programming languages and are Turing-complete

    Explanation

    Computational abstractions model programming languages more directly and are Turing-complete; Turing machines and Boolean circuits are examples.

  14. 14

    How can abstractions be layered?

    1. A

      An abstraction must replace every lower-level abstraction in a system

    2. B

      An abstraction can be used only if it is implemented directly in hardware

    3. C

      An abstraction can contain data but cannot contain operations

    4. D

      An abstraction can be implemented by algorithms or in terms of other abstractions

    Correct answer
    D

    An abstraction can be implemented by algorithms or in terms of other abstractions

    Explanation

    Abstractions can be built in layers, with one abstraction implemented using algorithms or lower-level abstractions. A dictionary, for example, can use a linked-list abstraction.

  15. 15

    What is the defining purpose of a compiler in the content?

    1. A

      To translate a source program into a semantically equivalent target program

    2. B

      To convert every program into a context-free grammar

    3. C

      To measure the running time of every possible algorithm

    4. D

      To execute a source program without changing its representation

    Correct answer
    A

    To translate a source program into a semantically equivalent target program

    Explanation

    A compiler is defined as a program that translates a source program into a target program with equivalent meaning.

  16. 16

    What major architectural idea changed compiler design during the 1960s and 1970s?

    1. A

      Viewing a compiler as a sequence of phases producing semantically equivalent lower-level representations

    2. B

      Using one monolithic algorithm for lexical analysis, parsing, and optimization

    3. C

      Eliminating semantic equivalence as a requirement for translation

    4. D

      Replacing all intermediate representations with direct hardware execution

    Correct answer
    A

    Viewing a compiler as a sequence of phases producing semantically equivalent lower-level representations

    Explanation

    Compilers came to be viewed as compositions of phases that progressively translate a program into lower-level but semantically equivalent representations.

  17. 17

    Which description correctly distinguishes the front end and back end of a compiler?

    1. A

      The front end and back end are identical phases with different names

    2. B

      The front end executes target code, while the back end checks source-language syntax

    3. C

      The front end analyzes the source language, while the back end produces code for a target machine

    4. D

      The front end performs only optimization, while the back end performs only lexical analysis

    Correct answer
    C

    The front end analyzes the source language, while the back end produces code for a target machine

    Explanation

    The front end handles source-language processing, while the back end uses the resulting representation to generate target-language code.

  18. 18

    How does LLVM support multiple source languages and target machines?

    1. A

      Each source language must have a separate complete compiler for every target machine

    2. B

      Different front ends translate into LLVM IR, which can be optimized and processed by multiple back ends

    3. C

      LLVM replaces front ends with handwritten machine-code programs

    4. D

      LLVM uses only one target language and does not support intermediate representations

    Correct answer
    B

    Different front ends translate into LLVM IR, which can be optimized and processed by multiple back ends

    Explanation

    LLVM allows several front ends to produce a common intermediate representation, LLVM IR, which can then be optimized and passed to different target code generators.

  19. 19

    If a new programming language is being compiled for an existing machine using LLVM, what major component generally needs to be added?

    1. A

      A new code generator for every existing source language

    2. B

      A quantum measurement phase for the source program

    3. C

      A new front end that translates the language into LLVM IR

    4. D

      A replacement for the LLVM optimizer and all target back ends

    Correct answer
    C

    A new front end that translates the language into LLVM IR

    Explanation

    For a new language on an existing machine, the main task is creating a front end that translates the new language into LLVM IR, after which existing optimization and back-end components can be reused.

  20. 20

    If an existing programming language must target a new machine architecture in LLVM, what component generally needs to be created?

    1. A

      A replacement for the source-language front end

    2. B

      A new context-free grammar for the programming language

    3. C

      An LLVM IR-to-target-machine-code generator

    4. D

      A new lexical specification for every token

    Correct answer
    C

    An LLVM IR-to-target-machine-code generator

    Explanation

    When the source language already has a front end, supporting a new machine primarily requires an LLVM IR-to-target-code generator.

  21. 21

    What is the data model of the regular-expression abstraction?

    1. A

      Sets of basic blocks connected by control-flow edges

    2. B

      Trees representing syntactic categories

    3. C

      Vectors representing quantum states

    4. D

      Sets of strings over an alphabet

    Correct answer
    D

    Sets of strings over an alphabet

    Explanation

    Regular expressions operate over sets of strings defined over some alphabet.

  22. 22

    Which operations define the regular-expression abstraction described in the content?

    1. A

      Union, concatenation, and Kleene closure

    2. B

      Transfer, confluence, and measurement

    3. C

      Shifting, reducing, and code generation

    4. D

      Insertion, deletion, and membership testing

    Correct answer
    A

    Union, concatenation, and Kleene closure

    Explanation

    The regular-expression abstraction uses union, concatenation, and Kleene closure to construct sets of strings.

  23. 23

    What was the running-time characteristic of Thompson's just-in-time simulation approach for regular expressions?

    1. A

      It was linear in the sum of the regular-expression length and input-string length

    2. B

      It was quadratic only in the number of grammar productions

    3. C

      It was linear in the product of the regular-expression length and input-string length

    4. D

      It was independent of both the pattern and input lengths

    Correct answer
    C

    It was linear in the product of the regular-expression length and input-string length

    Explanation

    The described simulation ran in time linear in ∣R∣×∣w∣|R| \times |w|∣R∣×∣w∣, where ∣R∣|R|∣R∣ is the regular-expression length and ∣w∣|w|∣w∣ is the input length.

  24. 24

    What was the observed running-time characteristic of the dynamic lazy DFA-transition construction approach?

    1. A

      It required time exponential in the number of input characters

    2. B

      It was linear in the product of the regular-expression length and input-string length

    3. C

      It required time independent of the regular expression

    4. D

      It was linear in the sum of the regular-expression length and input-string length

    Correct answer
    D

    It was linear in the sum of the regular-expression length and input-string length

    Explanation

    The described lazy construction had observed running time linear in ∣R∣+∣w∣|R| + |w|∣R∣+∣w∣, the sum of the pattern and input lengths.

  25. 25

    What does a lexical-analyzer generator such as Lex allow users to do?

    1. A

      Simulate arbitrary quantum circuits without measurement

    2. B

      Create lexical analyzers from token specifications without implementing pattern-matching algorithms themselves

    3. C

      Compute reaching definitions for intermediate representations

    4. D

      Generate target machine code directly from an ambiguous grammar

    Correct answer
    B

    Create lexical analyzers from token specifications without implementing pattern-matching algorithms themselves

    Explanation

    Lex takes token-pattern specifications and generates a lexer, hiding the implementation details of efficient pattern matching.

  26. 26

    In the integer-token example, what does the generated lexer do when it recognizes one or more digits?

    1. A

      It treats the digits as a grammar production and returns a parse tree

    2. B

      It stores the digit sequence in a table and returns a NUM token with a pointer to it

    3. C

      It converts the digits immediately into machine instructions

    4. D

      It deletes the digit sequence after checking whether it is in a dictionary

    Correct answer
    B

    It stores the digit sequence in a table and returns a NUM token with a pointer to it

    Explanation

    The lexer stores the recognized digit sequence in a table and returns the token NUM together with a pointer to the stored digits.

  27. 27

    What role do context-free grammars play in compiler design?

    1. A

      They implement hash tables used by symbol tables

    2. B

      They declaratively specify the grammatical structure of programming languages

    3. C

      They define the probabilities of quantum measurement outcomes

    4. D

      They specify only the machine instructions generated by a compiler

    Correct answer
    B

    They declaratively specify the grammatical structure of programming languages

    Explanation

    Context-free grammars are used as declarative abstractions for describing the syntax of programming languages.

  28. 28

    What is the purpose of a syntax-directed scheme attached to a context-free grammar?

    1. A

      To calculate the running time of a regular-expression matcher

    2. B

      To store all variables in a compiler symbol table

    3. C

      To translate a token stream into an output such as a syntax tree

    4. D

      To determine the temperature required for a quantum processor

    Correct answer
    C

    To translate a token stream into an output such as a syntax tree

    Explanation

    A syntax-directed scheme augments grammar productions with rules that guide translation of an input token stream, often into a syntax tree.

  29. 29

    What does YACC provide to compiler designers?

    1. A

      A tool for constructing syntax analyzers from grammatical specifications

    2. B

      A quantum circuit simulator based only on measurement gates

    3. C

      A regular-expression engine for matching input strings

    4. D

      A hardware device for executing compiled programs

    Correct answer
    A

    A tool for constructing syntax analyzers from grammatical specifications

    Explanation

    YACC generates parsers from grammar-based specifications, allowing users to construct syntax analyzers without implementing the parser-construction algorithm manually.

  30. 30

    Why did the combination of Lex and YACC become useful in compiler courses?

    1. A

      It converted every programming language directly into quantum circuits

    2. B

      It allowed students to experiment with programming-language syntax using generated lexers and parsers

    3. C

      It eliminated the need to define either tokens or grammatical rules

    4. D

      It guaranteed that all grammars would be free of ambiguity

    Correct answer
    B

    It allowed students to experiment with programming-language syntax using generated lexers and parsers

    Explanation

    Lex and YACC made it practical to build working lexical analyzers and parsers from specifications, supporting experimentation with language syntax.

  31. 31

    How does YACC resolve the described shift-reduce conflict?

    1. A

      It uses a rule that favors shifting

    2. B

      It always deletes the conflicting production

    3. C

      It converts the grammar into a regular expression

    4. D

      It always favors reducing before examining the next token

    Correct answer
    A

    It uses a rule that favors shifting

    Explanation

    The described convention resolves a shift-reduce conflict by favoring the shift action, providing a simple disambiguation rule.

  32. 32

    Why can an ambiguous expression grammar be convenient for a language such as C?

    1. A

      The grammar no longer needs any parser or semantic rules

    2. B

      C expressions contain no operator-precedence relationships

    3. C

      Precedence and associativity rules can replace many separate syntactic categories

    4. D

      Ambiguity guarantees that every expression has multiple meanings

    Correct answer
    C

    Precedence and associativity rules can replace many separate syntactic categories

    Explanation

    Instead of creating separate grammar categories for each precedence level, a compact ambiguous grammar can use rules specifying operator precedence and associativity.

  33. 33

    What advantage does a parser generator provide by reporting parsing conflicts?

    1. A

      It automatically proves that the language has no semantic errors

    2. B

      It helps reveal difficult constructs or inherent ambiguities in the grammar

    3. C

      It ensures that every hand-written parser is slower than the generated parser

    4. D

      It removes the need for a language designer to understand the grammar

    Correct answer
    B

    It helps reveal difficult constructs or inherent ambiguities in the grammar

    Explanation

    Parsing conflicts can identify places where a grammar is difficult to parse or inherently ambiguous, helping designers improve or deliberately disambiguate it.

  34. 34

    What does a flow graph model in compiler optimization?

    1. A

      The flow of control among basic blocks in a program

    2. B

      The operations available in a dictionary

    3. C

      The possible measurement outcomes of a qubit

    4. D

      The characters accepted by a regular expression

    Correct answer
    A

    The flow of control among basic blocks in a program

    Explanation

    A flow graph represents basic blocks as nodes and control-flow possibilities between blocks as directed edges.

  35. 35

    When does a definition of a variable reach a later statement?

    1. A

      When the later statement appears in a different procedure

    2. B

      When the variable is redefined at least once between the statements

    3. C

      When the definition is located only in an unreachable basic block

    4. D

      When an execution path connects the statements without redefining the variable

    Correct answer
    D

    When an execution path connects the statements without redefining the variable

    Explanation

    A definition reaches a statement if there is an execution path from the defining statement to that statement along which the variable is not redefined, or killed.

  36. 36

    What question does the reaching-definitions problem answer?

    1. A

      Which quantum states can be cloned

    2. B

      Which tokens belong to a regular language

    3. C

      Which target machine has the fastest processor

    4. D

      Which definitions may reach which program points

    Correct answer
    D

    Which definitions may reach which program points

    Explanation

    Reaching definitions analysis determines the definitions that may reach particular points in a program.

  37. 37

    Which optimizations can use reaching-definitions information?

    1. A

      Constant propagation and loop-invariant code motion

    2. B

      Hash-table resizing and linked-list traversal

    3. C

      Quantum measurement and state preparation

    4. D

      Lexical tokenization and grammar construction

    Correct answer
    A

    Constant propagation and loop-invariant code motion

    Explanation

    The content specifically identifies constant propagation and loop-invariant code motion as optimizations supported by reaching definitions.

  38. 38

    What is the data model of the flow-graph abstraction for reaching definitions?

    1. A

      A unit vector together with a unitary operator

    2. B

      A universal set together with insertion and deletion operations

    3. C

      A set of strings together with union and concatenation

    4. D

      A semilattice of subsets of variable definitions together with a directed graph

    Correct answer
    D

    A semilattice of subsets of variable definitions together with a directed graph

    Explanation

    The abstraction combines data-flow values represented by a semilattice of definition subsets with a directed graph of basic blocks.

  39. 39

    What does the transfer function associated with a basic block compute?

    1. A

      The grammar production selected by the next input token

    2. B

      The probability of a quantum measurement outcome

    3. C

      The output data-flow value at the block's end from its input value

    4. D

      The set of predecessor blocks from the block's output value

    Correct answer
    C

    The output data-flow value at the block's end from its input value

    Explanation

    A transfer function maps the data-flow value entering a node to the value leaving that node.

  40. 40

    What does the confluence operator compute in the flow-graph abstraction?

    1. A

      The data-flow value at a node's beginning from the values at the ends of its predecessors

    2. B

      The target machine instructions from the source-language tokens

    3. C

      The regular-expression transitions from the grammar's terminals

    4. D

      The quantum state after applying a measurement gate

    Correct answer
    A

    The data-flow value at a node's beginning from the values at the ends of its predecessors

    Explanation

    The confluence operator combines data-flow values from all predecessor blocks to determine the value entering a node.

  41. 41

    Why must the confluence operator be commutative and associative in the described formulation?

    1. A

      It simulates a unitary operator, which must preserve quantum amplitudes

    2. B

      It constructs regular expressions using concatenation only

    3. C

      It guarantees that every parser uses a bottom-up strategy

    4. D

      It operates over a semilattice, where combining predecessor values must not depend on order or grouping

    Correct answer
    D

    It operates over a semilattice, where combining predecessor values must not depend on order or grouping

    Explanation

    Because predecessor values are combined in a semilattice, the confluence operation must be commutative and associative so the result is independent of combination order.

  42. 42

    What is the state of a qubit represented as?

    1. A

      A directed graph whose nodes are basic blocks

    2. B

      A Boolean value that must be either zero or one

    3. C

      A set of grammar productions with no numerical representation

    4. D

      A unit vector in a complex vector space

    Correct answer
    D

    A unit vector in a complex vector space

    Explanation

    A qubit is represented by a unit vector in a complex Hilbert space, often written as α∣0⟩+β∣1⟩\alpha\lvert 0\rangle + \beta\lvert 1\rangleα∣0⟩+β∣1⟩.

  43. 43

    For a qubit state α∣0⟩+β∣1⟩\alpha\lvert 0\rangle + \beta\lvert 1\rangleα∣0⟩+β∣1⟩, what condition ensures that the state is normalized?

    1. A

      ∣α∣2+∣β∣2=1|\alpha|^2 + |\beta|^2 = 1∣α∣2+∣β∣2=1

    2. B

      ∣α∣+∣β∣=0|\alpha| + |\beta| = 0∣α∣+∣β∣=0

    3. C

      α+β=1\alpha + \beta = 1α+β=1 for all complex amplitudes

    4. D

      ∣α∣2−∣β∣2=1|\alpha|^2 - |\beta|^2 = 1∣α∣2−∣β∣2=1

    Correct answer
    A

    ∣α∣2+∣β∣2=1|\alpha|^2 + |\beta|^2 = 1∣α∣2+∣β∣2=1

    Explanation

    Normalization requires the sum of the squared absolute values of the amplitudes to equal one: ∣α∣2+∣β∣2=1|\alpha|^2 + |\beta|^2 = 1∣α∣2+∣β∣2=1.

  44. 44

    What fundamentally distinguishes a qubit from a classical bit?

    1. A

      A qubit cannot be represented mathematically by a vector

    2. B

      A qubit can store only one of two permanent classical values

    3. C

      A qubit can exist in a superposition of basis states

    4. D

      A qubit changes state only when a classical program assigns it a value

    Correct answer
    C

    A qubit can exist in a superposition of basis states

    Explanation

    Unlike a classical bit, a qubit can be a complex linear combination, or superposition, of the basis states ∣0⟩\lvert 0\rangle∣0⟩ and ∣1⟩\lvert 1\rangle∣1⟩.

  45. 45

    How is the evolution of a closed quantum system represented?

    1. A

      By a measurement operation that permanently collapses every state

    2. B

      By an irreversible Boolean operation that discards amplitudes

    3. C

      By a unitary operator acting as a reversible transformation of the state vector

    4. D

      By a context-free grammar that rewrites quantum symbols

    Correct answer
    C

    By a unitary operator acting as a reversible transformation of the state vector

    Explanation

    Closed-system evolution is represented by a unitary operator, which is reversible and can be viewed geometrically as a rotation in Hilbert space.

  46. 46

    What does applying a Hadamard operator to ∣0⟩\lvert 0\rangle∣0⟩ produce?

    1. A

      ∣0⟩−∣1⟩2\frac{\lvert 0\rangle - \lvert 1\rangle}{\sqrt{2}}2​∣0⟩−∣1⟩​

    2. B

      ∣1⟩\lvert 1\rangle∣1⟩

    3. C

      ∣0⟩+∣1⟩\lvert 0\rangle + \lvert 1\rangle∣0⟩+∣1⟩ without normalization

    4. D

      ∣0⟩+∣1⟩2\frac{\lvert 0\rangle + \lvert 1\rangle}{\sqrt{2}}2​∣0⟩+∣1⟩​

    Correct answer
    D

    ∣0⟩+∣1⟩2\frac{\lvert 0\rangle + \lvert 1\rangle}{\sqrt{2}}2​∣0⟩+∣1⟩​

    Explanation

    The Hadamard operator maps ∣0⟩\lvert 0\rangle∣0⟩ to the equal superposition ∣0⟩+∣1⟩2\frac{\lvert 0\rangle + \lvert 1\rangle}{\sqrt{2}}2​∣0⟩+∣1⟩​.

  47. 47

    What does applying a Hadamard operator to ∣1⟩\lvert 1\rangle∣1⟩ produce?

    1. A

      ∣0⟩+∣1⟩2\frac{\lvert 0\rangle + \lvert 1\rangle}{\sqrt{2}}2​∣0⟩+∣1⟩​

    2. B

      ∣1⟩−∣0⟩\lvert 1\rangle - \lvert 0\rangle∣1⟩−∣0⟩ without normalization

    3. C

      ∣0⟩−∣1⟩2\frac{\lvert 0\rangle - \lvert 1\rangle}{\sqrt{2}}2​∣0⟩−∣1⟩​

    4. D

      ∣0⟩\lvert 0\rangle∣0⟩

    Correct answer
    C

    ∣0⟩−∣1⟩2\frac{\lvert 0\rangle - \lvert 1\rangle}{\sqrt{2}}2​∣0⟩−∣1⟩​

    Explanation

    The Hadamard operator maps ∣1⟩\lvert 1\rangle∣1⟩ to ∣0⟩−∣1⟩2\frac{\lvert 0\rangle - \lvert 1\rangle}{\sqrt{2}}2​∣0⟩−∣1⟩​.

  48. 48

    What results from applying the Hadamard operator twice in succession?

    1. A

      A measurement that always returns zero

    2. B

      A bit-flip transformation on every input

    3. C

      The identity transformation

    4. D

      An irreversible collapse into a superposition

    Correct answer
    C

    The identity transformation

    Explanation

    The Hadamard operator is its own inverse, so applying it twice gives the identity matrix.

  49. 49

    How does a CNOT gate act on its target qubit?

    1. A

      It leaves the target unchanged when the control is ∣0⟩\lvert 0\rangle∣0⟩ and flips it when the control is ∣1⟩\lvert 1\rangle∣1⟩

    2. B

      It always flips the target regardless of the control state

    3. C

      It flips the control and leaves the target unchanged

    4. D

      It measures both qubits and outputs only the control value

    Correct answer
    A

    It leaves the target unchanged when the control is ∣0⟩\lvert 0\rangle∣0⟩ and flips it when the control is ∣1⟩\lvert 1\rangle∣1⟩

    Explanation

    CNOT uses one qubit as control and one as target: the target passes through unchanged for control ∣0⟩\lvert 0\rangle∣0⟩ and is flipped for control ∣1⟩\lvert 1\rangle∣1⟩.

  50. 50

    What happens when a qubit α∣0⟩+β∣1⟩\alpha\lvert 0\rangle + \beta\lvert 1\rangleα∣0⟩+β∣1⟩ is measured in the computational basis?

    1. A

      The outcome is zero with probability ∣α∣|\alpha|∣α∣ and one with probability ∣β∣|\beta|∣β∣

    2. B

      The outcome is zero with probability ∣α∣2|\alpha|^2∣α∣2 or one with probability ∣β∣2|\beta|^2∣β∣2

    3. C

      The state remains unchanged and both amplitudes are observed directly

    4. D

      The outcome is the complex amplitude α+β\alpha + \betaα+β

    Correct answer
    B

    The outcome is zero with probability ∣α∣2|\alpha|^2∣α∣2 or one with probability ∣β∣2|\beta|^2∣β∣2

    Explanation

    Measurement returns a classical bit: zero with probability ∣α∣2|\alpha|^2∣α∣2 and one with probability ∣β∣2|\beta|^2∣β∣2.

  51. 51

    What happens to the qubit state after a computational-basis measurement?

    1. A

      It collapses to ∣0⟩\lvert 0\rangle∣0⟩ or ∣1⟩\lvert 1\rangle∣1⟩ according to the observed outcome

    2. B

      It is copied into two identical qubits for later computation

    3. C

      It remains in the original superposition with unchanged amplitudes

    4. D

      It becomes a classical probability distribution over all complex vectors

    Correct answer
    A

    It collapses to ∣0⟩\lvert 0\rangle∣0⟩ or ∣1⟩\lvert 1\rangle∣1⟩ according to the observed outcome

    Explanation

    Measurement is not unitary and collapses the state to the basis state corresponding to the observed classical outcome.

  52. 52

    How is the state space of a composite quantum system formed?

    1. A

      By taking the tensor product of the component systems' state spaces

    2. B

      By taking the union of the component systems' possible classical outputs

    3. C

      By averaging the dimensions of the component systems

    4. D

      By concatenating their grammar productions

    Correct answer
    A

    By taking the tensor product of the component systems' state spaces

    Explanation

    The state space of a composite system is the tensor-product space of the component state spaces.

  53. 53

    What is the dimension of the state space of nnn combined qubits?

    1. A

      n2n^2n2

    2. B

      2n2n2n

    3. C

      n+2n+2n+2

    4. D

      2n2^n2n

    Correct answer
    D

    2n2^n2n

    Explanation

    Each additional qubit doubles the state-space dimension, so nnn qubits have a state space of dimension 2n2^n2n.

  54. 54

    Why are large quantum systems difficult to simulate on classical computers?

    1. A

      They require a separate classical processor for every possible grammar

    2. B

      Their state-space dimension grows exponentially as 2n2^n2n with the number of qubits

    3. C

      They cannot be represented using vectors or matrices

    4. D

      Their state-space dimension remains fixed while their measurement time grows linearly

    Correct answer
    B

    Their state-space dimension grows exponentially as 2n2^n2n with the number of qubits

    Explanation

    Because the state space has dimension 2n2^n2n, adding qubits causes exponential growth in the number of amplitudes needed for a classical simulation.

  55. 55

    Which restriction distinguishes quantum circuits from ordinary Boolean circuits?

    1. A

      Quantum circuits require every gate to be a logical OR gate

    2. B

      Quantum circuits contain no measurement operations

    3. C

      Quantum circuits allow unlimited copying of arbitrary unknown states

    4. D

      Quantum circuits allow no fan-out because unknown quantum states cannot be copied

    Correct answer
    D

    Quantum circuits allow no fan-out because unknown quantum states cannot be copied

    Explanation

    The no-cloning theorem prevents copying an unknown quantum state, so quantum circuits do not allow fan-out.

  56. 56

    What state results from applying a Hadamard gate followed by a CNOT gate to ∣00⟩\lvert 00\rangle∣00⟩?

    1. A

      ∣01⟩+∣10⟩2\frac{\lvert 01\rangle + \lvert 10\rangle}{\sqrt{2}}2​∣01⟩+∣10⟩​

    2. B

      ∣00⟩+∣11⟩\lvert 00\rangle + \lvert 11\rangle∣00⟩+∣11⟩ without normalization

    3. C

      ∣00⟩+∣11⟩2\frac{\lvert 00\rangle + \lvert 11\rangle}{\sqrt{2}}2​∣00⟩+∣11⟩​

    4. D

      ∣00⟩−∣11⟩2\frac{\lvert 00\rangle - \lvert 11\rangle}{\sqrt{2}}2​∣00⟩−∣11⟩​

    Correct answer
    C

    ∣00⟩+∣11⟩2\frac{\lvert 00\rangle + \lvert 11\rangle}{\sqrt{2}}2​∣00⟩+∣11⟩​

    Explanation

    The Hadamard creates a superposition on the first qubit, and CNOT correlates the second qubit with it, producing ∣00⟩+∣11⟩2\frac{\lvert 00\rangle + \lvert 11\rangle}{\sqrt{2}}2​∣00⟩+∣11⟩​.

  57. 57

    Why is the state ∣00⟩+∣11⟩2\frac{\lvert 00\rangle + \lvert 11\rangle}{\sqrt{2}}2​∣00⟩+∣11⟩​ called entangled?

    1. A

      It can be represented as two unrelated classical probability distributions

    2. B

      It contains two qubits that always remain in independent states

    3. C

      It cannot be expressed as a tensor product of two individual single-qubit states

    4. D

      It results from applying only irreversible measurement operations

    Correct answer
    C

    It cannot be expressed as a tensor product of two individual single-qubit states

    Explanation

    The state is entangled because it cannot be factored into a tensor product of separate states for the two qubits.

  58. 58

    What is the significance of Shor's algorithm for cryptography?

    1. A

      It proves that RSA can already be broken by current classical computers

    2. B

      A sufficiently large fault-tolerant quantum computer could factor integers efficiently enough to threaten RSA

    3. C

      It encrypts messages using a classical algorithm that requires no factoring assumptions

    4. D

      It prevents quantum computers from performing integer factorization

    Correct answer
    B

    A sufficiently large fault-tolerant quantum computer could factor integers efficiently enough to threaten RSA

    Explanation

    Shor's algorithm factors integers using approximately cubic operation complexity in the stated formulation, potentially making RSA vulnerable on large enough quantum computers.

  59. 59

    Why is RSA described as currently safer despite the threat from Shor's algorithm?

    1. A

      RSA uses no mathematical problem related to integer factorization

    2. B

      Classical computers can already factor RSA-sized integers efficiently

    3. C

      No quantum algorithm for factoring integers has been discovered

    4. D

      Large enough fault-tolerant quantum computers are not yet available

    Correct answer
    D

    Large enough fault-tolerant quantum computers are not yet available

    Explanation

    The threat is theoretical and future-oriented because existing quantum computers are not large or reliable enough to factor the integers used by RSA in practice.

  60. 60

    What is the structure of the hybrid computation used in Shor's algorithm as described?

    1. A

      A classical computer performs preprocessing and postprocessing while a quantum computer computes a function's period

    2. B

      A quantum computer generates machine code while a classical computer stores no results

    3. C

      A classical computer replaces the quantum computation entirely with a parser

    4. D

      A quantum computer performs all preprocessing, while a classical computer performs only measurements

    Correct answer
    A

    A classical computer performs preprocessing and postprocessing while a quantum computer computes a function's period

    Explanation

    The classical system reduces the factoring problem and processes the result, while the quantum system computes the period of a function.

  61. 61

    Why do current quantum computers function like specialized devices attached to classical computers?

    1. A

      Quantum computers cannot perform any unitary operations without compiling Boolean circuits

    2. B

      Quantum computers are unable to interact with any external control system

    3. C

      Classical computers prepare inputs and process the classical bits returned by quantum measurements

    4. D

      Classical computers are used only to display quantum states visually

    Correct answer
    C

    Classical computers prepare inputs and process the classical bits returned by quantum measurements

    Explanation

    Current systems are controlled by classical computers, which prepare inputs, invoke quantum routines, and process the classical measurement results.

  62. 62

    What programming restriction follows from the no-cloning theorem in quantum programming languages?

    1. A

      A program must measure every variable before it can be stored

    2. B

      A program must represent every quantum state as a classical Boolean value

    3. C

      A program cannot use an operation that copies an unknown quantum variable

    4. D

      A program cannot apply any unitary operation to a quantum variable

    Correct answer
    C

    A program cannot use an operation that copies an unknown quantum variable

    Explanation

    Because unknown quantum states cannot be cloned, quantum programming languages generally disallow unrestricted copy operations on quantum variables.

  63. 63

    What does the compiler framework for classical languages demonstrate about quantum-language compilers?

    1. A

      The abstraction-based framework used for classical compilers can also support quantum programming languages

    2. B

      Quantum compilers must abandon front ends, intermediate representations, and back ends

    3. C

      Quantum compilers can be built only by directly programming physical hardware

    4. D

      Quantum languages cannot use traditional compiler phases because their states are vectors

    Correct answer
    A

    The abstraction-based framework used for classical compilers can also support quantum programming languages

    Explanation

    The content argues that the established compiler framework and abstractions can be adapted to construct compilers for quantum programming languages.

  64. 64

    Why can natural language be problematic as a programming language?

    1. A

      Natural language is inherently highly ambiguous, which can create disagreements about intended semantics

    2. B

      Natural language contains too few words to express computational procedures

    3. C

      Natural language cannot describe any syntactic structure

    4. D

      Natural language is always more precise than formal programming languages

    Correct answer
    A

    Natural language is inherently highly ambiguous, which can create disagreements about intended semantics

    Explanation

    The content identifies inherent ambiguity in natural language as a problem because programmers and compiler designers could interpret the intended semantics differently.

  65. 65

    What practical advantage can machine-learning-based compiler generation potentially provide?

    1. A

      It guarantees correct compilers for all languages without training examples

    2. B

      It eliminates the need to define programming-language semantics

    3. C

      It makes parsing theory unnecessary for every programming language

    4. D

      It may generate programs or compilers from examples or spoken descriptions of desired behavior

    Correct answer
    D

    It may generate programs or compilers from examples or spoken descriptions of desired behavior

    Explanation

    The content describes experiments in which examples or natural-language descriptions are used to generate programs and potentially compiler-like systems.

  66. 66

    Why is thinking before programming presented as a better software-development strategy?

    1. A

      Programming before planning is required for discovering every algorithm

    2. B

      Planning helps formulate the problem and reduces the likelihood of debugging an ill-conceived solution afterward

    3. C

      Planning guarantees that no program will ever contain a syntax error

    4. D

      Planning replaces the need to test or evaluate a program

    Correct answer
    B

    Planning helps formulate the problem and reduces the likelihood of debugging an ill-conceived solution afterward

    Explanation

    The content recommends thinking before programming because deliberate problem formulation is generally more effective than coding first and only later trying to determine what went wrong.

  67. 67

    What teaching strategy is recommended for students with different learning styles?

    1. A

      Use only written explanations because all students learn best through reading

    2. B

      Avoid games and puzzles because they distract from computational thinking

    3. C

      Present important ideas repeatedly in different forms, such as text, visuals, or interactive activities

    4. D

      Repeat the same presentation without changing its format

    Correct answer
    C

    Present important ideas repeatedly in different forms, such as text, visuals, or interactive activities

    Explanation

    The content emphasizes that students learn in different ways and recommends repetition through varied methods, including reading, visuals, videos, games, and puzzles.

Question 1 of 67
Question 1 of 67

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent