HPCL IS – Previous Year Questions 2022 | TVK-TheVictoryKey

Complete Answer Guide with Explanations · Computer Science & Information Technology

77 Questions Detailed Explanations Wrong Option Analysis
Theory of Computation & Formal Languages
Q1 DCFL / Automata Which of the following languages is NOT a Deterministic Context-Free Language (DCFL)?
  • A {wwR : w ∈ {a, b}*} — reverse palindromes
  • B {bnabn : n ≥ 1}
  • C {bnan : n ≥ 1}
  • D {anban : n ≥ 1}
✔ Correct Answer
A — {wwR} is NOT a DCFL
Explanation

To recognise {wwR}, a machine must first push all characters of w onto a stack, then pop them while matching with wR. But the midpoint of the string is unknown — the machine cannot deterministically decide when w ends and wR begins. This inherent non-determinism means it can only be accepted by an NPDA, NOT a DPDA. Hence it is a CFL but NOT a DCFL.


Why Others Are DCFLs
  • B & D — {bnabn} and {anban}: The middle separator (a or b) is a unique sentinel. A DPDA pushes the first block, sees the separator, then pops while matching the second block — completely deterministic.
  • C — {bnan}: Classic DCFL. Push b's, then pop one per a. No ambiguity.

Extra for Exam

DCFL ⊂ CFL. Every DCFL is a CFL, but not every CFL is a DCFL. Key non-DCFLs to remember: {wwR}, {ww}, and languages that require "guessing" a midpoint. DCFLs are closed under complementation but NOT under union or intersection.

Q13 Regular Grammar Which defines a regular grammar for the language (ab)*a?
  • A G = ({S}, {a, b}, {S → abS | a}, S)
  • B G = ({S}, {a, b}, {S → aS | b}, S)
  • C G = ({S}, {a, b}, {S → abS | b}, S)
  • D G = ({S}, {a, b}, {S → bS | a}, S)
✔ Correct Answer
A — S → abS | a
Explanation

The language (ab)*a generates: a, aba, ababa, abababa, … Starting from S:

S → a (produces "a" directly ✓)
S → abS → aba (produces "aba" ✓)
S → abS → ababS → ababa ✓

This correctly matches (ab)*a. Option A is also a right-linear grammar (non-terminal always at right end), making it a valid regular grammar.


Why Others Are Wrong
  • B — S → aS | b: Generates strings of a's ending in b (e.g., aab). Completely wrong language.
  • C — S → abS | b: Terminal rule is b alone, so strings end in b. Not matching (ab)*a.
  • D — S → bS | a: Generates b*a — strings of b's followed by a. Wrong language.
Q14 Regular Expressions Which of the following is NOT a primitive regular expression?
  • A a
  • B λ (empty string)
  • C b
  • D (a + b)*
✔ Correct Answer
D — (a + b)* is NOT a primitive regular expression
Explanation

Primitive (atomic) regular expressions are defined as: ∅ (empty set), λ (empty string), and any single symbol from the alphabet (a, b, c, …). These are the base cases. (a + b)* is a compound expression built using union (+) and Kleene star (*) — it is NOT primitive.

Key Rule

Any regular expression that uses an operator (+ union, · concatenation, * Kleene star) is NOT primitive. It is a composed/derived expression.

Q15 CFL Properties Which statement is correct regarding Context-Free Languages (CFL)?
  • A Every CFL is regular.
  • B Every regular language is context-free.
  • C CFLs cannot be recognised by pushdown automata.
  • D CFLs are closed under intersection.
✔ Correct Answer
B — Every regular language is context-free
Explanation

The hierarchy: Regular ⊂ CFL ⊂ CSL ⊂ Recursively Enumerable. Since regular languages are a strict subset of CFLs, every regular language is also context-free.


Why Others Are Wrong
  • A: {anbn} is CFL but NOT regular (proved by Pumping Lemma). So not every CFL is regular.
  • C: Completely false — CFLs are EXACTLY the languages recognised by Pushdown Automata (PDA).
  • D: CFLs are NOT closed under intersection. Example: {anbncm} ∩ {ambncn} = {anbncn} which is NOT a CFL.
Closure Properties of CFL
  • Closed under: Union, Concatenation, Kleene star, Homomorphism
  • NOT closed under: Intersection, Complementation
Q17 Regular Grammar Identify the regular grammar from the options below.
  • A S → aS | A, A → bAc | bc
  • B S → aS | a, A → bA | b
  • C S → aS | A, A → abAc | bc
  • D S → aS | A, A → bAc | abc
✔ Correct Answer
B
Explanation

A regular grammar requires all productions to be either right-linear (A → aB or A → a) or left-linear (A → Ba or A → a). Option B satisfies this: S → aS (right-linear), S → a (terminal), A → bA (right-linear), A → b (terminal). All valid.


Why Others Are Wrong
  • A — A → bAc: Non-terminal A is in the MIDDLE, not at the right end. This makes it context-free, not regular.
  • C — A → abAc: Multiple terminals before and after the non-terminal — not regular.
  • D — A → bAc and A → abc: Same issue — non-terminal in the middle.
Q27 DFA Design DFA for L = {w : |w| mod 3 = 0}, Q = {1,2,3}, q₀ = 1, F = {1}. Which δ is correct?
  • A δ(1,a)=1, δ(1,b)=1, δ(2,a)=2, ... (self-loops)
  • B δ(1,a)=2, δ(1,b)=2, δ(2,a)=3, δ(2,b)=3, δ(3,a)=1, δ(3,b)=1
  • C δ(1,a)=2, δ(1,b)=1, δ(2,a)=3, ...
  • D δ(1,a)=3, δ(1,b)=3, ...
✔ Correct Answer
B
Explanation

The DFA tracks |w| mod 3. State 1 = 0 mod 3 (start & accept), State 2 = 1 mod 3, State 3 = 2 mod 3. On every character read, we move to the next state cyclically:

State 1 → (any symbol) → State 2
State 2 → (any symbol) → State 3
State 3 → (any symbol) → State 1 (accepted!)

Strings accepted: ε (length 0), aab (length 3), aaaaaa (length 6), etc.


Why Others Are Wrong
  • A: All states loop to themselves — every state accepts only if it's a final state. This DFA would accept ALL strings (or none), not just multiples of 3.
  • C: δ(1,b)=1 means 'b' doesn't advance the counter — string "b" would be accepted at length 1 incorrectly.
  • D: Jumps directly from state 1 to state 3 on first symbol — skips the "length 1" tracking entirely.
Q29 Regular Expressions Which RE represents L = {ε, c, ab, cc, cab, abc, abab, ccc, …}?
  • A c* · (a + b)
  • B (b + (a · c))*
  • C (c + (a · b))*
  • D (a + (b · c))*
✔ Correct Answer
C — (c + ab)*
Explanation

Pattern: the language consists of arbitrary arrangements of the "tokens" c and ab. So strings are built by choosing 'c' or 'ab' zero or more times:

ε = zero tokens ✓
c = one 'c' token ✓
ab = one 'ab' token ✓
cc = 'c' + 'c' ✓
cab = 'c' + 'ab' ✓
abc = 'ab' + 'c' ✓
abab = 'ab' + 'ab' ✓

Why Others Are Wrong
  • A — c*(a+b): Must end with a or b and cannot produce ε or cc.
  • B — (b + ac)*: Tokens are b and ac — produces strings like b, ac, bac, etc. Not matching.
  • D — (a + bc)*: Tokens are a and bc — produces a, bc, abc (=a+bc), etc. Generates "abc" differently and misses "ab".
Q41 Context-Free Grammar Which string is NOT generated by G = ({S,A,B}, {a,b}, {S→aaB, B→Aa, A→bBb|λ}, S)?
  • A aababa
  • B aabbabba
  • C aabbbabababa
  • D aabbababa
✔ Correct Answer
B — aabbabba (given in exam)
Verification of Valid Strings

All strings start with S → aaB. Then B → Aa → (bBb)a → … The grammar naturally generates strings of the form aa + (nested bBb expansions) + a chain. aabbabba cannot be derived because the structure of b-groups and a-sequences doesn't match the grammar's production pattern.

Exam Tip

For CFG derivation questions, always start from S and apply productions systematically. Track what each derivation step produces and verify character by character.

Q44 Pushdown Automata In NPDA, the transition function δ takes the current state, input symbol, and what else?
  • A Set of final states F
  • B Initial state q₀
  • C Current output symbol
  • D Current symbol on top of the stack
✔ Correct Answer
D — Top of Stack symbol
Explanation
NPDA δ: Q × (Σ ∪ {ε}) × Γ → 2^(Q × Γ*)

Inputs: (current state, input symbol, stack top symbol)
Output: set of (new state, stack string to push)

The stack top symbol is crucial — the PDA's behaviour depends on what's currently on top of the stack, enabling it to match nested structures like parentheses or {anbn}.

Q49 Regular Expressions Which language is represented by r = (bb)*(aa)*a?
  • A Odd b's followed by odd a's
  • B Even b's followed by odd a's
  • C Odd b's followed by even a's
  • D Even b's followed by even a's
✔ Correct Answer
B — Even number of b's followed by odd number of a's
Explanation
(bb)* → pairs of b's: ε, bb, bbbb, … → 0, 2, 4, … b's (EVEN)
(aa)*a → pairs of a's then one a: a, aaa, aaaaa, … → 1, 3, 5, … a's (ODD)

Examples: "a" (0 b's, 1 a), "bba" (2 b's, 1 a), "bbaaa" (2 b's, 3 a's) — all match.

Q56 Turing Machine For TM M = (Q, Σ, Γ, δ, q₀, b, F): (i) Γ is tape symbols. (ii) b ∈ Σ. Which is true?
  • A Only (ii)
  • B Neither
  • C Both
  • D Only (i)
✔ Correct Answer
D — Only (i) is true
Explanation

(i) TRUE: Γ is indeed the finite set of tape symbols, and Σ ⊆ Γ.

(ii) FALSE: The blank symbol b is in Γ (tape alphabet) but b ∉ Σ (input alphabet). This is a critical distinction — the blank b separates the input from unused tape cells, and it is never part of the input string itself.

Σ ⊂ Γ, and b ∈ Γ but b ∉ Σ
Q72 Regular Expressions For Σ = {a, b}, what language does the regex 'a + b' generate?
  • A {a, b}*
  • B {aa, ab, bb}
  • C {a, b}
  • D {λ, a, b}
✔ Correct Answer
C — {a, b}
Explanation

In regex notation, '+' (or '|') means union/OR. So 'a + b' means "either a or b" — exactly the set {a, b}. Do not confuse '+' in regex with arithmetic addition or Kleene plus.


Why Others Are Wrong
  • A — {a,b}*: This would be (a+b)* — all strings including ε.
  • D — {λ, a, b}: That would be (a+b+λ) or (a+b)? — includes empty string.
Q73 Regular Expressions Which of the following is NOT a valid regular expression over Σ = {a, b}?
  • A a
  • B b
  • C (a + b)* · (a + b)
  • D {a, b}
✔ Correct Answer
D — {a, b} is NOT a valid regular expression
Explanation

{a, b} is set notation, not regex notation. A regular expression uses symbols, operators (+, ·, *), and parentheses. Curly-brace set notation is from set theory / formal language description — it is not a valid regular expression syntax.

Q77 DFA Definition Which statement is INCORRECT about DFA M = (Q, Σ, δ, q₀, F)?
  • A The set of final states F may be empty.
  • B δ is defined for all states in Q and symbols in Σ.
  • C The initial state q₀ must be a member of Q.
  • D The set of states Q must be non-empty.
✔ Correct Answer (INCORRECT statement)
A — though debated (see explanation)
Explanation

Statements B, C, D are all definitionally true for any DFA. Statement A says "F may be empty" — formally, F ⊆ Q and F = ∅ is allowed (DFA accepts nothing). However, many textbooks and exam setters consider a DFA with empty F as degenerate/invalid, making A "incorrect" from that perspective. This is the intended answer in the exam.


Key DFA Facts
  • δ: Q × Σ → Q is a total function (defined for every state-symbol pair) — this distinguishes DFA from NFA.
  • Q must be non-empty (at least q₀ ∈ Q).
  • q₀ ∈ Q by definition.
Operating Systems
Q2 OS – Memory Where is the ready queue typically maintained in a modern OS?
  • A Secondary memory
  • B Tertiary memory
  • C Virtual memory
  • D Primary memory (RAM)
✔ Correct Answer
D — Primary Memory (RAM)
Explanation

The ready queue contains the Process Control Blocks (PCBs) of all processes that are loaded in memory and waiting for CPU time. It must be in RAM for the CPU scheduler to access it rapidly. Secondary memory is too slow; tertiary is even slower.

OS Queues Summary
  • Job queue: All processes in system (may be on disk)
  • Ready queue: In RAM — ready to execute
  • Device queues: In RAM — waiting for I/O
Q20 OS – System Calls Which provides OS services to user programs via an API?
  • A Demand paging
  • B Segmentation
  • C Virtual memory
  • D System call
✔ Correct Answer
D — System call
Explanation

A system call is the programmatic interface between a user-space application and OS kernel services. They are exposed as an API (e.g., POSIX in Unix). Examples: read(), write(), fork(), open(). When called, the CPU switches from user mode to kernel mode.


Why Others Are Wrong
  • Demand paging / Virtual memory / Segmentation are memory management techniques, not API mechanisms.
Q30 OS – Scheduling The 'job scheduler' in an OS is also known as the:
  • A Dispatcher
  • B Short-term scheduler
  • C Long-term scheduler
  • D Medium-term scheduler
✔ Correct Answer
C — Long-term scheduler
Explanation

The long-term (job) scheduler selects which jobs from the job pool (disk) to bring into the ready queue (RAM). It controls the degree of multiprogramming. It is invoked infrequently.


All 3 Schedulers
  • Long-term (Job) scheduler: Disk → Ready queue. Controls multiprogramming degree. Slow.
  • Short-term (CPU) scheduler: Ready queue → CPU. Very fast. Runs every few milliseconds.
  • Medium-term scheduler: Handles swapping — moves processes between RAM and disk to free memory.
  • Dispatcher: Performs the actual context switch — loads registers, switches to user mode.
Q33 OS – Threads (i) Multiple threads can exist in one process. (ii) A thread is a lightweight process. Which is true?
  • A Neither
  • B Only (i)
  • C Both (i) and (ii)
  • D Only (ii)
✔ Correct Answer
C — Both are true
Explanation

(i) TRUE: A process is a container for threads. A single process can have many threads (e.g., a browser has separate threads for UI, network, rendering).

(ii) TRUE: Threads are called "lightweight processes" because they share the parent process's memory space, code, and resources. Creating/switching threads is cheaper than full process creation.

Q34 OS – CPU Scheduling Calculate Avg TAT and Avg WT for P1(AT=0, BT=2), P2(AT=3, BT=1), P3(AT=5, BT=6) using FCFS.
  • A Avg TAT: 3, Avg WT: 3
  • B Avg TAT: 3, Avg WT: 0
✔ Correct Answer
B — Avg TAT: 3, Avg WT: 0
Calculation (FCFS)
P1: Arrives 0, BT=2. Start=0, End=2. TAT=2-0=2. WT=Start-AT=0-0=0
P2: Arrives 3, BT=1. CPU idle 2→3. Start=3, End=4. TAT=4-3=1. WT=3-3=0
P3: Arrives 5, BT=6. CPU idle 4→5. Start=5, End=11. TAT=11-5=6. WT=5-5=0

Avg TAT = (2+1+6)/3 = 9/3 = 3
Avg WT = (0+0+0)/3 = 0
Key Formulas
  • TAT = Completion Time − Arrival Time
  • WT = TAT − Burst Time
  • Response Time = Start Time − Arrival Time
Q46 OS – Memory Hierarchy Which statement about computer memory is INCORRECT?
  • A Main memory communicates with auxiliary memory through an I/O processor.
  • B Programs currently needed are transferred from main memory to auxiliary memory.
  • C Speed of main memory > auxiliary memory.
  • D Main memory communicates directly with CPU.
✔ Correct Answer (INCORRECT statement)
B — Direction is REVERSED
Explanation

The correct direction is: programs needed by the CPU are transferred FROM auxiliary memory (HDD/SSD) TO main memory (RAM), not the other way around. When a program is needed, the OS loads it into RAM for execution. Transferring to auxiliary memory is what happens during swapping (moving OUT of RAM).

Q50 OS – Kernel Access When software requires access to the OS kernel, it uses a:
  • A System call
  • B Virtual memory
  • C CUI
  • D GUI
✔ Correct Answer
A — System call
Explanation

A system call is the only safe, controlled mechanism for user-space programs to request kernel services. It triggers a CPU trap/interrupt to switch from user mode to kernel mode, execute the requested service, and return. CUI/GUI are user interfaces, not kernel access mechanisms.

Q58 OS – Memory Management Full form of TLB in OS memory management?
  • A Trivial Lookaside Buffer
  • B Translation Lookaside Buffer
  • C Trivial Lookaside Block
  • D Translation Lookaside Block
✔ Correct Answer
B — Translation Lookaside Buffer
Explanation

TLB is a hardware cache that stores recent page-number → frame-number mappings. Without TLB, every memory access requires TWO memory lookups: one for the page table + one for the actual data. With TLB, if the mapping is cached (TLB hit), only one lookup is needed. TLB hit ratio is typically 95–99%.

Effective Access Time = h × (TLB + Memory) + (1-h) × (TLB + 2×Memory)
where h = TLB hit ratio
Computer Networks
Q6 Networks – Topology Maximum links for a mesh topology with 10 nodes?
  • A 55
  • B 54
  • C 45
  • D 10
✔ Correct Answer
C — 45 links
Formula
Max links in full mesh = n(n-1)/2
= 10 × 9 / 2 = 90/2 = 45

This is also the number of edges in a complete graph K₁₀. Each of 10 nodes connects to 9 others, but each link is shared by 2 nodes.


Why A (55) Is Wrong

55 = 10×11/2 = C(11,2). That's the formula with n=11, not n=10. A common trap.

Q9 Networks – TCP/IP Which TCP/IP layer ensures packets arrive in sequence and error-free using ACKs?
  • A Transport layer
  • B Internet layer
  • C Physical layer
  • D Application layer
✔ Correct Answer
A — Transport Layer (TCP)
Explanation

TCP (Transmission Control Protocol) at the Transport layer provides: reliable delivery (ACKs + retransmissions), sequencing (sequence numbers), flow control (sliding window), and congestion control.


Why Others Are Wrong
  • Internet layer: IP is best-effort, connectionless — no guarantee of delivery or order.
  • Physical layer: Deals with bits on wire — no error correction at this level.
  • Application layer: Deals with application protocols (HTTP, SMTP) — not sequencing.
Q28 Networks – Protocols Which protocol allows two hosts to communicate character-by-character or line-by-line?
  • A TELNET
  • B FTP
  • C TFTP
  • D Anonymous FTP
✔ Correct Answer
A — TELNET
Explanation

TELNET (TELecommunication NETwork) provides a virtual terminal protocol — it allows a user to log into a remote host and interact character-by-character or line-by-line. It uses port 23. Note: TELNET transmits data in plaintext — SSH is its secure replacement.


Why Others Are Wrong
  • FTP: File Transfer Protocol — for transferring files, not interactive terminal sessions.
  • TFTP: Trivial FTP — simplified file transfer, no authentication.
  • Anonymous FTP: FTP variant allowing login without credentials.
Q31 Networks – Subnetting Subnet mask 255.255.240.0. Maximum hosts?
  • A 1024
  • B 2048
  • C 4094
  • D 4096
✔ Correct Answer
C — 4094
Calculation
255.255.240.0 = 11111111.11111111.11110000.00000000
Host bits = 4 (3rd octet) + 8 (4th octet) = 12 bits
Total addresses = 2¹² = 4096
Usable hosts = 4096 - 2 = 4094
(subtract network address and broadcast address)
Why D (4096) Is Wrong

4096 is the total number of addresses. But the network address (all host bits = 0) and broadcast address (all host bits = 1) cannot be assigned to hosts. So usable = 4096 − 2 = 4094.

Q39 Networks – IP Addressing Dotted decimal for hex IP address C22F1582?
  • A 194.74.21.130
  • B 194.47.21.130
  • C 194.47.21.103
  • D 149.47.12.130
✔ Correct Answer
B — 194.47.21.130
Hex → Decimal Conversion
C2 → 12×16 + 2 = 192+2 = 194
2F → 2×16 + 15 = 32+15 = 47
15 → 1×16 + 5 = 16+5 = 21
82 → 8×16 + 2 = 128+2 = 130

Result: 194.47.21.130
Q54 Networks – ICMP ICMP detects and reports: (i) Dropped packets, (ii) Connectivity failure?
  • A Neither
  • B Only (i)
  • C Both (i) and (ii)
  • D Only (ii)
✔ Correct Answer
C — Both
Explanation

ICMP (Internet Control Message Protocol) is a network-layer protocol for error reporting and diagnostics. It reports both dropped packets (e.g., "Destination Unreachable") and connectivity failures (e.g., "Echo Request/Reply" used by ping). It does NOT deliver data — it only carries control messages.

Common ICMP Messages
  • Type 0/8: Echo Reply/Request (ping)
  • Type 3: Destination Unreachable (dropped packet)
  • Type 11: Time Exceeded (TTL expired — used by traceroute)
Q55 Networks – Routing Routing protocols for TCP/IP: (i) RIP, (ii) EGP?
  • A Both (i) and (ii)
  • B Only (ii)
  • C Only (i)
  • D Neither
✔ Correct Answer
A — Both RIP and EGP
Explanation

RIP (Routing Information Protocol): Interior Gateway Protocol (IGP) using Distance Vector algorithm. Metric = hop count (max 15). Simple but slow convergence.

EGP (Exterior Gateway Protocol): Used for inter-domain routing between autonomous systems. Largely replaced by BGP today, but is still a valid routing protocol.

Q67 Networks – Protocols RARP maps which address to which?
  • A Ethernet (48-bit) → IPv4 (32-bit)
  • B IPv4 (32-bit) → Ethernet (48-bit)
✔ Correct Answer
A — MAC → IP
Explanation

RARP (Reverse ARP) allows a device that knows only its MAC address to discover its IP address from a RARP server. It is the reverse of ARP (which maps IP → MAC).

ARP: IP address → MAC address
RARP: MAC address → IP address

RARP is largely obsolete, replaced by DHCP (Dynamic Host Configuration Protocol).

Database Management Systems
Q7 DBMS – Constraints Which constraint specifies that a primary key cannot contain a NULL value?
  • A Foreign key constraint
  • B Domain constraint
  • C Key constraint
  • D Entity integrity constraint
✔ Correct Answer
D — Entity Integrity Constraint
Explanation

The Entity Integrity Constraint states: "No primary key attribute can be NULL." This ensures every entity (row) in a relation can be uniquely identified. A primary key with NULL would mean an entity that cannot be distinguished from others.


Why Others Are Wrong
  • Key constraint: States that primary key must be unique (no two rows same PK). Different from the NULL rule.
  • Domain constraint: Restricts values an attribute can take (e.g., age must be positive integer).
  • Foreign key constraint (Referential integrity): A foreign key value must match a PK in the referenced table or be NULL.
Q18 DBMS – ER Model In an ER diagram, what does a double-lined diamond represent?
  • A Weak Entity
  • B Derived Attribute
  • C Identifying Owner
  • D Identifying Relationship
✔ Correct Answer
D — Identifying Relationship
Explanation

An identifying relationship (double diamond) connects a weak entity to its identifying (owner) entity. Without this relationship, the weak entity cannot be uniquely identified.


ER Diagram Notation Summary
  • Rectangle → Entity
  • Double rectangle → Weak entity
  • Diamond → Relationship
  • Double diamond → Identifying relationship
  • Ellipse → Attribute
  • Dashed ellipse → Derived attribute
  • Double ellipse → Multivalued attribute
Q21 DBMS – SQL Which SQL clauses are optional: (i) SELECT, (ii) FROM, (iii) WHERE?
  • A Only (ii)
  • B Only (i) and (ii)
  • C Only (iii) WHERE
  • D Only (i) and (iii)
✔ Correct Answer
C — Only WHERE is optional
Explanation

SELECT and FROM are mandatory in a standard SQL query — they define what to retrieve and from where. WHERE is optional — omitting it retrieves all rows. A minimal valid query: SELECT * FROM Employee;

Q24 DBMS – Relational Algebra σ_Age < 20(Employee) returns which tuples?
  • A None
  • B All tuples
  • C Age ≥ 20
  • D Age < 20
✔ Correct Answer
D — Tuples where Age < 20
Explanation

The selection (σ) operator in relational algebra filters rows based on a predicate. σ_condition(R) returns only the tuples from R that satisfy the condition. It is equivalent to SQL's WHERE clause: SELECT * FROM Employee WHERE Age < 20;

Q68 DBMS – Normalisation R1(A,B,C) — atomic attributes, A is the only candidate key. Which is NOT necessarily true?
  • A R1 may or may not be in BCNF.
  • B R1 is in 1NF.
  • C R1 is definitely in 3NF.
  • D R1 is in 2NF.
✔ Correct Answer (NOT necessarily true)
C — "Definitely in 3NF" is NOT guaranteed
Explanation

1NF ✓: Given — all attributes atomic and single-valued.

2NF ✓: Since A is a single-attribute key, there can be no partial dependency (partial dependency requires a composite key). So 2NF is always satisfied.

3NF — NOT guaranteed: If B → C exists and B is not a candidate key, there is a transitive dependency (A→B→C), violating 3NF. We don't know the FDs, so 3NF is not necessarily true.

BCNF — may or may not hold (same reasoning). This statement is trivially true as a "maybe" claim.

Normalisation Quick Reference
  • 1NF: Atomic values, no repeating groups
  • 2NF: 1NF + no partial dependencies on PK
  • 3NF: 2NF + no transitive dependencies
  • BCNF: Every determinant is a candidate key
Q70 DBMS – Relational Algebra Which relational algebra operator is NOT commutative?
  • A Union
  • B Intersection
  • C Division
  • D Natural Join
✔ Correct Answer
C — Division is NOT commutative
Explanation

Division R ÷ S ≠ S ÷ R in general — the schemas must be compatible in a specific direction. Union (A∪B=B∪A), Intersection (A∩B=B∩A), and Natural Join (R⋈S=S⋈R) are all commutative — order doesn't affect the result.

Q71 DBMS – SQL Commands Which is NOT a Transaction Control Language (TCL) command?
  • A SAVEPOINT
  • B ROLLBACK
  • C GRANT
  • D COMMIT
✔ Correct Answer
C — GRANT is NOT TCL
Explanation

GRANT is a DCL (Data Control Language) command — it gives users permissions on database objects.

SQL Command Categories
  • DDL: CREATE, ALTER, DROP, TRUNCATE
  • DML: SELECT, INSERT, UPDATE, DELETE
  • TCL: COMMIT, ROLLBACK, SAVEPOINT
  • DCL: GRANT, REVOKE
Algorithms & Data Structures
Q4 Algorithms – DP Which statement accurately describes Matrix Chain Multiplication?
  • A DP approach: Θ(n²)
  • B DP approach: Θ(n³)
  • C Brute force: Θ(n²)
  • D Brute force: Θ(n log n)
✔ Correct Answer
B — DP is Θ(n³)
Explanation

Matrix Chain Multiplication asks for the optimal parenthesisation of n matrices to minimise scalar multiplications. The DP solution fills an n×n table with O(n) work per cell → Θ(n³). The brute force approach (trying all parenthesisations) is exponential — Ω(2n). Neither n² nor n log n describes it.

Q16 Algorithms – Greedy Which problem CANNOT be solved optimally by a Greedy Algorithm?
  • A Dijkstra's (Single Source Shortest Path)
  • B Minimum Spanning Tree
  • C 0–1 Knapsack Problem
  • D Fractional Knapsack
✔ Correct Answer
C — 0–1 Knapsack
Explanation

In the 0-1 Knapsack, each item must be taken wholly or left entirely. A greedy choice (always pick highest value/weight ratio) may leave gaps that smaller items could fill more optimally. This requires Dynamic Programming for optimal solution.

Fractional Knapsack CAN be solved greedily — you can take fractions, so always picking highest ratio is always optimal.

Greedy vs DP Problems
  • Greedy works: Fractional Knapsack, MST (Prim/Kruskal), Dijkstra's, Huffman Coding, Activity Selection
  • DP needed: 0-1 Knapsack, Matrix Chain Multiplication, Longest Common Subsequence, Floyd-Warshall
Q26 DS – Graph Traversal Which data structure is primarily used in DFS?
  • A Max Heap
  • B Queue
  • C AVL Tree
  • D Stack
✔ Correct Answer
D — Stack
Explanation

DFS explores as deep as possible before backtracking — this LIFO (Last-In-First-Out) behaviour matches a stack. In recursive DFS, the call stack acts implicitly. Iterative DFS uses an explicit stack.

BFS uses Queue

BFS (Breadth-First Search) uses a Queue (FIFO) to explore level-by-level. The Queue option is for BFS, not DFS — a common trap.

Q32 Algorithms – Sorting Which statement is INCORRECT about Merge Sort?
  • A merge() time complexity is O(log n)
  • B It is stable.
  • C It uses divide and conquer.
  • D Worst case: O(n log n)
✔ Correct Answer (INCORRECT statement)
A — merge() is O(n), NOT O(log n)
Explanation

The merge() function merges two sorted subarrays of total size n by comparing elements one by one — it takes O(n) time. The O(log n) factor comes from the number of recursive levels (log n levels), and at each level, O(n) total work is done → overall O(n log n).

Total: O(n log n) = O(n) work per level × O(log n) levels
Merge Sort Key Facts
  • Stable? Yes — equal elements maintain relative order
  • In-place? No — needs O(n) extra space
  • Best/Avg/Worst: All O(n log n)
  • Best for linked lists (no extra space needed)
Q36 Algorithms – DP Which statement is INCORRECT about Matrix Chain Multiplication?
  • A Can be optimally solved using greedy.
  • B Can be solved using DP.
  • C Follows divide and conquer strategy.
  • D DP solution is bottom-up.
✔ Correct Answer (INCORRECT statement)
A — Greedy does NOT give optimal solution
Explanation

MCM cannot be solved optimally by greedy because the optimal parenthesisation depends on the combination of all dimensions — a local greedy choice may lead to globally suboptimal results. This is a classic DP problem. B, C, D are all correct facts.

Q42 Algorithms – Greedy Which greedy algorithm uses a disjoint set (Union-Find) data structure?
  • A Huffman coding
  • B Dijkstra's algorithm
  • C Prim's algorithm
  • D Kruskal's algorithm
✔ Correct Answer
D — Kruskal's algorithm
Explanation

Kruskal's MST algorithm sorts edges by weight and greedily adds the cheapest edge that does NOT form a cycle. To efficiently detect cycles, it uses a Disjoint Set (Union-Find) data structure. Time complexity with union by rank + path compression: O(E log E).


Other Algorithms
  • Prim's: MST using priority queue / min-heap. Grows tree one vertex at a time.
  • Dijkstra's: SSSP using priority queue/min-heap, not disjoint sets.
  • Huffman: Uses a min-heap/priority queue to build optimal prefix codes.
Q47 DS – Trees / BST Which BST traversal produces a non-decreasing sequence?
  • A Preorder
  • B Level order
  • C Postorder
  • D Inorder
✔ Correct Answer
D — Inorder (Left → Root → Right)
Explanation

By BST property: all left subtree keys < root < all right subtree keys. Inorder visits Left → Root → Right, which naturally outputs keys in sorted (non-decreasing) order. This is a fundamental BST property used for sorting.

Traversal Summary
  • Inorder (L-R-T): Sorted output for BST
  • Preorder (R-L-T): Used for copying trees, prefix expressions
  • Postorder (L-T-R): Used for deleting trees, postfix expressions
  • Level order (BFS): Level-by-level, uses queue
Q52 DS – BST How many distinct BSTs can be formed with keys {1, 2, 3}?
  • A 3
  • B 4
  • C 5
  • D 1
✔ Correct Answer
C — 5
Catalan Number
Number of BSTs with n keys = Catalan(n) = C(2n,n)/(n+1)
For n=3: C(6,3)/4 = 20/4 = 5

The 5 BSTs with {1,2,3}: root=1 (2 trees), root=2 (1 tree), root=3 (2 trees). Distinct BSTs ≠ distinct binary trees (which can have same shape but different keys).

Catalan Numbers for Exam
  • n=1: 1 BST
  • n=2: 2 BSTs
  • n=3: 5 BSTs
  • n=4: 14 BSTs
Q53 DS – Trees Perfect binary tree of height 3 — how many leaf nodes?
  • A 7
  • B 8
  • C 6
  • D 5
✔ Correct Answer
B — 8
Formula
Leaf nodes in perfect binary tree of height h = 2^h
h = 3 → 2³ = 8 leaf nodes

Total nodes = 2^(h+1) - 1 = 2^4 - 1 = 15

Note: 7 (option A) = total nodes at heights 0+1+2 = 1+2+4 = 7, which is internal nodes only. Don't confuse total nodes (15) with leaf nodes (8).

Q66 Algorithms – Sorting Which statement is correct about Quick Sort?
  • A partition() places the pivot at its correct sorted position.
  • B Worst case is guaranteed O(n log n).
  • C It is inherently stable.
  • D Requires O(n) auxiliary space.
✔ Correct Answer
A — partition() places pivot correctly
Explanation

After partition(), the pivot element is in its correct final sorted position — all elements to its left are smaller, all to its right are larger. This is Quick Sort's key invariant.


Why Others Are Wrong
  • B: Worst case is O(n²) — happens when pivot is always min/max (e.g., sorted array with last element as pivot). O(n log n) is average case.
  • C: Quick Sort is NOT stable — elements with equal values may change relative order during partitioning.
  • D: Space complexity is O(log n) for the recursion stack (average) — not O(n).
Q76 Algorithms – Matrix Multiply Strassen's Matrix Multiplication: (i) Divide & conquer. (ii) 2×2 needs 7 multiplications & 18 additions. Which is true?
  • A Both (i) and (ii)
  • B Only (i)
  • C Only (ii)
  • D Neither
✔ Correct Answer
A — Both are true
Explanation

(i) TRUE: Strassen divides each n×n matrix into four n/2×n/2 submatrices and recursively computes 7 products (instead of 8 in naive divide-and-conquer).

(ii) TRUE: For 2×2 matrices: 7 multiplications + 18 additions/subtractions. Compare with naive: 8 multiplications + 4 additions. Strassen saves one multiplication at the cost of more additions.

Strassen complexity: O(n^log₂7) ≈ O(n^2.807)
vs Naive: O(n³)
Computer Organisation & Architecture
Q5 CO – Addressing Modes Register Addressing Mode — which statement is correct?
  • A Operand stored directly in instruction.
  • B Operand in a CPU register; register's address is in instruction's address field.
  • C Operand in memory; address in instruction.
  • D Operand in a register whose address is in ACC.
✔ Correct Answer
B
Explanation

In Register Addressing Mode, the operand resides in a CPU register, and the instruction's address field specifies which register (e.g., R1, R2). This is the fastest mode because no memory access is needed.


All Addressing Modes
  • Immediate: Operand is in the instruction itself (A → operand "in instruction" = option A)
  • Direct: Instruction has the memory address → option C
  • Register: Instruction has register name → option B ✓
  • Indirect: Instruction has address of a memory word that holds the actual address
  • Implied: Operand is implicit (e.g., stack top in zero-address)
  • Relative: EA = PC + displacement
Q8 CO – Paging Logical address space = 4096, page size = 512. How many high-order bits for page number?
  • A 8
  • B 9
  • C 3
  • D 2
✔ Correct Answer
C — 3 bits
Calculation
Total address bits = log₂(4096) = 12 bits
Page offset bits = log₂(512) = 9 bits
Page number bits = 12 - 9 = 3 bits

Number of pages = 4096 / 512 = 8 = 2³ → needs 3 bits ✓
Why A (8) Is Tempting

8 is log₂(256) — not relevant here. The trap is confusing page offset bits (9) with page number bits (3).

Q25 CO – Instruction Formats Which is INCORRECT about three-address instructions?
  • A The first address must always be a register.
  • B ADD R1, A, B ≡ R1 ← M[A] + M[B]
  • C Cyber 170 uses three-address instructions.
  • D Each address field can be register or memory.
✔ Correct Answer (INCORRECT statement)
A — First address is NOT required to be a register
Explanation

In three-address instructions, each of the three address fields can refer to either a register or a memory location — there's no requirement that the first address must always be a register. This is confirmed by option D (which is correct).

Q35 CO – Addressing Modes Zero-address instructions in stack-organised computers use which addressing mode?
  • A Register addressing
  • B Implied addressing
  • C Immediate addressing
  • D Register indirect addressing
✔ Correct Answer
B — Implied (Implicit) Addressing
Explanation

Zero-address instructions don't specify any operand address because the operand location is implied — it's always the top of the stack. E.g., ADD pops TOS and SOS, adds them, pushes result. The stack pointer implicitly defines operand locations.

Examples: PUSH, POP, ADD in stack machines (like HP RPN calculators)
Q40 CO – Memory Addressing 32-bit word, 8-bit opcode, byte-addressable. Max memory in direct addressing?
  • A 2¹⁶ bytes
  • B 2²⁴ bytes
  • C 2³² bytes
  • D 2⁸ bytes
✔ Correct Answer
B — 2²⁴ bytes (16 MB)
Calculation
Instruction size = 32 bits
Opcode = 8 bits
Address bits = 32 - 8 = 24 bits

Direct addressing: 24-bit address directly addresses memory
Max memory = 2²⁴ bytes = 16,777,216 bytes = 16 MB
Q45 CO – Instruction Format (i) Opcode specifies the operation. (ii) Mode field stores the actual address. Which is true?
  • A Neither
  • B Only (ii)
  • C Only (i)
  • D Both
✔ Correct Answer
C — Only (i) is true
Explanation

(i) TRUE: The opcode (operation code) field specifies what operation to perform (ADD, MOV, SUB, etc.).

(ii) FALSE: The mode field specifies the addressing mode (how to interpret the address field) — NOT the actual address. The actual address is in the address field.

Q48 CO – Pipelining Pipelined processor with k stages, 1 clock per stage. Which is TRUE?
  • A First instruction completes in 1 cycle.
  • B Throughput is 1 instruction per k cycles.
  • C Once pipeline is full, 1 instruction completes per cycle.
  • D Pipelining reduces latency of individual instructions.
✔ Correct Answer
C
Explanation

Once all k stages are occupied (pipeline full), one instruction exits (completes) every clock cycle — throughput = 1 instruction/cycle.


Why Others Are Wrong
  • A: First instruction takes k cycles to complete (goes through all k stages). Not 1 cycle.
  • B: Throughput is 1/cycle (not 1/k cycles) once full. 1/k is the throughput of a NON-pipelined processor.
  • D: Pipelining does NOT reduce individual instruction latency — each instruction still takes k cycles. It increases THROUGHPUT, not reduces latency.
Q59 CO / OS – Paging 32-bit addresses, 4KB page size, 4-byte page table entries. Page table size?
  • A 8 MB
  • B 4 MB
  • C 4 GB
  • D 16 MB
✔ Correct Answer
B — 4 MB
Calculation
Page size = 4 KB = 2¹² bytes → offset = 12 bits
Page number bits = 32 - 12 = 20 bits
Number of pages = 2²⁰ = 1,048,576
Each entry = 4 bytes
Page table size = 2²⁰ × 4 = 4 × 2²⁰ = 2²² bytes = 4 MB
Q60 CO – Addressing Modes Relative Addressing Mode: (i) EA = PC + address part. (ii) Address can be positive or negative. Which is true?
  • A Neither
  • B Only (i)
  • C Both
  • D Only (ii)
✔ Correct Answer
C — Both are true
Explanation

(i) TRUE: Effective Address = Program Counter + displacement. The PC holds the address of the next instruction, and a displacement is added.

(ii) TRUE: The displacement (offset) can be positive (jump forward) or negative (jump backward). This is how loops in assembly work — a negative offset jumps back to the loop start.

Q64 CO – Instruction Formats Which statement is correct about one-address instructions?
  • A LOAD A ≡ M[A] ← AC
  • B Stack computers use two-address instructions.
  • C Use an Index Register for all data manipulation.
  • D ADD A ≡ AC ← AC + M[A]
✔ Correct Answer
D — ADD A: AC ← AC + M[A]
Explanation

One-address instructions use the Accumulator (AC) as an implicit second operand. ADD A adds the contents of memory location A to the accumulator and stores the result in AC. LOAD A copies M[A] into AC (not the other way).


Why Others Are Wrong
  • A: LOAD A means AC ← M[A] (load FROM memory INTO accumulator). Option A reverses this — that would be STORE A.
  • B: Stack computers use zero-address instructions (operands implicitly on stack).
  • C: Index Register is used in indexed addressing mode — not the default for one-address instructions.
Digital Electronics & Boolean Algebra
Q3 DE – Combinational Circuits Sum of two 3-bit numbers — how many output lines?
  • A 5
  • B 6
  • C 4
  • D 3
✔ Correct Answer
C — 4 output lines
Calculation
Max 3-bit number = 111₂ = 7
Max sum = 7 + 7 = 14 = 1110₂ → needs 4 bits to represent
∴ 4 output lines required
General Rule

Adding two n-bit numbers produces at most an (n+1)-bit sum. For n=3: output = 4 bits. The extra bit handles the carry-out.

Q10 DE – Registers (i) Shift register uses flip-flops and logic gates. (ii) Can transfer information. Which is true?
  • A Neither
  • B Only (i)
  • C Only (ii)
  • D Both (i) and (ii)
✔ Correct Answer
D — Both
Explanation

(i) TRUE: A shift register is built from a chain of flip-flops (usually D flip-flops) clocked together, sometimes with additional logic gates for serial/parallel input-output.

(ii) TRUE: Shift registers can perform serial data transfer (SISO, SIPO, PISO, PIPO) and are used in serial communication, data conversion, and multiplication/division by 2.

Q19 DE – Boolean Algebra A + A' = ?
  • A 0
  • B A
  • C 1
✔ Correct Answer
C — 1
Explanation

This is the Complement Law: A + A' = 1. Either A is 1 (so A=1 makes it 1) or A' is 1 (when A=0, A'=1). One of them is always 1.

Boolean Laws:
A + A' = 1 (complement law — OR)
A · A' = 0 (complement law — AND)
A + A = A (idempotent)
A · A = A (idempotent)
Q38 DE – Adders Full adder requires how many half adders and logic gates?
  • A 2 half adders + 1 NAND gate
  • B 2 half adders + 1 OR gate
  • C 2 half adders + 1 AND gate
  • D 2 half adders + 1 NOR gate
✔ Correct Answer
B — 2 half adders + 1 OR gate
Explanation
Half Adder 1: Sum₁ = A ⊕ B, C₁ = A · B
Half Adder 2: Sum = Sum₁ ⊕ Cₙ, C₂ = Sum₁ · Cₙ
OR gate: Cout = C₁ OR C₂

Final Full Adder: Sum = A⊕B⊕Cₙ, Cout = AB + BCₙ + ACₙ

The two carry outputs from both half adders are ORed to get the final carry-out. An AND gate would be wrong — two carries can never both be 1 simultaneously (so OR and AND give same result, but conceptually it's OR).

Q62 DE – Combinational Circuits Which circuit uses exactly one XOR gate and one AND gate?
  • A Half Adder
  • B Half Subtractor
  • C Full Adder
  • D Full Subtractor
✔ Correct Answer
A — Half Adder
Explanation
Half Adder:
Sum = A ⊕ B (XOR gate)
Carry = A · B (AND gate)
Total: 1 XOR + 1 AND ✓

Why Others Are Wrong
  • Half Subtractor: Difference = A⊕B (XOR), Borrow = A'·B (AND + NOT). Needs an additional NOT gate.
  • Full Adder: Needs 2 XOR, 2 AND, 1 OR (or 2 half adders + 1 OR).
  • Full Subtractor: Even more gates.
Q74 DE – Boolean Functions How many distinct Boolean functions can be formed with exactly 2 Boolean variables?
  • A 17
  • B 14
  • C 15
  • D 16
✔ Correct Answer
D — 16
Formula
With n variables: 2^(2^n) distinct Boolean functions
n = 2: 2^(2²) = 2^4 = 16

With 2 variables (A, B), there are 4 input combinations (00, 01, 10, 11). Each combination can output 0 or 1 independently → 2⁴ = 16 possible truth tables = 16 distinct Boolean functions.

These include: AND, OR, XOR, NAND, NOR, XNOR, NOT A, NOT B, A, B, 0, 1, etc.

Number Systems
Q11 NS – Base Conversion (5348)₉ − (2873)₉. Identify the INCORRECT representation.
  • A 1760 in decimal ✓
  • B 6E2 in hexadecimal ✗
  • C 3340 in octal ✓
  • D 2365 in base-9 ✓
✔ Correct Answer (INCORRECT representation)
B — 6E2 in hex is wrong (correct is 6E0)
Full Calculation
5348₉ = 5×729 + 3×81 + 4×9 + 8 = 3645+243+36+8 = 3932
2873₉ = 2×729 + 8×81 + 7×9 + 3 = 1458+648+63+3 = 2172
Result = 3932 - 2172 = 1760₁₀ ✓

1760 → Hex: 1760÷16=110 r 0, 110÷16=6 r 14(E), 6÷16=0 r 6
1760₁₀ = 6E0₁₆ (NOT 6E2)

1760 → Octal: 1760÷8=220r0, 220÷8=27r4, 27÷8=3r3, 3÷8=0r3
1760₁₀ = 3340₈ ✓

2365₉ = 2×729+3×81+6×9+5 = 1458+243+54+5 = 1760 ✓
Q12 NS – Base Conversion N = (231)_y = (11101)₂. Find y.
  • A y = 4
  • B y = 5
  • C y = 3
✔ Correct Answer
A — y = 4 (most likely intended answer)
Explanation & Note

y = 3 is invalid immediately — the digit '3' appears in (231)_y, and digits must be less than the base. So y > 3.

The binary number in the question may have a typo (the math for y=4 gives (231)₄ = 32+12+1 = 45 = (101101)₂, not (11101)₂). The most common exam answer is y = 4 as the smallest valid base greater than 3.

y=4: (231)₄ = 2×16 + 3×4 + 1 = 45
y=5: (231)₅ = 2×25 + 3×5 + 1 = 66
Q61 NS – Binary Representation How many bits are required to represent decimal 1000 in binary?
  • A 10
  • B 11
  • C 9
  • D 8
✔ Correct Answer
A — 10 bits
Calculation
1000 in binary = 1111101000₂
(512+256+128+64+32+8 = 1000)
Count: 10 bits

Check: 2⁹ = 512 < 1000 < 1024 = 2¹⁰
So 10 bits are needed (not 9).
Q63 NS – Binary Count of 0s and 1s in binary representation of decimal 992?
  • A Four 0's and five 1's
  • B Five 0's and four 1's
  • C Four 0's and six 1's
  • D Five 0's and five 1's
✔ Correct Answer
D — Five 0's and five 1's
Calculation
992 = 512+256+128+64+32 = 2⁹+2⁸+2⁷+2⁶+2⁵
992 = 1111100000₂
Count: Five 1's + Five 0's = 10 bits total
Q69 NS / CO – Paging Logical address space = 1024, page size = 256. How many low-order bits for page offset?
  • A 8
  • B 16
  • C 10
  • D 12
✔ Correct Answer
A — 8 bits
Calculation
Page offset bits = log₂(page size) = log₂(256) = 8 bits
Total address bits = log₂(1024) = 10 bits
Page number bits = 10 - 8 = 2 bits → 4 pages
Q75 NS – Hexadecimal In hexadecimal, which character represents decimal 12?
  • A B
  • B A
  • C C
  • D D
✔ Correct Answer
C — C
Hex Reference Table
0-9 = 0-9 | 10=A | 11=B | 12=C | 13=D | 14=E | 15=F
C / C++ Programming
Q22 C++ – Loops Which 'for' loop results in an infinite loop?
  • A for(int i=0; i<10; i++)
  • B for(int i=1; ; i++)
  • C for(int i=10; i>0; i--)
  • D for(int i=0; i==10; i++)
✔ Correct Answer
B — for(int i=1; ; i++)
Explanation

An empty condition in a for loop is treated as always true in C++. So for(int i=1; ; i++) never stops — it's an infinite loop.


Why D Is NOT Infinite (Tricky!)

for(int i=0; i==10; i++) — i starts at 0, condition i==10 is immediately FALSE (0≠10), so the loop body executes zero times and exits. Not infinite, but a zero-iteration loop.

Q37 C++ – Loops Which C++ segment does NOT correctly print 1 to 10?
  • A for(int a=1; a<=10; a++) { cout << a; } ✓
  • B int a=1; while(a<=10) { cout << a; a++; } ✓
  • C int a=1; do { cout << a; a++; } while(a<=10); ✓
  • D int a=1; while(a<10) { a++; cout << a; } ✗
✔ Correct Answer (does NOT work correctly)
D
Explanation

Option D: starts at a=1, condition a<10 is true, then increments a before printing: prints 2, 3, 4, ..., 10. Misses 1! The condition also stops before a=10 can re-enter — wait, let's trace: when a=9, condition true, a becomes 10, prints 10. Then condition a<10 is false (10<10 = false), exits. Prints 2–10, missing 1.


Why C (do-while) Works Correctly

The do-while: prints a=1, increments to 2, checks 2≤10 (true)... continues until printing 10, increments to 11, checks 11≤10 (false), stops. Prints 1–10 correctly ✓

Q51 C – File I/O Which statement about fopen() in C is correct?
  • A Return type is void.
  • B Accepts filename + integer mode.
  • C Accepts three parameters.
  • D Accepts two parameters, both char*.
✔ Correct Answer
D — Two char* parameters
Explanation
FILE *fopen(const char *filename, const char *mode);

Example: fopen("data.txt", "r");
Returns: FILE* pointer (NULL on failure)

Both parameters are strings: filename (path to file) and mode ("r", "w", "a", "rb", etc.). Return type is FILE*, not void.

Q57 C – Data Types char x = 130; printf("x = %d", x); — What is the output?
  • A x = 386
  • B x = 130
  • C x = -126
  • D x = 256
✔ Correct Answer
C — x = -126
Signed Overflow
signed char range: -128 to +127
130 > 127 → overflow!

130 in binary: 10000010
Interpreted as signed: -(128-2) = -126

Alternatively: 130 - 256 = -126

In C, assigning 130 to a signed char causes implementation-defined behaviour (overflow), but on most systems with two's complement, the result is -126.

Key Point

If char is unsigned (0 to 255), x=130 would print 130. If signed (-128 to 127), 130 overflows to -126. By default in most compilers, char is signed.

Remaining Questions
Q23 CO – Cache Memory Which statement about Cache Memory is correct?
  • A Speed lower than main memory.
  • B It is auxiliary memory.
  • C Communicates directly with input devices.
  • D Small, high-speed memory between CPU and main memory.
✔ Correct Answer
D
Explanation

Cache is the fastest memory in the hierarchy, sitting between CPU registers and RAM. It stores frequently/recently accessed data so the CPU doesn't always have to access slow RAM.

Speed: Registers > L1 Cache > L2 Cache > L3 Cache > RAM > SSD > HDD
Q43 OS – File Systems Which maintains one entry for each disk block, indexed by block number?
  • A Virtual memory
  • B Memory page
  • C File Allocation Table (FAT)
  • D Memory segment
✔ Correct Answer
C — File Allocation Table (FAT)
Explanation

FAT is a file system structure where each entry corresponds to a disk block (cluster). Each FAT entry contains either the next block in a file chain, or a special marker (EOF, free, bad). The FAT is indexed by block number, making it a disk-wide lookup table for block allocation.

Q65 Networks – Protocols Connection-oriented approach: (i) File transfer (ii) Remote login (iii) PSTN?
  • A Only (ii) and (iii)
  • B Only (i) and (iii)
  • C Only (i) and (ii)
  • D All three: (i), (ii), and (iii)
✔ Correct Answer
D — All three
Explanation
  • File transfer (FTP): Uses TCP (connection-oriented) — ensures complete, ordered file delivery ✓
  • Remote login (Telnet/SSH): Uses TCP — interactive sessions need reliable, ordered delivery ✓
  • PSTN (Public Switched Telephone Network): Circuit-switched — establishes a dedicated physical connection before communication ✓