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 marksIn reinforcement learning, the agent selects actions to maximize:
- A.Immediate reward only
- B.Cumulative (discounted) reward over time
- C.The number of actions taken
- 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 marksThe genetic algorithm is inspired by:
- A.Human brain structure
- B.Darwinian natural selection and genetics
- C.Statistical regression
- 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 marksIn knowledge representation, a semantic network uses:
- A.If-then rules only
- B.Nodes for concepts and labeled edges for relationships
- C.First-order predicate logic exclusively
- 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 marksWhich machine learning technique is used for classification tasks with labeled training data?
- A.K-means clustering
- B.Supervised learning
- C.Unsupervised learning
- 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 marksThe alpha-beta pruning technique is used to optimize which search algorithm?
- A.A* search
- B.Minimax search
- C.Breadth-first search
- 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 marksNatural Language Processing (NLP) involves all of the following EXCEPT:
- A.Morphological analysis
- B.Syntactic parsing
- C.Semantic analysis
- 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 marksIn the iterative deepening depth-first search (IDDFS), the time complexity is:
- A.Much worse than BFS due to repeated work
- B.O(b^d), asymptotically the same as BFS where b is branching factor and d is depth
- C.O(b^(d/2))
- 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 marksIn a decision tree classifier, which measure is commonly used to select the best attribute for splitting?
- A.Mean squared error
- B.Information gain (based on entropy)
- C.Euclidean distance
- 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 marksResolution in propositional logic involves:
- A.Converting formulas to conjunctive normal form (CNF) and applying the resolution rule
- B.Using forward chaining only
- C.Searching a game tree
- 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 marksThe backpropagation algorithm in neural networks computes gradients using:
- A.Forward pass only
- B.The chain rule of calculus applied backward from the output layer
- C.Genetic operators
- 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 marksThe Naive Bayes classifier assumes that:
- A.Features are dependent on each other
- B.Features are conditionally independent given the class
- C.The class distribution is uniform
- 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 marksConstraint satisfaction problems (CSPs) in AI are solved using techniques such as:
- A.Gradient descent
- B.Backtracking with constraint propagation
- C.K-means clustering
- 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 marksHill climbing search is a type of:
- A.Uninformed search
- B.Local search that can get stuck at local optima
- C.Complete and optimal search
- 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 marksSimulated annealing differs from hill climbing by:
- A.Never accepting worse solutions
- B.Accepting worse solutions with a probability that decreases over time
- C.Always finding the global optimum in polynomial time
- 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 marksThe k-nearest neighbors (KNN) algorithm is an example of:
- A.Eager learning (builds a model during training)
- B.Lazy learning (defers computation until prediction time)
- C.Unsupervised learning
- 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 marksIn the A* algorithm, the heuristic h(n) is said to be admissible if:
- A.h(n) always overestimates the true cost
- B.h(n) never overestimates the true cost to the goal
- C.h(n) = 0 for all nodes
- 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 marksOverfitting in machine learning occurs when:
- A.The model performs well on both training and test data
- B.The model performs well on training data but poorly on unseen test data
- C.The model performs poorly on training data
- 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 marksThe Q-learning algorithm in reinforcement learning is a:
- A.Model-based method
- B.Model-free, off-policy temporal difference method
- C.Supervised learning method
- 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 marksFrames in knowledge representation are similar to:
- A.Production rules
- B.Objects in object-oriented programming (with slots as attributes)
- C.Neural network layers
- 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 marksGiven a relation R(A, B, C, D) with FDs: AB→C, C→D, D→A. The candidate keys are:
- A.{AB} only
- B.{AB, BC, BD}
- C.{A, B, C, D} (each is a candidate key)
- 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 marksIn 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)?
- A.124
- B.100
- C.120
- 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 marksA relation R(A,B,C) with FDs {A→B, B→C} is in which highest normal form?
- A.1NF only
- B.2NF but not 3NF
- C.3NF
- 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 marksWhat is the output of a postorder traversal of the BST formed by inserting 50, 30, 70, 20, 40, 60, 80 in that order?
- A.20, 40, 30, 60, 80, 70, 50
- B.20, 30, 40, 50, 60, 70, 80
- C.50, 30, 20, 40, 70, 60, 80
- 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 marksIn a context-free grammar, if a non-terminal A derives the empty string (A ⇒* ε), then A is called:
- A.Useless
- B.Nullable
- C.Reachable
- 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 marksIn TCP congestion control, the slow start algorithm doubles the congestion window after each:
- A.Segment sent
- B.Round-trip time (RTT)
- C.Timeout
- 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 marksThe token bucket algorithm for traffic shaping allows bursts of traffic up to:
- A.The bucket capacity
- B.The token arrival rate
- C.Unlimited size
- 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 marksWhat is the minimum number of comparisons needed to find both the minimum and maximum of n elements?
- A.2n − 2
- B.⌈3n/2⌉ − 2
- C.n − 1
- 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 marksIn the subnet 172.16.32.0/20, the broadcast address is:
- A.172.16.47.255
- B.172.16.63.255
- C.172.16.32.255
- 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 marksIn a relational database, the HAVING clause is used with:
- A.WHERE clause to filter rows
- B.GROUP BY clause to filter groups
- C.ORDER BY clause to sort results
- 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 marksThe stable sorting algorithms among the following are:
- A.Quicksort and Heapsort
- B.Merge sort and Insertion sort
- C.Selection sort and Quicksort
- 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.