Computational Thinking and Compilers
- 67Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What are the two pillars of computational thinking emphasized in the content?
What are the two pillars of computational thinking emphasized in the content?
67 questions
- 1
What are the two pillars of computational thinking emphasized in the content?
- A
Measurement and simulation
- B
Hardware and networking
- C
Syntax and compilation
- D
Abstraction and algorithms
Correct answer
DAbstraction and algorithms
Explanation
The content identifies abstractions and algorithms as the two pillars that transformed compiler design from an art into a science.
- A
- 2
Which description best captures computational thinking?
- A
Memorizing programming languages so problems can be solved without formal planning
- B
Formulating problems with abstractions so solutions can be represented as computational steps and algorithms
- C
Representing every real-world problem directly as hardware without using mathematical models
- D
Writing computer programs first and analyzing their behavior only after they fail
Correct answer
BFormulating 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.
- A
- 3
Why is there no single standard definition of abstraction across all fields?
- A
Every abstraction must be expressed using a Turing-complete language
- B
Abstractions are used only in computer science and therefore lack broader agreement
- C
Mathematical models cannot be applied consistently to scientific disciplines
- D
Different fields use distinct abstractions to describe their own subject matter
Correct answer
DDifferent 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.
- A
- 4
In the presented computer science definition, what two components make up an abstraction?
- A
A compiler and a target machine
- B
A grammar and a parse tree
- C
A data model and a set of operations
- D
A graph and a measurement device
Correct answer
CA 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.
- A
- 5
What is distinctive about the computer science definition of abstraction compared with many definitions in other fields?
- A
It requires every model to be computationally universal
- B
It includes operations for manipulating the data in the model
- C
It requires the model to describe only physical objects
- D
It excludes any language-like way of interacting with the model
Correct answer
BIt 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.
- A
- 6
Which set of operations belongs to the dictionary abstraction described in the content?
- A
Compile a program, optimize code, and generate instructions
- B
Sort an element, reverse a list, and calculate a path
- C
Measure a state, clone a state, and reverse a measurement
- D
Insert an element, delete an element, and test membership
Correct answer
DInsert an element, delete an element, and test membership
Explanation
The dictionary supports insertion, deletion, and checking whether a given element belongs to the set.
- A
- 7
What is the data model of the dictionary abstraction?
- A
A sequence of tokens and a parse tree that is initially complete
- B
A vector space and a unitary matrix that is initially identity
- C
A graph of basic blocks and a set of control-flow edges
- D
A universal set U and a subset S of U that is initially empty
Correct answer
DA universal set U and a subset S of U that is initially empty
Explanation
The dictionary's data model consists of a universal set U and a subset S⊆U, with S initially empty.
- A
- 8
Why can the operations of an abstraction be viewed as a programming language that need not be Turing-complete?
- A
The operations are unrelated to the data model being manipulated
- B
The operations describe only the hardware used to implement the abstraction
- C
The operations must always simulate a universal Turing machine
- D
The operations provide a way to manipulate the model without necessarily expressing every computation
Correct answer
DThe 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.
- A
- 9
Which formal definition of an algorithm is given in the content?
- A
A Turing machine that halts on all inputs
- B
A parser that accepts every syntactically valid string
- C
A program that produces output for at least one input
- D
A mathematical model with no associated operations
Correct answer
AA Turing machine that halts on all inputs
Explanation
Formally, an algorithm is defined as a Turing machine that halts on every input.
- A
- 10
Which category contains dictionaries, stacks, queues, graphs, trees, and classes with methods lacking specifications?
- A
Abstract implementations
- B
Computational abstractions
- C
Declarative abstractions
- D
Fundamental abstractions
Correct answer
DFundamental abstractions
Explanation
Fundamental abstractions are commonly introduced in first computer science courses and include structures such as dictionaries, stacks, queues, graphs, and trees.
- A
- 11
What is the purpose of an abstract implementation?
- A
To represent the physical state of a quantum system
- B
To specify desired behavior without describing how it is achieved
- C
To provide data structures useful for implementing fundamental abstractions
- D
To model a programming language with Turing-complete operations
Correct answer
CTo 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.
- A
- 12
What characterizes a declarative abstraction?
- A
It always provides a concrete low-level implementation
- B
It specifies what is wanted without specifying how to accomplish it
- C
It consists only of physical circuits and hardware components
- D
It must be Turing-complete and model an entire programming language
Correct answer
BIt 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.
- A
- 13
What distinguishes computational abstractions from the other categories?
- A
They more closely model programming languages and are Turing-complete
- B
They are used exclusively to implement hash tables and search trees
- C
They specify results while deliberately excluding computational procedures
- D
They can represent only sets with insertion and deletion operations
Correct answer
AThey 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.
- A
- 14
How can abstractions be layered?
- A
An abstraction must replace every lower-level abstraction in a system
- B
An abstraction can be used only if it is implemented directly in hardware
- C
An abstraction can contain data but cannot contain operations
- D
An abstraction can be implemented by algorithms or in terms of other abstractions
Correct answer
DAn 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.
- A
- 15
What is the defining purpose of a compiler in the content?
- A
To translate a source program into a semantically equivalent target program
- B
To convert every program into a context-free grammar
- C
To measure the running time of every possible algorithm
- D
To execute a source program without changing its representation
Correct answer
ATo 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.
- A
- 16
What major architectural idea changed compiler design during the 1960s and 1970s?
- A
Viewing a compiler as a sequence of phases producing semantically equivalent lower-level representations
- B
Using one monolithic algorithm for lexical analysis, parsing, and optimization
- C
Eliminating semantic equivalence as a requirement for translation
- D
Replacing all intermediate representations with direct hardware execution
Correct answer
AViewing 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.
- A
- 17
Which description correctly distinguishes the front end and back end of a compiler?
- A
The front end and back end are identical phases with different names
- B
The front end executes target code, while the back end checks source-language syntax
- C
The front end analyzes the source language, while the back end produces code for a target machine
- D
The front end performs only optimization, while the back end performs only lexical analysis
Correct answer
CThe 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.
- A
- 18
How does LLVM support multiple source languages and target machines?
- A
Each source language must have a separate complete compiler for every target machine
- B
Different front ends translate into LLVM IR, which can be optimized and processed by multiple back ends
- C
LLVM replaces front ends with handwritten machine-code programs
- D
LLVM uses only one target language and does not support intermediate representations
Correct answer
BDifferent 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.
- A
- 19
If a new programming language is being compiled for an existing machine using LLVM, what major component generally needs to be added?
- A
A new code generator for every existing source language
- B
A quantum measurement phase for the source program
- C
A new front end that translates the language into LLVM IR
- D
A replacement for the LLVM optimizer and all target back ends
Correct answer
CA 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.
- A
- 20
If an existing programming language must target a new machine architecture in LLVM, what component generally needs to be created?
- A
A replacement for the source-language front end
- B
A new context-free grammar for the programming language
- C
An LLVM IR-to-target-machine-code generator
- D
A new lexical specification for every token
Correct answer
CAn 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.
- A
- 21
What is the data model of the regular-expression abstraction?
- A
Sets of basic blocks connected by control-flow edges
- B
Trees representing syntactic categories
- C
Vectors representing quantum states
- D
Sets of strings over an alphabet
Correct answer
DSets of strings over an alphabet
Explanation
Regular expressions operate over sets of strings defined over some alphabet.
- A
- 22
Which operations define the regular-expression abstraction described in the content?
- A
Union, concatenation, and Kleene closure
- B
Transfer, confluence, and measurement
- C
Shifting, reducing, and code generation
- D
Insertion, deletion, and membership testing
Correct answer
AUnion, concatenation, and Kleene closure
Explanation
The regular-expression abstraction uses union, concatenation, and Kleene closure to construct sets of strings.
- A
- 23
What was the running-time characteristic of Thompson's just-in-time simulation approach for regular expressions?
- A
It was linear in the sum of the regular-expression length and input-string length
- B
It was quadratic only in the number of grammar productions
- C
It was linear in the product of the regular-expression length and input-string length
- D
It was independent of both the pattern and input lengths
Correct answer
CIt 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∣, where ∣R∣ is the regular-expression length and ∣w∣ is the input length.
- A
- 24
What was the observed running-time characteristic of the dynamic lazy DFA-transition construction approach?
- A
It required time exponential in the number of input characters
- B
It was linear in the product of the regular-expression length and input-string length
- C
It required time independent of the regular expression
- D
It was linear in the sum of the regular-expression length and input-string length
Correct answer
DIt 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∣, the sum of the pattern and input lengths.
- A
- 25
What does a lexical-analyzer generator such as Lex allow users to do?
- A
Simulate arbitrary quantum circuits without measurement
- B
Create lexical analyzers from token specifications without implementing pattern-matching algorithms themselves
- C
Compute reaching definitions for intermediate representations
- D
Generate target machine code directly from an ambiguous grammar
Correct answer
BCreate 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.
- A
- 26
In the integer-token example, what does the generated lexer do when it recognizes one or more digits?
- A
It treats the digits as a grammar production and returns a parse tree
- B
It stores the digit sequence in a table and returns a NUM token with a pointer to it
- C
It converts the digits immediately into machine instructions
- D
It deletes the digit sequence after checking whether it is in a dictionary
Correct answer
BIt 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.
- A
- 27
What role do context-free grammars play in compiler design?
- A
They implement hash tables used by symbol tables
- B
They declaratively specify the grammatical structure of programming languages
- C
They define the probabilities of quantum measurement outcomes
- D
They specify only the machine instructions generated by a compiler
Correct answer
BThey declaratively specify the grammatical structure of programming languages
Explanation
Context-free grammars are used as declarative abstractions for describing the syntax of programming languages.
- A
- 28
What is the purpose of a syntax-directed scheme attached to a context-free grammar?
- A
To calculate the running time of a regular-expression matcher
- B
To store all variables in a compiler symbol table
- C
To translate a token stream into an output such as a syntax tree
- D
To determine the temperature required for a quantum processor
Correct answer
CTo 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.
- A
- 29
What does YACC provide to compiler designers?
- A
A tool for constructing syntax analyzers from grammatical specifications
- B
A quantum circuit simulator based only on measurement gates
- C
A regular-expression engine for matching input strings
- D
A hardware device for executing compiled programs
Correct answer
AA 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.
- A
- 30
Why did the combination of Lex and YACC become useful in compiler courses?
- A
It converted every programming language directly into quantum circuits
- B
It allowed students to experiment with programming-language syntax using generated lexers and parsers
- C
It eliminated the need to define either tokens or grammatical rules
- D
It guaranteed that all grammars would be free of ambiguity
Correct answer
BIt 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.
- A
- 31
How does YACC resolve the described shift-reduce conflict?
- A
It uses a rule that favors shifting
- B
It always deletes the conflicting production
- C
It converts the grammar into a regular expression
- D
It always favors reducing before examining the next token
Correct answer
AIt 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.
- A
- 32
Why can an ambiguous expression grammar be convenient for a language such as C?
- A
The grammar no longer needs any parser or semantic rules
- B
C expressions contain no operator-precedence relationships
- C
Precedence and associativity rules can replace many separate syntactic categories
- D
Ambiguity guarantees that every expression has multiple meanings
Correct answer
CPrecedence 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.
- A
- 33
What advantage does a parser generator provide by reporting parsing conflicts?
- A
It automatically proves that the language has no semantic errors
- B
It helps reveal difficult constructs or inherent ambiguities in the grammar
- C
It ensures that every hand-written parser is slower than the generated parser
- D
It removes the need for a language designer to understand the grammar
Correct answer
BIt 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.
- A
- 34
What does a flow graph model in compiler optimization?
- A
The flow of control among basic blocks in a program
- B
The operations available in a dictionary
- C
The possible measurement outcomes of a qubit
- D
The characters accepted by a regular expression
Correct answer
AThe 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.
- A
- 35
When does a definition of a variable reach a later statement?
- A
When the later statement appears in a different procedure
- B
When the variable is redefined at least once between the statements
- C
When the definition is located only in an unreachable basic block
- D
When an execution path connects the statements without redefining the variable
Correct answer
DWhen 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.
- A
- 36
What question does the reaching-definitions problem answer?
- A
Which quantum states can be cloned
- B
Which tokens belong to a regular language
- C
Which target machine has the fastest processor
- D
Which definitions may reach which program points
Correct answer
DWhich definitions may reach which program points
Explanation
Reaching definitions analysis determines the definitions that may reach particular points in a program.
- A
- 37
Which optimizations can use reaching-definitions information?
- A
Constant propagation and loop-invariant code motion
- B
Hash-table resizing and linked-list traversal
- C
Quantum measurement and state preparation
- D
Lexical tokenization and grammar construction
Correct answer
AConstant propagation and loop-invariant code motion
Explanation
The content specifically identifies constant propagation and loop-invariant code motion as optimizations supported by reaching definitions.
- A
- 38
What is the data model of the flow-graph abstraction for reaching definitions?
- A
A unit vector together with a unitary operator
- B
A universal set together with insertion and deletion operations
- C
A set of strings together with union and concatenation
- D
A semilattice of subsets of variable definitions together with a directed graph
Correct answer
DA 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.
- A
- 39
What does the transfer function associated with a basic block compute?
- A
The grammar production selected by the next input token
- B
The probability of a quantum measurement outcome
- C
The output data-flow value at the block's end from its input value
- D
The set of predecessor blocks from the block's output value
Correct answer
CThe 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.
- A
- 40
What does the confluence operator compute in the flow-graph abstraction?
- A
The data-flow value at a node's beginning from the values at the ends of its predecessors
- B
The target machine instructions from the source-language tokens
- C
The regular-expression transitions from the grammar's terminals
- D
The quantum state after applying a measurement gate
Correct answer
AThe 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.
- A
- 41
Why must the confluence operator be commutative and associative in the described formulation?
- A
It simulates a unitary operator, which must preserve quantum amplitudes
- B
It constructs regular expressions using concatenation only
- C
It guarantees that every parser uses a bottom-up strategy
- D
It operates over a semilattice, where combining predecessor values must not depend on order or grouping
Correct answer
DIt 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.
- A
- 42
What is the state of a qubit represented as?
- A
A directed graph whose nodes are basic blocks
- B
A Boolean value that must be either zero or one
- C
A set of grammar productions with no numerical representation
- D
A unit vector in a complex vector space
Correct answer
DA 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⟩.
- A
- 43
For a qubit state α∣0⟩+β∣1⟩, what condition ensures that the state is normalized?
- A
∣α∣2+∣β∣2=1
- B
∣α∣+∣β∣=0
- C
α+β=1 for all complex amplitudes
- D
∣α∣2−∣β∣2=1
Correct answer
A∣α∣2+∣β∣2=1
Explanation
Normalization requires the sum of the squared absolute values of the amplitudes to equal one: ∣α∣2+∣β∣2=1.
- A
- 44
What fundamentally distinguishes a qubit from a classical bit?
- A
A qubit cannot be represented mathematically by a vector
- B
A qubit can store only one of two permanent classical values
- C
A qubit can exist in a superposition of basis states
- D
A qubit changes state only when a classical program assigns it a value
Correct answer
CA 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⟩ and ∣1⟩.
- A
- 45
How is the evolution of a closed quantum system represented?
- A
By a measurement operation that permanently collapses every state
- B
By an irreversible Boolean operation that discards amplitudes
- C
By a unitary operator acting as a reversible transformation of the state vector
- D
By a context-free grammar that rewrites quantum symbols
Correct answer
CBy 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.
- A
- 46
What does applying a Hadamard operator to ∣0⟩ produce?
- A
2​∣0⟩−∣1⟩​
- B
∣1⟩
- C
∣0⟩+∣1⟩ without normalization
- D
2​∣0⟩+∣1⟩​
Correct answer
D2​∣0⟩+∣1⟩​
Explanation
The Hadamard operator maps ∣0⟩ to the equal superposition 2​∣0⟩+∣1⟩​.
- A
- 47
What does applying a Hadamard operator to ∣1⟩ produce?
- A
2​∣0⟩+∣1⟩​
- B
∣1⟩−∣0⟩ without normalization
- C
2​∣0⟩−∣1⟩​
- D
∣0⟩
Correct answer
C2​∣0⟩−∣1⟩​
Explanation
The Hadamard operator maps ∣1⟩ to 2​∣0⟩−∣1⟩​.
- A
- 48
What results from applying the Hadamard operator twice in succession?
- A
A measurement that always returns zero
- B
A bit-flip transformation on every input
- C
The identity transformation
- D
An irreversible collapse into a superposition
Correct answer
CThe identity transformation
Explanation
The Hadamard operator is its own inverse, so applying it twice gives the identity matrix.
- A
- 49
How does a CNOT gate act on its target qubit?
- A
It leaves the target unchanged when the control is ∣0⟩ and flips it when the control is ∣1⟩
- B
It always flips the target regardless of the control state
- C
It flips the control and leaves the target unchanged
- D
It measures both qubits and outputs only the control value
Correct answer
AIt leaves the target unchanged when the control is ∣0⟩ and flips it when the control is ∣1⟩
Explanation
CNOT uses one qubit as control and one as target: the target passes through unchanged for control ∣0⟩ and is flipped for control ∣1⟩.
- A
- 50
What happens when a qubit α∣0⟩+β∣1⟩ is measured in the computational basis?
- A
The outcome is zero with probability ∣α∣ and one with probability ∣β∣
- B
The outcome is zero with probability ∣α∣2 or one with probability ∣β∣2
- C
The state remains unchanged and both amplitudes are observed directly
- D
The outcome is the complex amplitude α+β
Correct answer
BThe outcome is zero with probability ∣α∣2 or one with probability ∣β∣2
Explanation
Measurement returns a classical bit: zero with probability ∣α∣2 and one with probability ∣β∣2.
- A
- 51
What happens to the qubit state after a computational-basis measurement?
- A
It collapses to ∣0⟩ or ∣1⟩ according to the observed outcome
- B
It is copied into two identical qubits for later computation
- C
It remains in the original superposition with unchanged amplitudes
- D
It becomes a classical probability distribution over all complex vectors
Correct answer
AIt collapses to ∣0⟩ or ∣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.
- A
- 52
How is the state space of a composite quantum system formed?
- A
By taking the tensor product of the component systems' state spaces
- B
By taking the union of the component systems' possible classical outputs
- C
By averaging the dimensions of the component systems
- D
By concatenating their grammar productions
Correct answer
ABy 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.
- A
- 53
What is the dimension of the state space of n combined qubits?
- A
n2
- B
2n
- C
n+2
- D
2n
Correct answer
D2n
Explanation
Each additional qubit doubles the state-space dimension, so n qubits have a state space of dimension 2n.
- A
- 54
Why are large quantum systems difficult to simulate on classical computers?
- A
They require a separate classical processor for every possible grammar
- B
Their state-space dimension grows exponentially as 2n with the number of qubits
- C
They cannot be represented using vectors or matrices
- D
Their state-space dimension remains fixed while their measurement time grows linearly
Correct answer
BTheir state-space dimension grows exponentially as 2n with the number of qubits
Explanation
Because the state space has dimension 2n, adding qubits causes exponential growth in the number of amplitudes needed for a classical simulation.
- A
- 55
Which restriction distinguishes quantum circuits from ordinary Boolean circuits?
- A
Quantum circuits require every gate to be a logical OR gate
- B
Quantum circuits contain no measurement operations
- C
Quantum circuits allow unlimited copying of arbitrary unknown states
- D
Quantum circuits allow no fan-out because unknown quantum states cannot be copied
Correct answer
DQuantum 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.
- A
- 56
What state results from applying a Hadamard gate followed by a CNOT gate to ∣00⟩?
- A
2​∣01⟩+∣10⟩​
- B
∣00⟩+∣11⟩ without normalization
- C
2​∣00⟩+∣11⟩​
- D
2​∣00⟩−∣11⟩​
Correct answer
C2​∣00⟩+∣11⟩​
Explanation
The Hadamard creates a superposition on the first qubit, and CNOT correlates the second qubit with it, producing 2​∣00⟩+∣11⟩​.
- A
- 57
Why is the state 2​∣00⟩+∣11⟩​ called entangled?
- A
It can be represented as two unrelated classical probability distributions
- B
It contains two qubits that always remain in independent states
- C
It cannot be expressed as a tensor product of two individual single-qubit states
- D
It results from applying only irreversible measurement operations
Correct answer
CIt 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.
- A
- 58
What is the significance of Shor's algorithm for cryptography?
- A
It proves that RSA can already be broken by current classical computers
- B
A sufficiently large fault-tolerant quantum computer could factor integers efficiently enough to threaten RSA
- C
It encrypts messages using a classical algorithm that requires no factoring assumptions
- D
It prevents quantum computers from performing integer factorization
Correct answer
BA 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.
- A
- 59
Why is RSA described as currently safer despite the threat from Shor's algorithm?
- A
RSA uses no mathematical problem related to integer factorization
- B
Classical computers can already factor RSA-sized integers efficiently
- C
No quantum algorithm for factoring integers has been discovered
- D
Large enough fault-tolerant quantum computers are not yet available
Correct answer
DLarge 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.
- A
- 60
What is the structure of the hybrid computation used in Shor's algorithm as described?
- A
A classical computer performs preprocessing and postprocessing while a quantum computer computes a function's period
- B
A quantum computer generates machine code while a classical computer stores no results
- C
A classical computer replaces the quantum computation entirely with a parser
- D
A quantum computer performs all preprocessing, while a classical computer performs only measurements
Correct answer
AA 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.
- A
- 61
Why do current quantum computers function like specialized devices attached to classical computers?
- A
Quantum computers cannot perform any unitary operations without compiling Boolean circuits
- B
Quantum computers are unable to interact with any external control system
- C
Classical computers prepare inputs and process the classical bits returned by quantum measurements
- D
Classical computers are used only to display quantum states visually
Correct answer
CClassical 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.
- A
- 62
What programming restriction follows from the no-cloning theorem in quantum programming languages?
- A
A program must measure every variable before it can be stored
- B
A program must represent every quantum state as a classical Boolean value
- C
A program cannot use an operation that copies an unknown quantum variable
- D
A program cannot apply any unitary operation to a quantum variable
Correct answer
CA 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.
- A
- 63
What does the compiler framework for classical languages demonstrate about quantum-language compilers?
- A
The abstraction-based framework used for classical compilers can also support quantum programming languages
- B
Quantum compilers must abandon front ends, intermediate representations, and back ends
- C
Quantum compilers can be built only by directly programming physical hardware
- D
Quantum languages cannot use traditional compiler phases because their states are vectors
Correct answer
AThe 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.
- A
- 64
Why can natural language be problematic as a programming language?
- A
Natural language is inherently highly ambiguous, which can create disagreements about intended semantics
- B
Natural language contains too few words to express computational procedures
- C
Natural language cannot describe any syntactic structure
- D
Natural language is always more precise than formal programming languages
Correct answer
ANatural 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.
- A
- 65
What practical advantage can machine-learning-based compiler generation potentially provide?
- A
It guarantees correct compilers for all languages without training examples
- B
It eliminates the need to define programming-language semantics
- C
It makes parsing theory unnecessary for every programming language
- D
It may generate programs or compilers from examples or spoken descriptions of desired behavior
Correct answer
DIt 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.
- A
- 66
Why is thinking before programming presented as a better software-development strategy?
- A
Programming before planning is required for discovering every algorithm
- B
Planning helps formulate the problem and reduces the likelihood of debugging an ill-conceived solution afterward
- C
Planning guarantees that no program will ever contain a syntax error
- D
Planning replaces the need to test or evaluate a program
Correct answer
BPlanning 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.
- A
- 67
What teaching strategy is recommended for students with different learning styles?
- A
Use only written explanations because all students learn best through reading
- B
Avoid games and puzzles because they distract from computational thinking
- C
Present important ideas repeatedly in different forms, such as text, visuals, or interactive activities
- D
Repeat the same presentation without changing its format
Correct answer
CPresent 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.
- A

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