AI InterviewSearch…Search problems, topics, or pages…Ctrl KGet started

Topic

OS, DBMS & Networks aptitude questions

Core computer science: processes, scheduling, SQL, normalisation and the OSI layers.

0 of 40 solved in this view

Formula sheetOS, DBMS & Networks: the essentialsFormula sheetOS, DBMS & Networks: the essentialsShow

Three subjects, each asked as short facts and small calculations.

Operating systems

  • Turnaround = completion − arrival; waiting = turnaround − burst.
  • Scheduling: FCFS suffers the convoy effect; non-preemptive SJF gives the least average waiting time and SRTF is its preemptive form; round robin with a huge quantum becomes FCFS.
  • Deadlock needs mutual exclusion, hold and wait, no preemption and circular wait at once. P processes needing at most N units each cannot deadlock with P(N − 1) + 1 units.
  • Paging: 32-bit addresses with 4 KB pages give 2³² ÷ 2¹² = 2²⁰ page-table entries. With a TLB, EMAT = h(t + m) + (1 − h)(t + 2m). FIFO can show Belady's anomaly; LRU cannot.
  • Threads share code, data and files but keep their own stack and registers.

DBMS and networks

  • Normal forms: 2NF removes partial dependencies, 3NF transitive ones; BCNF needs every determinant to be a superkey.
  • SQL runs FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY: WHERE filters rows, HAVING filters groups. COUNT(*) counts rows; other aggregates skip NULLs.
  • TRUNCATE is DDL, DELETE is DML.
  • OSI: switches work at layer 2 (MAC), routers at 3 (IP), ports at 4.
  • TCP is reliable and opened by SYN, SYN-ACK, ACK; UDP gives no guarantees. Ports: 22 SSH, 25 SMTP, 53 DNS, 80 HTTP, 443 HTTPS.
  • Usable hosts in a subnet = 2^(32 − prefix) − 2, so a /26 has 62.

Questions40

1

Average waiting time under FCFS

Three processes arrive together at time 0, in the order P1, P2, P3: Under first-come first-served scheduling, what is the average waiting time?

scheduling · fcfs

105s

Medium
2

Average waiting time under SJF

Four processes are all present at time 0: Under non-preemptive shortest-job-first scheduling, what is the average waiting time?

scheduling · sjf

120s

Medium
3

Round robin with a quantum of 4

Three processes arrive together at time 0, in the order P1, P2, P3: Under round-robin scheduling with a time quantum of 4, what is the average waiting time?

scheduling · round robin

135s

Medium
4

Preemptive shortest remaining time first

Four processes arrive at different times: Under shortest-remaining-time-first (preemptive SJF) scheduling, what is the average waiting time?

scheduling · srtf · preemption

180s

Hard
5

The four deadlock conditions

Which of these is not one of the four necessary conditions for deadlock?

deadlock · os

60s

Easy
6

Numbering the resources

An operating system numbers every resource and insists that a process request resources only in increasing order of number.

deadlock · prevention

90s

Medium
7

Units needed to rule out deadlock

Four processes share identical units of a single resource, and each process may need up to 3 units to finish.

deadlock · resources

135s

Hard
8

Counting FIFO page faults

A process references the pages 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5. With three frames and FIFO replacement, how many page faults occur?

paging · fifo · page fault

180s

Medium
9

Counting LRU page faults

A process references the pages 7, 0, 1, 2, 0, 3, 0, 4. With three frames and LRU replacement, how many page faults occur?

paging · lru · page fault

165s

Medium
10

Belady's anomaly

Belady's anomaly — adding a frame producing more page faults — can occur with which page-replacement algorithm?

paging · belady

75s

Easy
11

Size of a page table

A system uses 32-bit logical addresses with a page size of 4 KB. How many entries does a single-level page table contain?

paging · memory

90s

Medium
12

Effective memory access time

A paged system has a TLB hit ratio of 80%. A TLB lookup takes 20 ns and a memory access takes 100 ns.

tlb · paging · performance

150s

Hard
13

Internal fragmentation

Which memory-management scheme suffers from internal fragmentation?

memory · fragmentation

60s

Easy
14

What threads do not share

Two threads belong to the same process. Which of these does each thread keep private?

threads · process

60s

Easy
15

Value of a counting semaphore

A counting semaphore is initialised to 10. Six wait (P) operations and four signal (V) operations are then completed on it. What is its value?

semaphore · synchronisation

75s

Medium
16

Which normal form is it in?

A relation R(A, B, C, D) has A as its only candidate key, with the functional dependencies A → B, B → C and A → D. What is the highest normal form R satisfies?

dbms · normalisation

105s

Medium
17

The gap between 3NF and BCNF

A relation R(A, B, C) has the functional dependencies AB → C and C → B. What is the highest normal form R satisfies?

dbms · normalisation · bcnf

165s

Hard
18

Counting candidate keys

For R(A, B, C, D) with the functional dependencies AB → C, C → D and D → A, how many candidate keys does R have?

dbms · keys · closure

180s

Hard
19

GROUP BY with HAVING

Table employee: What does this query return?

sql · group by

120s

Medium
20

COUNT and NULL

Table employee: What does this query return?

sql · null · aggregate

90s

Medium
21

Rows from a left outer join

Two tables: students marks How many rows does this query return?

sql · join

105s

Medium
22

Largest possible natural join

R(A, B) holds 200 tuples and S(B, C) holds 100 tuples. What is the maximum possible number of tuples in the natural join of R and S?

dbms · join · relational algebra

105s

Medium
23

Where an alias may be used

Why can a column alias defined in the SELECT list be referenced in ORDER BY but not in WHERE?

sql · semantics

90s

Medium
24

TRUNCATE against DELETE

Which command removes every row of a table while keeping the table itself, and is classed as DDL rather than DML?

sql · ddl

60s

Easy
25

Surviving a crash

A transaction commits and the server loses power a second later.

dbms · acid · transactions

60s

Easy
26

Choosing an isolation level

Which isolation level prevents dirty reads but still permits non-repeatable reads?

dbms · isolation · transactions

90s

Medium
27

Clustered indexes

Which statement about a clustered index is correct?

dbms · indexing

75s

Medium
28

PRIMARY KEY against UNIQUE

What distinguishes a PRIMARY KEY constraint from a UNIQUE constraint?

dbms · constraints · keys

60s

Easy
29

Where a router works

A router forwards packets by examining destination IP addresses. At which OSI layer does it operate?

networks · osi · routing

45s

Easy
30

The translation layer

Which OSI layer handles encryption, compression and the translation of data between different character representations?

networks · osi

45s

Easy
31

TCP against UDP

Which of these statements about TCP is false?

networks · tcp · udp

90s

Medium
32

The three-way handshake

What is the correct order of segments in the TCP three-way handshake?

networks · tcp

45s

Easy
33

The port DNS uses

Which well-known port does DNS use by default?

networks · ports · dns

45s

Easy
34

Which DNS record

Which DNS record type maps a host name to an IPv4 address?

networks · dns

45s

Easy
35

Hosts in a /26

How many usable host addresses does an IPv4 subnet with a /26 prefix provide?

networks · subnetting

75s

Medium
36

Finding the broadcast address

A host is configured with the address 192.168.10.75 and the subnet mask 255.255.255.192. What is the broadcast address of its subnet?

networks · subnetting · addressing

150s

Hard
37

Reading an HTTP status code

A server fully understands a request but refuses to authorise it, and repeating the request with the same credentials will not help.

networks · http

75s

Medium
38

Collision and broadcast domains

A single 24-port Ethernet switch has one host on each port and no VLANs configured. How many collision domains and broadcast domains exist?

networks · switching

90s

Medium
39

Flow control in TCP

Which mechanism does TCP use for flow control — that is, to stop a fast sender from overwhelming a slow receiver?

networks · tcp · flow control

90s

Medium
40

Window size in Go-Back-N

A Go-Back-N protocol numbers its frames with a 4-bit sequence number. What is the largest sender window it may use?

networks · sliding window · data link

120s

Hard

Showing 40 of 40

OS, DBMS & Networks Aptitude Questions with Solutions

40 OS, DBMS & Networks questions with hints, worked solutions and time targets — 12 easy · 21 medium · 7 hard.

  • Section: Programming MCQs
  • Questions: 40
  • By difficulty: 12 easy · 21 medium · 7 hard
  • Cost: Free, unlimited on every plan

Core computer science: processes, scheduling, SQL, normalisation and the OSI layers.

OS, DBMS & Networks: the essentials

Three subjects, each asked as short facts and small calculations.

Operating systems

  • Turnaround = completion − arrival; waiting = turnaround − burst.
  • Scheduling: FCFS suffers the convoy effect; non-preemptive SJF gives the least average waiting time and SRTF is its preemptive form; round robin with a huge quantum becomes FCFS.
  • Deadlock needs mutual exclusion, hold and wait, no preemption and circular wait at once. P processes needing at most N units each cannot deadlock with P(N − 1) + 1 units.
  • Paging: 32-bit addresses with 4 KB pages give 2³² ÷ 2¹² = 2²⁰ page-table entries. With a TLB, EMAT = h(t + m) + (1 − h)(t + 2m). FIFO can show Belady's anomaly; LRU cannot.
  • Threads share code, data and files but keep their own stack and registers.

DBMS and networks

  • Normal forms: 2NF removes partial dependencies, 3NF transitive ones; BCNF needs every determinant to be a superkey.
  • SQL runs FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY: WHERE filters rows, HAVING filters groups. COUNT(*) counts rows; other aggregates skip NULLs.
  • TRUNCATE is DDL, DELETE is DML.
  • OSI: switches work at layer 2 (MAC), routers at 3 (IP), ports at 4.
  • TCP is reliable and opened by SYN, SYN-ACK, ACK; UDP gives no guarantees. Ports: 22 SSH, 25 SMTP, 53 DNS, 80 HTTP, 443 HTTPS.
  • Usable hosts in a subnet = 2^(32 − prefix) − 2, so a /26 has 62.

Questions

  1. Average waiting time under FCFS Medium
    Three processes arrive together at time 0, in the order P1, P2, P3: Under first-come first-served scheduling, what is the average waiting time?
  2. Average waiting time under SJF Medium
    Four processes are all present at time 0: Under non-preemptive shortest-job-first scheduling, what is the average waiting time?
  3. Round robin with a quantum of 4 Medium
    Three processes arrive together at time 0, in the order P1, P2, P3: Under round-robin scheduling with a time quantum of 4, what is the average waiting time?
  4. Preemptive shortest remaining time first Hard
    Four processes arrive at different times: Under shortest-remaining-time-first (preemptive SJF) scheduling, what is the average waiting time?
  5. The four deadlock conditions Easy
    Which of these is not one of the four necessary conditions for deadlock?
  6. Numbering the resources Medium
    An operating system numbers every resource and insists that a process request resources only in increasing order of number.
  7. Units needed to rule out deadlock Hard
    Four processes share identical units of a single resource, and each process may need up to 3 units to finish.
  8. Counting FIFO page faults Medium
    A process references the pages 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5. With three frames and FIFO replacement, how many page faults occur?
  9. Counting LRU page faults Medium
    A process references the pages 7, 0, 1, 2, 0, 3, 0, 4. With three frames and LRU replacement, how many page faults occur?
  10. Belady's anomaly Easy
    Belady's anomaly — adding a frame producing more page faults — can occur with which page-replacement algorithm?
  11. Size of a page table Medium
    A system uses 32-bit logical addresses with a page size of 4 KB. How many entries does a single-level page table contain?
  12. Effective memory access time Hard
    A paged system has a TLB hit ratio of 80%. A TLB lookup takes 20 ns and a memory access takes 100 ns.
  13. Internal fragmentation Easy
    Which memory-management scheme suffers from internal fragmentation?
  14. What threads do not share Easy
    Two threads belong to the same process. Which of these does each thread keep private?
  15. Value of a counting semaphore Medium
    A counting semaphore is initialised to 10. Six wait (P) operations and four signal (V) operations are then completed on it. What is its value?
  16. Which normal form is it in? Medium
    A relation R(A, B, C, D) has A as its only candidate key, with the functional dependencies A → B, B → C and A → D. What is the highest normal form R satisfies?
  17. The gap between 3NF and BCNF Hard
    A relation R(A, B, C) has the functional dependencies AB → C and C → B. What is the highest normal form R satisfies?
  18. Counting candidate keys Hard
    For R(A, B, C, D) with the functional dependencies AB → C, C → D and D → A, how many candidate keys does R have?
  19. GROUP BY with HAVING Medium
    Table employee: What does this query return?
  20. COUNT and NULL Medium
    Table employee: What does this query return?
  21. Rows from a left outer join Medium
    Two tables: students marks How many rows does this query return?
  22. Largest possible natural join Medium
    R(A, B) holds 200 tuples and S(B, C) holds 100 tuples. What is the maximum possible number of tuples in the natural join of R and S?
  23. Where an alias may be used Medium
    Why can a column alias defined in the SELECT list be referenced in ORDER BY but not in WHERE?
  24. TRUNCATE against DELETE Easy
    Which command removes every row of a table while keeping the table itself, and is classed as DDL rather than DML?
  25. Surviving a crash Easy
    A transaction commits and the server loses power a second later.
  26. Choosing an isolation level Medium
    Which isolation level prevents dirty reads but still permits non-repeatable reads?
  27. Clustered indexes Medium
    Which statement about a clustered index is correct?
  28. PRIMARY KEY against UNIQUE Easy
    What distinguishes a PRIMARY KEY constraint from a UNIQUE constraint?
  29. Where a router works Easy
    A router forwards packets by examining destination IP addresses. At which OSI layer does it operate?
  30. The translation layer Easy
    Which OSI layer handles encryption, compression and the translation of data between different character representations?
  31. TCP against UDP Medium
    Which of these statements about TCP is false?
  32. The three-way handshake Easy
    What is the correct order of segments in the TCP three-way handshake?
  33. The port DNS uses Easy
    Which well-known port does DNS use by default?
  34. Which DNS record Easy
    Which DNS record type maps a host name to an IPv4 address?
  35. Hosts in a /26 Medium
    How many usable host addresses does an IPv4 subnet with a /26 prefix provide?
  36. Finding the broadcast address Hard
    A host is configured with the address 192.168.10.75 and the subnet mask 255.255.255.192. What is the broadcast address of its subnet?
  37. Reading an HTTP status code Medium
    A server fully understands a request but refuses to authorise it, and repeating the request with the same credentials will not help.
  38. Collision and broadcast domains Medium
    A single 24-port Ethernet switch has one host on each port and no VLANs configured. How many collision domains and broadcast domains exist?
  39. Flow control in TCP Medium
    Which mechanism does TCP use for flow control — that is, to stop a fast sender from overwhelming a slow receiver?
  40. Window size in Go-Back-N Hard
    A Go-Back-N protocol numbers its frames with a 4-bit sequence number. What is the largest sender window it may use?

Placement tests that ask os, dbms & networks