Computer Science Quiz on Automata and Algorithms

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the minimum possible number of states required in a deterministic finite automaton (DFA) to recognize the regular language L = {w₁aw2 | w₁, w₂ ∈ {a, b}*, |w₁| = 2, |w₂| ≥ 3}?

  • 5
  • 8 (correct)
  • 10
  • 16

A graph G has n vertices and 25 edges. If each vertex has a degree of at least 3, what is the maximum possible value for n?

  • 14
  • 12
  • 18
  • 16 (correct)

What is the correct interpretation of the statement 'static char var;'?

  • The variable var is allocated memory in the data segment of memory. (correct)
  • The variable var is allocated memory in the stack segment of memory.
  • The variable var is allocated memory in the heap segment of memory.
  • The variable var is allocated memory dynamically during runtime.

Consider the following C code snippet: 'm = malloc(10); m = NULL;'. What does this code do?

<p>It allocates 10 bytes of memory but then makes the pointer m invalid, resulting in a memory leak. (C)</p> Signup and view all the answers

Which of the following statements correctly describes the Towers of Hanoi algorithm with 'n' disks, in terms of its time complexity?

<p>O(2<sup>n</sup>) (A)</p> Signup and view all the answers

Which of the following statements is TRUE about a connected UDP socket in Linux?

<p>A process can successfully call the connect function again for an already connected UDP socket. (A)</p> Signup and view all the answers

What is the time complexity of adding two n x n matrices?

<p>O(n<sup>2</sup>) (B)</p> Signup and view all the answers

Which of the following statements is CORRECT about a circular queue implemented using a singly linked list with FRONT and REAR pointers?

<p>The next pointer of the front node points to the rear node. (C)</p> Signup and view all the answers

Which of the following statements concerning RIP is TRUE?

<p>RIP utilizes distance-vector routing. (C), RIP relies on UDP for packet transmission. (D)</p> Signup and view all the answers

Which routing protocol relies on TCP for packet transmission?

<p>OSPF (A)</p> Signup and view all the answers

Which of the following statements accurately describes the relationship between SLR, LALR, and Canonical LR parsing techniques?

<p>Canonical LR is more powerful than SLR. (C)</p> Signup and view all the answers

Suppose a machine has a 2^32 byte memory, divided into blocks of 32 bytes each. This machine utilizes a direct-mapped cache with 512 cache lines. What is the size of the tag field in bits for this cache?

<p>18 bits (A)</p> Signup and view all the answers

Consider two individuals, P and Q, applying for a job. The probability of P applying is 1/4, the probability of P applying given Q applies is 1/2, and the probability of Q applying given P applies is 1/3. What is the probability that P does not apply for the job, given that Q does not apply?

<p>4/5 (C)</p> Signup and view all the answers

Which of the following languages are regular?

<p>L₂ = {a^n b^m c^(2m) | n ≥ 0, m ≥ 0} (D)</p> Signup and view all the answers

Which of the following languages are context-free but not regular?

<p>L₁ = {a^p | p is a prime number} (B)</p> Signup and view all the answers

The memory hierarchy described in the text consists of I-cache, D-cache, L2-cache, and main memory. Considering the given read access times and hit ratios, what is the average read access time for memory operand fetch?

<p>25.8 nanoseconds (D)</p> Signup and view all the answers

How many multiple choice questions are included in the exam if the total mark is 100 and consists of both multiple choice and essay questions?

<p>15 (B)</p> Signup and view all the answers

Which building is situated in the middle based on the given positional relationships of buildings V, W, X, Y, and Z?

<p>V (B)</p> Signup and view all the answers

Which phrase correctly completes the sentence about Saturn being visible at night?

<p>bright enough (A)</p> Signup and view all the answers

Identify the option that contains words that are not synonymous.

<p>yielding, resistant (B)</p> Signup and view all the answers

What is the probability of selecting two socks of the same color from a collection of red, green, and blue socks?

<p>4/15 (A)</p> Signup and view all the answers

If X is a 30-digit number starting with the digit 4 followed by the digit 7, how many digits does X³ have?

<p>90 digits (B)</p> Signup and view all the answers

In the scenario involving three incorrectly labeled boxes, what is the best box to open to determine the contents?

<p>The box labeled both (D)</p> Signup and view all the answers

Which of the following sentences is grammatically incorrect regarding the visibility of Saturn?

<p>Saturn is enough bright to be seen. (B)</p> Signup and view all the answers

In the provided text, what is the author's primary argument concerning literature?

<p>Literature holds intrinsic merit and should not be solely valued for its ideological contributions. (D)</p> Signup and view all the answers

What is the main function of the air pressure contour lines in the provided plot?

<p>To depict changes in atmospheric pressure across the region. (A)</p> Signup and view all the answers

Which of the following statements best describes the author's view on the interpretation of actions in the country they describe?

<p>Gestures, even personal ones, are solely interpreted through a political lens. (B)</p> Signup and view all the answers

According to the grammar provided, which of the following strings is a member of the language generated?

<p>aaabbb (A)</p> Signup and view all the answers

What is the decimal value of the single-precision IEEE-754 floating-point number represented by 00111110011011010000000000000000?

<p>2.27 (D)</p> Signup and view all the answers

Which option accurately reflects the order in which nodes would be visited by the Breadth First Search (BFS) algorithm, assuming we start at node 'M' in the provided graph?

<p>POQNMR (D)</p> Signup and view all the answers

Analyzing the air pressure contour plot provided, which region shows the steepest gradient in air pressure?

<p>R (D)</p> Signup and view all the answers

Which of the following options represents a common misconception about the Breadth First Search (BFS) algorithm?

<p>BFS always visits the node with the highest degree first. (A)</p> Signup and view all the answers

What is the condition being checked in option (c)?

<p>Variable q is zero, r equals x, and y is greater than zero. (B)</p> Signup and view all the answers

Given a B+ tree with a block size of 512 bytes, what information does the maximum order of 52 represent?

<p>The maximum number of keys that can be stored in a single node. (D)</p> Signup and view all the answers

How many tuples does the provided SQL query return from the top_scorer table?

<p>7 (B)</p> Signup and view all the answers

In the given networking scenario, which option best describes what p and q represent?

<p>Transmission delay is p and propagation delay is q in milliseconds. (B)</p> Signup and view all the answers

What is the average waiting time in milliseconds for processes using preemptive priority scheduling?

<p>29 (D)</p> Signup and view all the answers

What will the C program output when executed?

<p>0 (A)</p> Signup and view all the answers

How many total characters are in the character set X = {P, Q, R, S, T}?

<p>5 (D)</p> Signup and view all the answers

In the context of the data provided, what is the significance of 'goals > ANY' in SQL?

<p>It checks if a player's goals are greater than at least one German player. (D)</p> Signup and view all the answers

What is the maximum number of router addresses that can be listed in the Record Route (RR) option of an IPv4 header?

<p>9 (C)</p> Signup and view all the answers

In the context of the C function 'printxy', what is the correct output when calling 'printxy(1, 1)'?

<p>1, 0 (D)</p> Signup and view all the answers

Given the function f(x) = R sin(πx/2) + S, with f'(π/2) = √2 and ∫(f(x)dx from 0 to π = 2R/π, what are the values of R and S?

<p>π/4 and 0 (D)</p> Signup and view all the answers

Which compiler phase is responsible for processing the token stream?

<p>Syntax Analyzer (A)</p> Signup and view all the answers

What is the logical representation of the statement: “It is not raining and it is pleasant, and it is not pleasant only if it is raining and it is cold”?

<p>(¬p^r)^(¬r → (p^q)) (A)</p> Signup and view all the answers

What is the rank of the matrix P + Q, where * P = [1 1 -1 7] and Q = [-1 -2 -1] [2 -3 4] [6 12 6] [5 10 5] [3 -2 3] *?

<p>2 (D)</p> Signup and view all the answers

Which of the following statements about the routing protocols RIP and OSPF are correct?

<p>All of the above. (D)</p> Signup and view all the answers

What is the minimum number of ordered pairs that need to be added to the relation R to make (X, R) a lattice, where X = {a, b, c, d, e} and R = {(a, a), (a, b), (a, c), (a, d), (a, e), (b, b), (b, c), (b, e), (c, c), (c, e), (d, d), (d, e), (e, e)}?

<p>0 (D)</p> Signup and view all the answers

Flashcards

Middle Building

In a sequence of buildings, V is West of W, Z is East of X and West of V, and W is West of Y. To find the middle building, we need to arrange them based on their positions.

Multiple Choice Questions

The exam has 20 questions worth 100 marks, with multiple-choice questions worth 3 marks each and essay questions worth 11 marks each. We need to determine the number of multiple-choice questions in the exam.

Saturn's Visibility

Saturn is visible to the naked eye on a clear night, but its brightness may vary. The answer choice expresses this visibility in a grammatically correct and natural way.

Identifying Non-Synonyms

Synonyms are words with similar meanings, while antonyms are words with opposite meanings. The question requires identification of the pair of words that are not synonyms.

Signup and view all the flashcards

Probability of Picking Socks

The probability of picking two socks of the same color from a group of 3 red, 4 green, and 3 blue socks needs to be determined.

Signup and view all the flashcards

Digits in X Cubed

The number X is a 30-digit number starting with 47. The question requires calculating the number of digits in X cubed (X³).

Signup and view all the flashcards

Mislabeled Boxes

Three boxes are mislabeled, one containing apples, another oranges, and the last both apples and oranges. You can open one box and pick one fruit to correctly label all the boxes.

Signup and view all the flashcards

Roots of e^x+0.5x²-2 = 0 in [-5, 5]

The number of roots of the equation e^x+0.5x²-2 = 0 within the interval [-5, 5] is 2.

Signup and view all the flashcards

Breadth-First Search (BFS) Algorithm

The BFS algorithm begins at a given source node and explores all of its neighbors. It then explores the neighbors of the explored nodes, and so on, until all reachable nodes have been visited. The nodes are visited in a breadth-first manner, meaning that nodes at the same level in the graph are visited in order.

Signup and view all the flashcards

IEEE-754 Single Precision Floating-Point Format

The IEEE-754 standard defines a binary representation for floating-point numbers, which includes a sign bit, an exponent, and a mantissa. The first bit represents the sign, the next 8 bits represent the exponent, and the remaining bits represent the mantissa.

Signup and view all the flashcards

Shared Resources by Threads within a Process

In a process, all threads share the same address space, allowing them to access the same memory locations. This enables communication and data sharing between threads. However, each thread has its own separate stack, which contains local variables and function call information.

Signup and view all the flashcards

Thunderstorm Prediction using Air Pressure Contour Plots

The air pressure contour plot shows areas of equal atmospheric pressure. Regions with closely spaced contour lines indicate a steeper pressure gradient, suggesting a faster change in pressure. This rapid change is often associated with thunderstorms.

Signup and view all the flashcards

Author's Belief about Literature and Ideology

The author believes that literature has intrinsic value and is not merely a tool for promoting ideology. The word 'urgent' highlights that the author considers ideology as a more pressing concern than literature.

Signup and view all the flashcards

Language Generated by a Formal Grammar

The grammar generates strings of the form a^m b^n, where m is greater than or equal to n, and n is greater than or equal to 0. In other words, the language consists of strings with any number of 'a's followed by at least the same number of 'b's.

Signup and view all the flashcards

Suppression of Literary Merit Due to Political Agenda

The author suggests that in their culture, literary works were devalued and only appreciated when they supported a specific political agenda. This implies a suppression of creative expression and a prioritization of ideology over artistic merit.

Signup and view all the flashcards

Regular Language (DFA)

A regular language is a set of strings that can be recognized by a deterministic finite automaton (DFA). This means that the DFA has a finite number of states and transitions based on the input symbols.

Signup and view all the flashcards

Minimum States in a DFA

The minimum number of states in a DFA that accepts a regular language is the smallest number of states required to uniquely distinguish all the possible string combinations.

Signup and view all the flashcards

Maximum Vertices in a Graph

The degree of a vertex in an undirected graph is the number of edges incident to that vertex. The maximum possible value of 'n' (number of vertices) depends on the constraints on the degree of each vertex and the number of edges.

Signup and view all the flashcards

Static Variable

A static variable in C retains its value throughout the program's lifetime. Its memory is allocated in the data section of the program, retaining its value even after the function exits.

Signup and view all the flashcards

Memory leaks (malloc + NULL)

The 'malloc' function allocates memory dynamically at runtime. When set to NULL, the allocated memory is released and cannot be accessed anymore, resulting in a memory leak.

Signup and view all the flashcards

Register Variable

A register variable is a variable stored in a CPU register for quick access. This allows for efficient data manipulation, but the register is restricted to the specific CPU architecture.

Signup and view all the flashcards

Connected UDP Socket

A connected UDP socket allows communication with the specified peer as established by the 'connect' function. However, UDP inherently allows communication with multiple peers concurrently.

Signup and view all the flashcards

Towers of Hanoi

The Towers of Hanoi puzzle requires moving disks between three rods, with constraints on what moves are allowed. It demonstrates exponential time complexity due to the doubling of steps with each additional disk.

Signup and view all the flashcards

Deleting Tuple (3,8)

No additional records needed to be deleted from the table to remove the tuple (3,8) as there is no information about the table's structure or constraints.

Signup and view all the flashcards

Max IPv4 Router Addresses in RR Field

The maximum number of router addresses that can be listed in the 'Record Route' option field of an IPv4 header is 9. This field helps in tracing the path of a packet through the network.

Signup and view all the flashcards

Lattice Property

The Hasse Diagram represents the partial order (X, R) where X is a set with elements {a, b, c, d, e} and R is a set of ordered pairs defining the relationship between those elements. A lattice is a special case of a partially ordered set. In a lattice, for any two elements, there is a unique least upper bound and greatest lower bound. The given Hasse Diagram is already a lattice, meaning no additional ordered pairs need to be added for it to become a lattice.

Signup and view all the flashcards

Matrix Rank

The rank of a matrix is the number of linearly independent rows or columns. In this case, the rank of the sum of the given matrices is 2, indicating two linearly independent rows or columns.

Signup and view all the flashcards

Compiler Phases

The Lexical Analyzer is responsible for converting the character stream into a token stream of meaningful units. The Syntax Analyzer constructs a parse tree based on the tokens and checks for grammatical errors. The Semantic Analyzer checks for semantic correctness and generates intermediate representation. Finally, the Code Generator translates the intermediate representation into machine code. Each phase processes a specific input based on its functionalities.

Signup and view all the flashcards

Logical Representation

The statement "It is not raining and it is pleasant, and it is not pleasant only if it is raining and it is cold" can be represented logically as (¬p^r)^(¬r → (p^q)), where p represents "It is raining", q represents "It is cold", and r represents "It is pleasant". This representation captures the logical connectives and relationships between the statements.

Signup and view all the flashcards

Pointer Manipulation

The code snippet demonstrates pointer manipulation in C. The output of invoking printxy(1,1) is (1,0), due to the modifications within the function.

Signup and view all the flashcards

Finding Constants R and S

The constants R and S can be determined by using the given information: f'(π/2) = √2 and ∫(f(x)dx from 0 to π = 2R/π. Applying the given conditions and performing differentiation and integration, we find that R = π/4 and S = 0. Therefore, the constants R and S are π/4 and 0, respectively.

Signup and view all the flashcards

RIP routing type

RIP (Routing Information Protocol) uses distance vector routing, which means that each router maintains a table of distances to other routers and the best route to reach them. Each router shares its routing table with its neighbors, and they update their own tables based on this information. This process creates a network map of the distances between routers, enabling packets to be efficiently routed to their destination.

Signup and view all the flashcards

RIP packet transmission

RIP (Routing Information Protocol) packets are sent using UDP (User Datagram Protocol), a connectionless protocol that does not guarantee delivery of packets. This means that RIP packets may be lost or arrive out of order, but since the protocol is designed to handle such situations, it's usually not a significant problem.

Signup and view all the flashcards

OSPF routing type

OSPF (Open Shortest Path First) is a link-state routing protocol. In contrast to distance vector routing, where routers share their entire routing tables, link-state routing involves each router broadcasting its local network information to all other routers in the network. Each router then builds a complete map of the network and its shortest paths to every destination, making OSPF a more efficient and scalable routing solution.

Signup and view all the flashcards

OSPF packet transmission

OSPF (Open Shortest Path First) packets are sent using TCP (Transmission Control Protocol), a connection-oriented protocol that ensures reliable delivery of packets. TCP guarantees that packets arrive in order and without loss, making it a suitable transport protocol for OSPF, which requires robust and reliable communication between routers.

Signup and view all the flashcards

CLR parser

A parser is a program that takes a sequence of tokens (like words) and converts them into a structured representation, such as a parse tree. This structured representation is easier for a computer program to understand and interpret. A Canonical LR (CLR) parser is the most powerful type of LR parser, meaning it can parse a broader range of grammatical constructs than other LR parsers.

Signup and view all the flashcards

SLR parser

An SLR (Simple LR) parser simplifies the implementation of a LR parser. It is less powerful than a CLR parser, meaning it cannot parse all grammatical constructs that a CLR parser can, specifically those with potential ambiguities.

Signup and view all the flashcards

Tag field in a cache

The tag field in a cache is used to identify the specific memory block stored in a cache line. The size of the tag field determines how many memory blocks can be uniquely identified. In this case, there are 512 cache lines and 2^19 (512) memory blocks, so 19 bits are needed to uniquely identify each memory block. The tag field is only part of the cache line, so the total size of the tag field is 18 bits (19 - 1).

Signup and view all the flashcards

Direct mapped cache

In a direct mapped cache, each memory block can only be stored in one specific cache line, which is determined by its address. Since the cache has 512 lines (2^9), the lower 9 bits of the memory address are used to determine the cache line. The remaining bits are used as the tag. The tag field is used to identify the specific memory block within the cache line and compare it to the memory address of the block being accessed.

Signup and view all the flashcards

Expression (d)

A Boolean expression in C programming that evaluates to true if and only if both q is equal to 0 and y is greater than 0.

Signup and view all the flashcards

What is the maximum order of a B+ tree?

A B+ tree is a self-balancing tree data structure that is commonly used in databases. Its order is determined by the block size, the search key size, and the block pointer size. The maximum order is calculated by dividing the block size by the sum of the search key size and the block pointer size.

Signup and view all the flashcards

SQL Query Output

The given SQL query retrieves records from the top_scorer table where the player's goal count is greater than all the goal counts from players in Spain and also greater than at least one goal count from players in Germany.

Signup and view all the flashcards

Transmission and Propagation Delay

Propagation delay is the time it takes for a signal to travel from one point to another. Transmission delay is the time it takes to send a message over a link. The formula for transmission delay is packet size / link bandwidth.

Signup and view all the flashcards

Preemptive Priority Scheduling

Preemptive priority scheduling is a scheduling algorithm where the process with the highest priority is always chosen to run next. In the case of a preemption, the currently running process is interrupted and swapped out, and the higher-priority process is swapped in.

Signup and view all the flashcards

C Program Output

The C code demonstrates the use of pre-increment (++m) and post-increment (m++) operators. The value of n is ultimately set to 0 due to the post-increment and the decrement operations.

Signup and view all the flashcards

Expression (a)

The && operator represents the logical AND operation. It evaluates to true if both operands are true. In this case, the expression (q == r) && (r == 0) holds true only if q and r are both equal to 0.

Signup and view all the flashcards

Expression (b)

The && operator works in conjunction with > to evaluate the conditions. In this case, the expression (x > 0) && (r == x) && (y > 0) will be true only if x, r, and y are all positive and r is equal to x.

Signup and view all the flashcards

Study Notes

  • No information provided to generate study notes. Please provide text or questions.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

DFA Quiz
0 questions

DFA Quiz

SuppleSard9813 avatar
SuppleSard9813
Deterministic Finite Automaton (DFA)
3 questions
Finite Automata Overview
10 questions
Non-deterministic Finite Automata (NFA)
24 questions
Use Quizgecko on...
Browser
Browser