Discrete Mathematics
Database Systems
SQL
Python Programming
Deterministic Finite Automata (DFA)
100

Which of the following is an example of a bijective function?

  • A) f(x) = x2 for all real numbers
  • B) f(x) = 3x + 1 for all integers
  • C) f(x) = sin(x) for all real numbers
  • D) f(x) = x3 - 4x for all real numbers

Correct: B, a bijective function is both one-to-one and onto

100

Which of the following is NOT a type of database model?

  • A) Relational
  • B) Hierarchical
  • C) Graph-based
  • D) Stack-based

Correct: D, stack-based is not a database model

100

Which SQL command is used to retrieve data from a database?

  • A) INSERT
  • B) UPDATE
  • C) SELECT
  • D) ALTER

Correct: C, SELECT is used to fetch data from a database

100

Which keyword is used to define a function in Python?

  • A) func
  • B) def
  • C) define
  • D) lambda

Correct: B, def is used to define functions in Python

100

Which of the following best describes a Deterministic Finite Automaton (DFA)?

  • A) A finite state machine with exactly one transition per symbol from each state
  • B) A machine that can have multiple transitions for the same symbol from a state
  • C) A machine that accepts only regular languages
  • D) Both A and C

 

Correct: D, DFAs have a unique transition per input symbol and accept regular languages

200

Which of the following sets is countably infinite?

  • A) The set of prime numbers
  • B) The set of real numbers between 0 and 1
  • C) The set of points on a plane
  • D) The set of irrational numbers

Correct: A, the set of prime numbers is countably infinite, while others are uncountable

200

What is the primary function of a database management system (DBMS)? 

  • A) To manage a computer’s operating system
  • B) To store and retrieve structured data efficiently
  • C) To control network traffic
  • D) To encrypt data for security

Correct: B, a DBMS organizes and manages structured data

200

Which SQL function is used to count the number of rows in a table?

  • A) COUNT()
  • B) SUM()
  • C) AVG()
  • D) TOTAL()

Correct: A, COUNT() returns the number of rows in a table

200

Which Python library is commonly used for working with databases?

  • A) NumPy
  • B) Pandas
  • C) SQLite3
  • D) Matplotlib

Correct: C, SQLite3 is used for working with databases in Python

200

How does a DFA differ from a Non-deterministic Finite Automaton (NFA)? 

  • A) A DFA allows multiple transitions for the same input symbol
  • B) An NFA can have ε-moves (epsilon transitions)
  • C) DFAs can recognize non-regular languages
  • D) NFAs require more states than DFAs

Correct: B, NFAs can have ε-transitions while DFAs cannot

300

What is the result of the logical expression: (A ∨ B) ∧ (¬ A)?

  • A) A
  • B) B
  • C) ¬ B
  • D) A ∧ B

Correct: B, if A is false, then only B determines the outcome

300

Which of the following is NOT a characteristic of a relational database?

  • A) Uses tables with rows and columns
  • B) Data is stored as key-value pairs
  • C) Uses primary and foreign keys
  • D) Supports ACID properties

Correct: B, key-value pairs are used in NoSQL databases

300

What does the following SQL statement do? 

SELECT name, age FROM students WHERE age > 20 ORDER BY age DESC;

  • A) Retrieves students aged 20 or younger, sorted in ascending order
  • B) Retrieves students aged over 20, sorted by age in descending order
  • C) Deletes students over 20 from the database
  • D) Returns all students without filtering

Correct: B, it retrieves students older than 20 and sorts them by age in descending order

300

Which of the following is a mutable data type in Python?

  • A) Tuple
  • B) String
  • C) List
  • D) Integer

Correct: C, lists are mutable while tuples and strings are immutable

300

What is the minimum number of states required in a DFA that accepts strings of length exactly 3 over the alphabet {0,1}?

  • A) 2
  • B) 3
  • C) 4
  • D) 5

Correct: C, since we need to track exactly three input symbols, we require four states: one for the initial state and three to count the length

400

In a graph, what is the minimum number of edges needed to connect all vertices without forming a cycle?

  • A) n
  • B) n−1
  • C) n+1
  • D) 2n−1

Correct: B, this forms a spanning tree with n−1 edges

400

What is the main purpose of an index in a database?

  • A) To store relationships between tables
  • B) To enforce constraints on a table
  • C) To speed up query performance
  • D) To normalize data

 

Correct: C, indexing improves search efficiency

400

What is the purpose of the SQL GROUP BY clause?

  • A) To filter rows based on a condition
  • B) To create a new table
  • C) To group rows that have the same values in specified columns
  • D) To delete records in bulk

Correct: C, GROUP BY is used for aggregating data

400

What will be the output of the following Python expression?

pythonCopyEdit

bool([])  
  • A) True
  • B) False
  • C) None
  • D) Error

Correct: B, an empty list evaluates to False in Boolean context

400

What happens if a DFA encounters an input symbol for which there is no transition from the current state?

  • A) It moves to a new state automatically
  • B) It rejects the input immediately
  • C) It continues processing but ignores the symbol
  • D) It enters an undefined state

Correct: B, DFAs must have a defined transition for every symbol, or the input is rejected

500

What is the number of edges in a complete graph Kn?

  • A) n
  • B) n2
  • C) n(n−1)/2
  • D) 2n

 

Correct: C, each vertex connects to every other vertex exactly once

500

What type of join retrieves only matching records from both tables?

  • A) INNER JOIN
  • B) LEFT JOIN
  • C) RIGHT JOIN
  • D) FULL OUTER JOIN

 

Correct: A, INNER JOIN returns only matching records from both tables

500

What will happen if you try to insert a NULL value into a column defined as PRIMARY KEY?

  • A) It will be accepted
  • B) The NULL value will be converted to zero
  • C) The query will fail
  • D) The database will create a new key automatically

Correct: C, a PRIMARY KEY cannot have NULL values

500

What will be the output of the following Python code?

print(type([]))

  • A) <class 'list'>
  • B) <class 'tuple'>
  • C) <class 'set'>
  • D) <class 'dict'>


Correct: A, [] is an empty list in Python

500

If a DFA has nnn states, what is the maximum number of transitions it can have for an alphabet of size Σ?

  • A) n+|Σ|
  • B) n2
  • C) n×|Σ|
  • D) n!

Correct: C, every state has exactly one transition per input symbol, so the maximum is n×|Σ|