Skip to lesson

Core CS rapid-fire round

The interviewer fires 20 short questions in 15 minutes: process or thread, ACID, TCP or UDP. They are checking whether your basics come out instantly and correctly, not whether you can talk for two minutes.

How the round runs: answers in two or three sentences

A rapid-fire round is a part of a technical interview where the interviewer asks many short core CS questions in a row and expects a correct two-to-three-sentence answer to each.

Run this mock with a friend or a timer: 30 questions, about 30 seconds each, answered aloud. Cover the model answers, answer, then check.

Example 1 · A long answer and a rapid-fire answer

Text
Question: "What is a deadlock?"Too long: "So deadlock is a very important concept in OS. It happens in           many systems, like databases also. Basically there are           processes and resources, and in our college lab once the           printer was stuck... (goes on for two minutes)"Rapid-fire: "A deadlock is when two or more processes wait forever, each             holding a resource the other needs. It needs four conditions             at once: mutual exclusion, hold and wait, no preemption and             circular wait."
Why the second one wins
Definition in sentence 1, the key fact (four conditions) in sentence 2.
About 15 seconds. The interviewer can follow up on prevention if they want.

What this code does

  • The long answer never gives a clear definition, and the story uses up time.
  • The rapid-fire answer is complete and gives the interviewer an easy follow-up ("How do you prevent it?").
  • Naming the four conditions shows depth in one sentence.

Score every question 2 (full), 1 (partly right) or 0 (wrong or blank). A real round may ask 10 to 20 questions in 15 minutes, so one long answer costs you the chance to show the others.

Order of execution

Shape a rapid-fire answer

Put the parts of a good rapid-fire answer in the order you say them.

If the interviewer wants more, they will ask "Can you explain more?" Let them pull the detail out of you.

Round 1: operating systems (10 questions)

An operating system (OS) is the software that manages the CPU, memory, files and devices for all running programs and gives them common services.

The ten OS questions below check processes and threads, scheduling, synchronisation, deadlock and memory. Answer each one aloud before you read the model answer.

Example 2 · Operating systems: questions and model answers

Text
 1. What is the difference between a process and a thread? 2. What is a context switch? 3. What is a deadlock, and what conditions cause it? 4. What is paging? 5. What is virtual memory, and what is a page fault? 6. What is thrashing? 7. What is the difference between a mutex and a semaphore? 8. How does Round Robin scheduling work? 9. What is starvation, and how does aging fix it?10. What is a race condition, and what is a critical section?
Model answers
 1. A process is a running program with its own memory space. A thread
    runs inside a process and shares its memory with the other threads,
    so threads are cheaper to create and switch.
 2. The CPU saves the state (registers, program counter) of the running
    process or thread and loads another's. It is pure overhead: no useful
    work is done during the switch.
 3. Processes wait forever, each holding a resource another needs. All
    four must hold: mutual exclusion, hold and wait, no preemption,
    circular wait.
 4. Logical memory is split into fixed-size pages and physical memory into
    frames of the same size; a page table maps pages to frames. It removes
    external fragmentation.
 5. Virtual memory lets a process use more memory than the physical RAM by
    keeping some pages on disk. A page fault happens when a page is
    accessed that is not in RAM, so the OS loads it from disk.
 6. The system spends more time moving pages between RAM and disk than
    running programs, usually because too many processes share too few
    frames.
 7. A mutex is a lock held by one thread at a time, and only the owner
    releases it. A semaphore is a counter that allows up to N threads in;
    any thread can signal it.
 8. Each process gets the CPU for a fixed time slice (quantum) in turn,
    then goes to the back of the queue. It is preemptive and gives good
    response time; a very small quantum adds switching overhead.
 9. Starvation is when a process waits indefinitely, for example a low-
    priority process. Aging slowly raises the priority of waiting
    processes so they eventually run.
10. A race condition is when the result depends on the timing of threads
    using shared data. The critical section is the code that uses the
    shared data; only one thread at a time should run it.

What this code does

  • Each answer has a definition and one key detail, which is the length an interviewer expects.
  • Answers 3 and 7 are the most common follow-up magnets: be ready for prevention and for binary semaphore questions.
  • Answer 4 says paging removes external fragmentation; internal fragmentation can still happen in the last page.

Predict the output

Trace Round Robin

Three processes take turns on the CPU. Work out when each one finishes.

Burst times 5, 3 and 1, time slice 2. What does the program print?

public class RoundRobinDemo {
public static void main(String[] args) {
int[] burst = {5, 3, 1};
int quantum = 2;
int time = 0;
StringBuilder done = new StringBuilder();
int left = burst.length;
while (left > 0) {
for (int i = 0; i < burst.length; i++) {
if (burst[i] == 0) continue;
int run = Math.min(quantum, burst[i]);
time += run;
burst[i] -= run;
if (burst[i] == 0) {
done.append("P").append(i + 1).append("@").append(time).append(" ");
left--;
}
}
}
System.out.println(done.toString().trim());
}
}

Round 2: DBMS (10 questions)

A database management system (DBMS) is software that stores data in tables and lets many users read and change it safely and quickly.

The ten DBMS questions check keys, normal forms, ACID, joins, indexes and one small SQL query. Answer each one aloud before you read the model answer.

Example 3 · DBMS: questions and model answers

Text
11. What is the difference between a primary key and a unique key?12. What does ACID stand for?13. Explain 1NF, 2NF and 3NF in one line each.14. What is the difference between DELETE, TRUNCATE and DROP?15. What is an index, and what does it cost?16. What is the difference between INNER JOIN and LEFT JOIN?17. What is the difference between WHERE and HAVING?18. What is a foreign key?19. What is a dirty read?20. Write a query for the second-highest salary.
Model answers
11. A primary key is unique and NOT NULL, and a table has only one. A
    table can have many unique keys, and they allow NULL (MySQL allows
    several NULLs in a unique column).
12. Atomicity (all or nothing), Consistency (rules always hold),
    Isolation (transactions do not see each other's half-done work),
    Durability (committed data survives a crash).
13. 1NF: each cell holds one atomic value. 2NF: 1NF and no non-key column
    depends on only part of a composite key. 3NF: 2NF and no non-key
    column depends on another non-key column.
14. DELETE removes chosen rows (with WHERE) and can be rolled back in a
    transaction. TRUNCATE removes all rows quickly and, in MySQL, resets
    AUTO_INCREMENT and commits implicitly. DROP removes the whole table.
15. An index is a separate sorted structure, usually a B+ tree, that finds
    rows without scanning the whole table. It costs extra space and makes
    INSERT, UPDATE and DELETE slower.
16. INNER JOIN returns only rows that match in both tables. LEFT JOIN
    returns every row of the left table, with NULLs where the right table
    has no match.
17. WHERE filters rows before grouping; HAVING filters groups after
    GROUP BY, so it can use aggregates like COUNT(*).
18. A column whose values must exist in another table's primary (or
    unique) key. It keeps links between tables valid.
19. Reading another transaction's change before it commits; if that
    transaction rolls back, you read data that never existed. READ
    COMMITTED and stricter levels prevent it.
20. SELECT MAX(salary) FROM employee
    WHERE salary < (SELECT MAX(salary) FROM employee);

What this code does

  • Answer 14 names MySQL behaviour explicitly, because TRUNCATE details differ between databases.
  • Answer 20 handles duplicate top salaries correctly; ORDER BY salary DESC LIMIT 1 OFFSET 1 needs DISTINCT to do the same.
  • For ACID, the one-line meaning of each letter is enough unless they ask for an example.

Find the bug

Find the SQL mistake

Each query gives the wrong result or an error. Tap the line that is wrong.

Find the second-highest salary.

Round 1 of 3

Round 3: computer networks (10 questions)

A computer network is a set of devices that exchange data using agreed rules called protocols, such as TCP, HTTP and DNS.

The ten network questions check the OSI model, TCP and UDP, DNS, HTTP and HTTPS, addresses and devices. Answer each one aloud before you read the model answer.

Example 4 · Computer networks: questions and model answers

Text
21. Name the seven OSI layers in order.22. What is the difference between TCP and UDP?23. Explain the TCP three-way handshake.24. What happens when you type a URL in the browser?25. What does DNS do?26. What is the difference between HTTP and HTTPS?27. What is the difference between an IP address and a MAC address?28. What does ARP do?29. What is the difference between a switch and a router?30. How many usable host addresses does a /24 subnet have?
Model answers
21. Physical, Data Link, Network, Transport, Session, Presentation,
    Application (from layer 1 to layer 7).
22. TCP is connection-oriented and reliable: ordered delivery,
    retransmission, flow and congestion control. UDP is connectionless,
    with no delivery guarantee, but lighter and faster, so it suits
    video calls, games and DNS.
23. The client sends SYN, the server replies SYN-ACK, and the client
    sends ACK. Both sides have then agreed on starting sequence numbers
    and the connection is open.
24. The browser finds the IP address through DNS, opens a TCP connection
    (plus a TLS handshake for HTTPS), sends an HTTP request, gets the
    response and renders the page, loading other files the same way.
25. DNS translates a domain name like example.com into an IP address.
    Lookups usually use UDP on port 53.
26. HTTPS is HTTP over TLS: the data is encrypted, protected from
    tampering, and the server proves its identity with a certificate.
    Default ports are 80 for HTTP and 443 for HTTPS.
27. An IP address is a logical address at the network layer and can
    change between networks. A MAC address is a 48-bit hardware address
    of the network card, used at the data link layer within a local
    network.
28. ARP finds the MAC address for a known IP address on the local
    network, by broadcasting "who has this IP?"
29. A switch connects devices inside one network using MAC addresses
    (layer 2). A router connects different networks and forwards packets
    using IP addresses (layer 3).
30. 254. A /24 has 2^8 = 256 addresses; the network address and the
    broadcast address cannot be given to hosts.

What this code does

  • A common memory aid for the OSI layers from 1 to 7 is "Please Do Not Tell Secret Passwords Anywhere".
  • Answer 24 is the most asked "big" question; keep the order DNS → TCP → TLS → HTTP → render.
  • Answer 30 generalises: a /n subnet has 2^(32 − n) − 2 usable hosts.

Predict the output

Usable hosts in a subnet

A /n subnet has 2^(32 - n) addresses; two of them are not usable by hosts.

Round 1 of 2

How many usable hosts does a /26 subnet have?

public class Hosts26 {
public static void main(String[] args) {
int prefix = 26;
System.out.println((1 << (32 - prefix)) - 2);
}
}

Saying "I am not sure", scoring and what to revise

Reasoning aloud means that when you do not know an answer, you say so honestly and then think step by step through what you do know, instead of guessing silently.

Interviewers meet blank moments all the time. What they remember is whether you invented an answer or reasoned honestly. Never invent a definition.

Example 5 · Saying "I am not sure" and reasoning aloud

Text
Question: "What is Belady's anomaly?"Bad:  (silence for ten seconds) ... "I don't know."Bad:  "It is when the CPU gets too hot and slows down." (made up)Good: "I am not sure of the exact definition. I know it is about page       replacement, so I think it is a case where giving a process more       frames causes more page faults, which sounds wrong but can happen       with FIFO. Is that right?"
What the good answer shows
- Honesty: says "not sure" up front
- Reasoning: links the term to the topic it belongs to
- A careful guess, clearly labelled as a guess (and here it is correct)
- Ends by checking, which invites a hint

What this code does

  • An invented answer is the worst choice: it damages trust in your other answers.
  • Reasoning from the topic ("it is about page replacement") often gets you most of the way there.
  • If you truly have nothing, say "I have not studied that yet; I will read about it today" and move on.

Example 6 · Scoring sheet: marks by topic and what to revise

RapidFireScoreDemo.javaJava
public class RapidFireScoreDemo {    public static void main(String[] args) {        String[] topics = {"OS", "DBMS", "Networks"};        // 2 = full, 1 = partly right, 0 = wrong or blank; questions 1-10, 11-20, 21-30        int[][] marks = {            {2, 2, 1, 2, 0, 1, 2, 2, 2, 1},            {2, 1, 2, 0, 2, 2, 1, 0, 1, 2},            {2, 2, 2, 1, 2, 0, 1, 2, 2, 2},        };
        int grand = 0;        for (int t = 0; t < topics.length; t++) {            int score = 0;            StringBuilder missed = new StringBuilder();            for (int q = 0; q < marks[t].length; q++) {                score += marks[t][q];                if (marks[t][q] == 0) {                    missed.append(" Q").append(t * 10 + q + 1);                }            }            grand += score;            int percent = score * 100 / (2 * marks[t].length);            System.out.printf("%-8s %2d/20  %3d%%  missed:%s%s%n", topics[t], score, percent,                    missed, percent < 70 ? "  -> revise" : "");        }        System.out.println("Total: " + grand + "/60");    }}
Output
OS       15/20   75%  missed: Q5
DBMS     13/20   65%  missed: Q14 Q18  -> revise
Networks 16/20   80%  missed: Q26
Total: 44/60

What this code does

  • Question numbers are rebuilt from the topic and position (t * 10 + q + 1), so they match the lists above.
  • DBMS is below 70%, so it goes on the revision list, starting with Q14 (DELETE, TRUNCATE, DROP) and Q18 (foreign key).
  • The 70% line is a practical target; set your own, but keep it the same between mocks so you can compare.

Interviewers usually prefer "I am not sure, but I think..." with sensible reasoning over a confident wrong answer. After the mock, total your marks per topic: any topic below about 70% goes on the revision list, and the questions you scored 0 on are re-learned first.

Practise these answers aloud in the timed Mock Interview Mode (opens in a new tab).

Next step

Check your understanding

12 quick questions