UGC NET CS Practice Set 7

UGC NET JRF Computer Science · 2026 · with answers and explanations

questions
30
Total marks
60
Duration
180 minutes
Negative marking
No

Subjects: Computer Science

Question 1

Computer Science · 2 marks

In reinforcement learning, the agent selects actions to maximize:

  1. A.Immediate reward only
  2. B.Cumulative (discounted) reward over time
  3. C.The number of actions taken
  4. D.The training data accuracy

Correct answer: B

Explanation: In RL, the agent aims to maximize the expected cumulative (discounted) reward: R = Σ γ^t × r_t, where γ ∈ [0,1] is the discount factor. This balances immediate and future rewards. Maximizing only immediate reward is a greedy strategy that may not be globally optimal.

Question 2

Computer Science · 2 marks

The genetic algorithm is inspired by:

  1. A.Human brain structure
  2. B.Darwinian natural selection and genetics
  3. C.Statistical regression
  4. D.Fuzzy set theory

Correct answer: B

Explanation: Genetic algorithms are metaheuristic optimization algorithms inspired by the process of natural selection. They use operations analogous to biological evolution: selection (fitness-based), crossover (recombination), and mutation to evolve solutions over generations.

Question 3

Computer Science · 2 marks

In knowledge representation, a semantic network uses:

  1. A.If-then rules only
  2. B.Nodes for concepts and labeled edges for relationships
  3. C.First-order predicate logic exclusively
  4. D.Probabilistic distributions

Correct answer: B

Explanation: A semantic network represents knowledge as a graph where nodes represent concepts/objects and labeled directed edges represent relationships between them (is-a, has-a, part-of, etc.). It supports inheritance through is-a hierarchies.

Question 4

Computer Science · 2 marks

Which machine learning technique is used for classification tasks with labeled training data?

  1. A.K-means clustering
  2. B.Supervised learning
  3. C.Unsupervised learning
  4. D.Self-supervised learning

Correct answer: B

Explanation: Supervised learning uses labeled training data (input-output pairs) to learn a mapping function. Classification (discrete output) and regression (continuous output) are the two main supervised tasks. K-means is unsupervised (no labels).

Question 5

Computer Science · 2 marks

The alpha-beta pruning technique is used to optimize which search algorithm?

  1. A.A* search
  2. B.Minimax search
  3. C.Breadth-first search
  4. D.Hill climbing

Correct answer: B

Explanation: Alpha-beta pruning optimizes the minimax algorithm for game trees by eliminating branches that cannot affect the final decision. Alpha is the best value MAX can guarantee, beta is the best value MIN can guarantee. When alpha ≥ beta, the branch is pruned.

Question 6

Computer Science · 2 marks

Natural Language Processing (NLP) involves all of the following EXCEPT:

  1. A.Morphological analysis
  2. B.Syntactic parsing
  3. C.Semantic analysis
  4. D.Pixel-level image segmentation

Correct answer: D

Explanation: NLP involves morphological analysis (word structure), syntactic parsing (sentence structure), semantic analysis (meaning), pragmatics (context), and discourse. Pixel-level image segmentation is a computer vision task, not NLP.

Question 7

Computer Science · 2 marks

In the iterative deepening depth-first search (IDDFS), the time complexity is:

  1. A.Much worse than BFS due to repeated work
  2. B.O(b^d), asymptotically the same as BFS where b is branching factor and d is depth
  3. C.O(b^(d/2))
  4. D.O(d × b)

Correct answer: B

Explanation: IDDFS repeats DFS with increasing depth limits. Although nodes are revisited, the total work is dominated by the last iteration: (d+1)b^0 + d·b^1 + ... + 1·b^d = O(b^d), the same order as BFS. IDDFS combines BFS's completeness/optimality with DFS's linear space O(bd).

Question 8

Computer Science · 2 marks

In a decision tree classifier, which measure is commonly used to select the best attribute for splitting?

  1. A.Mean squared error
  2. B.Information gain (based on entropy)
  3. C.Euclidean distance
  4. D.Cosine similarity

Correct answer: B

Explanation: Decision trees (e.g., ID3, C4.5) use information gain (reduction in entropy after splitting) to select the attribute that best separates the classes. CART uses Gini impurity. MSE is for regression, Euclidean distance for clustering/KNN.

Question 9

Computer Science · 2 marks

Resolution in propositional logic involves:

  1. A.Converting formulas to conjunctive normal form (CNF) and applying the resolution rule
  2. B.Using forward chaining only
  3. C.Searching a game tree
  4. D.Training a neural network

Correct answer: A

Explanation: Resolution is a proof procedure that works on formulas in conjunctive normal form (CNF). The resolution rule: from (A ∨ B) and (¬B ∨ C), derive (A ∨ C). It is sound and complete for propositional logic. To prove a statement, negate it and show the resolvent leads to the empty clause.

Question 10

Computer Science · 2 marks

The backpropagation algorithm in neural networks computes gradients using:

  1. A.Forward pass only
  2. B.The chain rule of calculus applied backward from the output layer
  3. C.Genetic operators
  4. D.Random gradient estimation

Correct answer: B

Explanation: Backpropagation computes the gradient of the loss function with respect to each weight by applying the chain rule of calculus from the output layer backward through hidden layers. This enables efficient gradient computation for gradient descent optimization.

Question 11

Computer Science · 2 marks

The Naive Bayes classifier assumes that:

  1. A.Features are dependent on each other
  2. B.Features are conditionally independent given the class
  3. C.The class distribution is uniform
  4. D.Training data must be linearly separable

Correct answer: B

Explanation: The 'naive' assumption in Naive Bayes is that all features are conditionally independent given the class label: P(x₁,...,xₙ|C) = ∏P(xᵢ|C). Despite this strong (often unrealistic) assumption, Naive Bayes performs surprisingly well in practice for text classification and spam filtering.

Question 12

Computer Science · 2 marks

Constraint satisfaction problems (CSPs) in AI are solved using techniques such as:

  1. A.Gradient descent
  2. B.Backtracking with constraint propagation
  3. C.K-means clustering
  4. D.Naive Bayes classification

Correct answer: B

Explanation: CSPs are solved using backtracking search enhanced with constraint propagation techniques like arc consistency (AC-3), forward checking, and heuristics like MRV (Minimum Remaining Values) and LCV (Least Constraining Value). Examples include Sudoku, map coloring, and scheduling.

Question 13

Computer Science · 2 marks

Hill climbing search is a type of:

  1. A.Uninformed search
  2. B.Local search that can get stuck at local optima
  3. C.Complete and optimal search
  4. D.Adversarial search

Correct answer: B

Explanation: Hill climbing is a local search algorithm that iteratively moves to the neighbor with the highest value (for maximization). It is greedy, incomplete, and can get stuck at local optima, plateaus, and ridges. Variants include stochastic hill climbing and random restarts.

Question 14

Computer Science · 2 marks

Simulated annealing differs from hill climbing by:

  1. A.Never accepting worse solutions
  2. B.Accepting worse solutions with a probability that decreases over time
  3. C.Always finding the global optimum in polynomial time
  4. D.Using a population of solutions

Correct answer: B

Explanation: Simulated annealing allows moves to worse states with a probability P = e^(−ΔE/T) that decreases as the 'temperature' T is gradually reduced. This helps escape local optima. At T=0 it behaves like hill climbing. The 'population' approach describes genetic algorithms.

Question 15

Computer Science · 2 marks

The k-nearest neighbors (KNN) algorithm is an example of:

  1. A.Eager learning (builds a model during training)
  2. B.Lazy learning (defers computation until prediction time)
  3. C.Unsupervised learning
  4. D.Reinforcement learning

Correct answer: B

Explanation: KNN is a lazy (instance-based) learner — it stores all training data and delays computation until a query is made. At prediction time, it finds the k nearest training examples and votes (classification) or averages (regression). There is no explicit training phase.

Question 16

Computer Science · 2 marks

In the A* algorithm, the heuristic h(n) is said to be admissible if:

  1. A.h(n) always overestimates the true cost
  2. B.h(n) never overestimates the true cost to the goal
  3. C.h(n) = 0 for all nodes
  4. D.h(n) equals the exact cost to the goal

Correct answer: B

Explanation: A heuristic is admissible if it never overestimates the actual cost to reach the goal: 0 ≤ h(n) ≤ h*(n) for all n, where h*(n) is the true cost. Admissibility guarantees A* finds the optimal solution. h(n)=0 is admissible (reduces to Dijkstra's) but uninformative.

Question 17

Computer Science · 2 marks

Overfitting in machine learning occurs when:

  1. A.The model performs well on both training and test data
  2. B.The model performs well on training data but poorly on unseen test data
  3. C.The model performs poorly on training data
  4. D.The model has too few parameters

Correct answer: B

Explanation: Overfitting occurs when a model learns the training data too well, including noise and outliers, resulting in high accuracy on training data but poor generalization to unseen data. It is typically caused by excessive model complexity relative to the amount of training data.

Question 18

Computer Science · 2 marks

The Q-learning algorithm in reinforcement learning is a:

  1. A.Model-based method
  2. B.Model-free, off-policy temporal difference method
  3. C.Supervised learning method
  4. D.Unsupervised clustering method

Correct answer: B

Explanation: Q-learning is a model-free (no environment model needed), off-policy (learns optimal policy while following an exploratory policy) TD (temporal difference) method. It updates Q(s,a) ← Q(s,a) + α[r + γ max Q(s',a') − Q(s,a)]. It converges to optimal Q-values under sufficient exploration.

Question 19

Computer Science · 2 marks

Frames in knowledge representation are similar to:

  1. A.Production rules
  2. B.Objects in object-oriented programming (with slots as attributes)
  3. C.Neural network layers
  4. D.Bayesian probability tables

Correct answer: B

Explanation: Frames (Minsky, 1975) are structured knowledge representation units similar to objects in OOP. A frame has slots (attributes) with facets (constraints, default values, procedures). They support inheritance through is-a hierarchies, much like class inheritance in OOP.

Question 20

Computer Science · 2 marks

Given a relation R(A, B, C, D) with FDs: AB→C, C→D, D→A. The candidate keys are:

  1. A.{AB} only
  2. B.{AB, BC, BD}
  3. C.{A, B, C, D} (each is a candidate key)
  4. D.{ABCD}

Correct answer: B

Explanation: B does not appear on the right side of any FD, so B must be in every key. AB⁺ = {A,B,C,D} (AB→C→D) ✓. BC⁺ = {B,C,D,A} (C→D, D→A) ✓. BD⁺ = {B,D,A,C} (D→A, AB→C) ✓. All are minimal: B alone gives {B}, and A,C,D alone don't give all attributes. So the candidate keys are {AB, BC, BD}.

Question 21

Computer Science · 2 marks

In a B-tree of order 5 (maximum 4 keys per node), what is the maximum number of keys that can be stored in a B-tree of height 2 (root at height 0)?

  1. A.124
  2. B.100
  3. C.120
  4. D.625

Correct answer: A

Explanation: In a B-tree of order m=5, each node has at most 4 keys and 5 children. At height 0: 1 node with 4 keys. At height 1: 5 nodes × 4 keys = 20. At height 2: 25 nodes × 4 keys = 100. Total = 4 + 20 + 100 = 124.

Question 22

Computer Science · 2 marks

A relation R(A,B,C) with FDs {A→B, B→C} is in which highest normal form?

  1. A.1NF only
  2. B.2NF but not 3NF
  3. C.3NF
  4. D.BCNF

Correct answer: B

Explanation: Candidate key is A (A→B→C). A→B: left side is superkey, OK for 3NF/BCNF. B→C: B is not a superkey and C is not a prime attribute. This is a transitive dependency A→B→C, violating 3NF. There are no partial dependencies (single-attribute key), so it's in 2NF.

Question 23

Computer Science · 2 marks

What is the output of a postorder traversal of the BST formed by inserting 50, 30, 70, 20, 40, 60, 80 in that order?

  1. A.20, 40, 30, 60, 80, 70, 50
  2. B.20, 30, 40, 50, 60, 70, 80
  3. C.50, 30, 20, 40, 70, 60, 80
  4. D.80, 60, 70, 40, 20, 30, 50

Correct answer: A

Explanation: The BST has root 50, left subtree (30 with children 20, 40), right subtree (70 with children 60, 80). Postorder (Left, Right, Root): 20, 40, 30, 60, 80, 70, 50.

Question 24

Computer Science · 2 marks

In a context-free grammar, if a non-terminal A derives the empty string (A ⇒* ε), then A is called:

  1. A.Useless
  2. B.Nullable
  3. C.Reachable
  4. D.Ambiguous

Correct answer: B

Explanation: A non-terminal A is nullable if it can derive the empty string ε (A ⇒* ε). Identifying nullable non-terminals is important for converting a CFG to Chomsky Normal Form and for computing FIRST sets in parsing.

Question 25

Computer Science · 2 marks

In TCP congestion control, the slow start algorithm doubles the congestion window after each:

  1. A.Segment sent
  2. B.Round-trip time (RTT)
  3. C.Timeout
  4. D.Duplicate ACK

Correct answer: B

Explanation: In TCP slow start, the congestion window (cwnd) increases by 1 MSS for each ACK received. Since each RTT approximately doubles the number of outstanding segments acknowledged, cwnd effectively doubles each RTT — hence exponential growth despite the name 'slow start'.

Question 26

Computer Science · 2 marks

The token bucket algorithm for traffic shaping allows bursts of traffic up to:

  1. A.The bucket capacity
  2. B.The token arrival rate
  3. C.Unlimited size
  4. D.One packet at a time

Correct answer: A

Explanation: The token bucket algorithm allows traffic bursts up to the bucket capacity (the maximum number of tokens that can be stored). Tokens are added at a constant rate; each packet consumes tokens. When the bucket is full, accumulated tokens allow a burst of traffic.

Question 27

Computer Science · 2 marks

What is the minimum number of comparisons needed to find both the minimum and maximum of n elements?

  1. A.2n − 2
  2. B.⌈3n/2⌉ − 2
  3. C.n − 1
  4. D.n log n

Correct answer: B

Explanation: By processing elements in pairs and comparing with current min/max, we need 3 comparisons per pair (1 to compare the pair + 1 for min + 1 for max). For n elements, this gives ⌈3n/2⌉ − 2 comparisons, which is optimal. The naive approach needs 2(n−1) = 2n−2.

Question 28

Computer Science · 2 marks

In the subnet 172.16.32.0/20, the broadcast address is:

  1. A.172.16.47.255
  2. B.172.16.63.255
  3. C.172.16.32.255
  4. D.172.16.255.255

Correct answer: A

Explanation: /20 means the first 20 bits are the network portion. The host portion is 12 bits. 172.16.32.0 in binary: 10101100.00010000.0010|0000.00000000. Setting all host bits to 1: 10101100.00010000.0010|1111.11111111 = 172.16.47.255.

Question 29

Computer Science · 2 marks

In a relational database, the HAVING clause is used with:

  1. A.WHERE clause to filter rows
  2. B.GROUP BY clause to filter groups
  3. C.ORDER BY clause to sort results
  4. D.JOIN clause to combine tables

Correct answer: B

Explanation: HAVING filters groups created by GROUP BY, typically based on aggregate function results (e.g., HAVING COUNT(*) > 5). WHERE filters individual rows before grouping. HAVING is evaluated after GROUP BY, while WHERE is evaluated before it.

Question 30

Computer Science · 2 marks

The stable sorting algorithms among the following are:

  1. A.Quicksort and Heapsort
  2. B.Merge sort and Insertion sort
  3. C.Selection sort and Quicksort
  4. D.Heapsort and Shell sort

Correct answer: B

Explanation: A sorting algorithm is stable if it preserves the relative order of equal elements. Merge sort and insertion sort are stable. Quicksort, heapsort, and selection sort are not stable in their standard implementations.

View all papers — UGC NET JRF Computer Science

Practice this paper with a timer

Attempt it online, get scored instantly, and see which subjects are costing you marks.

Start practising free