Intermediate Computer Science interview questions

150 questions with answers (CSE-151 to CSE-300). Try each one aloud before reading the answer.

Data Structures

CSE-151 · How does a hash map handle collisions?

With separate chaining, each bucket holds a list (or, in Java 8+, a balanced tree once a bucket grows large) of entries. With open addressing, the colliding key probes for another slot by linear probing, quadratic probing or double hashing.

CSE-152 · What is the load factor of a hash table and why does it matter?

Load factor α = n / m, the number of entries over the number of buckets. As α grows, collisions and probe lengths rise, so tables resize, typically doubling, when α crosses a threshold such as 0.75 in Java's HashMap.

CSE-153 · How do you implement a queue using two stacks?

Push onto an inbox stack. To dequeue, if the outbox stack is empty, pop everything from inbox and push onto outbox, then pop from outbox. Each element moves at most twice, giving amortized O(1) per operation.

CSE-154 · How do you detect a cycle in a linked list?

Use Floyd's tortoise-and-hare: advance slow by one node and fast by two. If they ever meet there is a cycle; if fast reaches null there is none. It runs in O(n) time and O(1) space.

CSE-155 · What are the tree traversal orders?

Inorder (left, root, right), which gives sorted order for a BST; preorder (root, left, right), useful for copying trees; postorder (left, right, root), useful for deletion; and level order, which uses a queue.

CSE-156 · What is an AVL tree?

A self-balancing BST where the heights of each node's left and right subtrees differ by at most one. After insertions and deletions, rotations (LL, RR, LR, RL) restore balance, guaranteeing O(log n) operations.

CSE-157 · What is a red-black tree?

A self-balancing BST whose nodes are coloured red or black, with rules that the root is black, red nodes have black children and every root-to-leaf path has equal black nodes. Height stays ≤ 2 log₂(n + 1), and it backs Java's TreeMap and C++'s std::map.

CSE-158 · How is a binary heap stored in an array?

For 0-based index i, the children are at 2i + 1 and 2i + 2 and the parent is at ⌊(i − 1) / 2⌋. The complete-tree shape means no pointers are needed and storage is compact.

CSE-159 · What is a B-tree and why do databases use it?

A balanced multi-way search tree where each node holds many keys and children, keeping height low. Because each node maps to a disk page, lookups need few I/Os; B+ trees, which keep all data in linked leaves, also give efficient range scans.

CSE-160 · What is a disjoint-set (union-find) structure?

It tracks elements partitioned into disjoint sets with find (return the set's representative) and union (merge two sets). With path compression and union by rank, operations take amortized O(α(n)), effectively constant. It is used in Kruskal's algorithm.

CSE-161 · How do you build an LRU cache with O(1) operations?

Combine a hash map from key to node with a doubly linked list ordered by recency. On get, move the node to the front; on put, insert at the front and evict the tail when over capacity. Python's OrderedDict and Java's LinkedHashMap provide this.

CSE-162 · What is a segment tree?

A binary tree over array ranges where each node stores an aggregate (sum, min, max) of its segment. It answers range queries and point updates in O(log n) using O(n) space.

CSE-163 · What is a skip list?

A layered linked list where higher levels skip over many elements, with each node promoted to a higher level with probability ½. Search, insert and delete take expected O(log n), and it is simpler to implement concurrently than balanced trees; Redis uses it for sorted sets.

Algorithms & Complexity

CSE-164 · What is the time complexity of QuickSort?

Average O(n log n). Worst case O(n²) when the pivot repeatedly ends up as the smallest or largest element, as with a first-element pivot on sorted input. It is in-place with O(log n) average stack but not stable; random or median-of-three pivots make the worst case unlikely.

CSE-165 · What does the Master Theorem state?

For T(n) = aT(n/b) + f(n), compare f(n) with n^(log_b a). If f is polynomially smaller, T = Θ(n^(log_b a)); if equal, T = Θ(n^(log_b a) log n); if larger (with regularity), T = Θ(f(n)). Merge sort: a = 2, b = 2, f = n gives Θ(n log n).

CSE-166 · How does heap sort work?

Build a max-heap in O(n), then repeatedly swap the root with the last element, shrink the heap and sift down. Total time is O(n log n) in all cases with O(1) extra space, but it is not stable.

CSE-167 · What is the lower bound for comparison-based sorting?

Ω(n log n). A decision tree must have at least n! leaves, so its height is at least log₂(n!) ≈ n log₂ n. Counting, radix and bucket sort beat this by not comparing elements.

CSE-168 · How does counting sort work and when is it useful?

It counts occurrences of each key in a range of size k, computes prefix sums and places elements into an output array. It runs in O(n + k) and is stable, so it suits small integer ranges and serves as radix sort's subroutine.

CSE-169 · How does Dijkstra's algorithm work?

It keeps tentative distances, repeatedly extracts the unvisited vertex with the smallest distance from a priority queue and relaxes its outgoing edges. With a binary heap it runs in O((V + E) log V), and it requires non-negative edge weights.

CSE-170 · What is topological sorting?

A linear ordering of a DAG's vertices so every edge u → v has u before v. Kahn's algorithm repeatedly removes zero in-degree vertices; the DFS method outputs vertices in reverse finish order. Both are O(V + E).

CSE-171 · What is the difference between memoization and tabulation?

Memoization is top-down: recursive calls cache results and only needed subproblems are solved. Tabulation is bottom-up: an iterative loop fills a table from base cases, avoiding recursion overhead and stack limits.

CSE-172 · How do you solve the 0/1 knapsack problem?

With DP: dp[i][w] = max(dp[i−1][w], vᵢ + dp[i−1][w − wᵢ]) when wᵢ ≤ w. It runs in O(nW) time, which is pseudo-polynomial, and can use a one-dimensional array iterated from high w to low.

CSE-173 · How do Kruskal's and Prim's algorithms find a minimum spanning tree?

Kruskal sorts edges and adds the cheapest edge that does not form a cycle, using union-find, in O(E log E). Prim grows one tree from a start vertex, adding the cheapest edge leaving it, in O(E log V) with a binary heap.

CSE-174 · What is amortized analysis?

Averaging the cost of a sequence of operations so that occasional expensive operations are offset by many cheap ones. A dynamic array that doubles when full has O(1) amortized append despite O(n) resizes.

CSE-175 · What is the two-pointer technique?

Using two indices that move through a sequence, often from both ends or at different speeds, to solve problems in O(n) instead of O(n²). Example: finding a pair summing to a target in a sorted array.

CSE-176 · What is backtracking?

Building candidate solutions incrementally and abandoning (pruning) a partial candidate as soon as it cannot lead to a valid solution. It is used for N-Queens, Sudoku, permutations and subset problems.

OOP & Design Patterns

CSE-177 · What are the SOLID principles?

Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation and Dependency Inversion. Together they guide toward classes that are cohesive, extensible and loosely coupled.

CSE-178 · What is the Liskov Substitution Principle?

Objects of a subtype must be usable wherever the base type is expected without breaking correctness. A subclass should not strengthen preconditions, weaken postconditions or throw unexpected exceptions.

CSE-179 · What is dependency injection?

Supplying an object's dependencies from outside, through the constructor, a setter or a framework, instead of creating them internally. It decouples components and makes them easy to test with mocks; Spring and Guice automate it.

CSE-180 · How do you make a Singleton thread-safe in Java?

Use an enum singleton, a static holder class (lazy and thread-safe through class loading), or double-checked locking with a volatile instance field.

class Config {
  private Config() {}
  private static class Holder { static final Config I = new Config(); }
  static Config get() { return Holder.I; }
}

CSE-181 · What is the Strategy pattern?

A behavioural pattern that defines a family of interchangeable algorithms behind a common interface and lets the client choose one at run time, such as different payment or compression methods. It replaces conditional logic with composition.

CSE-182 · What is the Decorator pattern?

A structural pattern that wraps an object to add behaviour dynamically while keeping the same interface. Java I/O streams, such as BufferedInputStream wrapping FileInputStream, are classic examples.

CSE-183 · What is the Adapter pattern?

A structural pattern that converts one interface into another that a client expects, letting incompatible classes work together, much like a power-plug adapter.

CSE-184 · What is the Builder pattern?

A creational pattern that constructs complex objects step by step through a fluent API, avoiding telescoping constructors with many optional parameters. It typically ends with build() returning an immutable object.

CSE-185 · What is the difference between Factory Method and Abstract Factory?

Factory Method lets subclasses decide which single product class to instantiate. Abstract Factory provides an interface for creating families of related products, such as all widgets for one UI theme, without naming concrete classes.

CSE-186 · What is coupling versus cohesion?

Coupling is the degree of interdependence between modules; cohesion is how closely related the responsibilities within a module are. Good design aims for low coupling and high cohesion.

CSE-187 · What is the difference between static and dynamic binding?

Static (early) binding resolves a call at compile time, as with overloaded, static, private and final methods. Dynamic (late) binding resolves at run time based on the object's actual type, as with overridden virtual methods.

CSE-188 · What is the MVC pattern?

Model-View-Controller separates an application into the Model (data and business logic), View (presentation) and Controller (handles input and updates the model). It improves separation of concerns and testability.

CSE-189 · What is the diamond problem in multiple inheritance?

When class D inherits from B and C, which both inherit from A, D gets ambiguous or duplicated members of A. C++ resolves it with virtual inheritance; Java avoids it by allowing only single class inheritance, and requires explicit override when default interface methods conflict.

Programming Languages (C/C++/Java/Python)

CSE-190 · What is the difference between pass by value and pass by reference?

Pass by value copies the argument, so changes inside the function do not affect the caller. Pass by reference passes an alias, so changes do. Java passes everything by value, including copies of object references.

CSE-191 · What is a dangling pointer?

A pointer that still holds the address of memory that has been freed or gone out of scope. Dereferencing it is undefined behaviour; setting pointers to NULL after free and using smart pointers help avoid it.

CSE-192 · What are smart pointers in C++?

RAII wrappers that manage heap object lifetimes automatically. unique_ptr has sole ownership and is move-only; shared_ptr uses reference counting for shared ownership; weak_ptr observes without owning, breaking reference cycles.

CSE-193 · What is RAII?

Resource Acquisition Is Initialization ties a resource's lifetime to an object's: the constructor acquires it (memory, file, lock) and the destructor releases it. Cleanup then happens automatically even when exceptions are thrown.

CSE-194 · What is the difference between shallow and deep copy?

A shallow copy duplicates the top-level object but shares nested objects or pointed-to memory. A deep copy recursively duplicates everything. In Python, copy.copy is shallow and copy.deepcopy is deep.

CSE-195 · What is the Global Interpreter Lock (GIL) in CPython?

A mutex that lets only one thread execute Python bytecode at a time, simplifying memory management. It limits CPU-bound multithreading, so use multiprocessing or native extensions for parallel computation; I/O-bound threads still benefit.

CSE-196 · What are Python generators?

Functions that use yield to produce values lazily, pausing and resuming state between calls. They save memory on large or infinite sequences.

def count_up(n):
    i = 0
    while i < n:
        yield i
        i += 1

CSE-197 · What are Python decorators?

Functions that take a function and return a wrapped version, adding behaviour such as logging, caching or access checks without changing the original code. They are applied with @decorator above a definition, as in @functools.lru_cache.

CSE-198 · Why is String immutable in Java?

Immutability allows string-pool sharing, safe use as HashMap keys with cached hash codes, thread safety without synchronization and security for values like file paths and class names.

CSE-199 · What is the difference between HashMap and ConcurrentHashMap in Java?

HashMap is not thread-safe and allows one null key. ConcurrentHashMap supports concurrent reads and writes with fine-grained locking and CAS operations, disallows null keys and values, and its iterators do not throw ConcurrentModificationException.

CSE-200 · What are checked and unchecked exceptions in Java?

Checked exceptions (subclasses of Exception but not RuntimeException, such as IOException) must be caught or declared with throws. Unchecked exceptions (RuntimeException and its subclasses, such as NullPointerException) need not be declared.

CSE-201 · What does the volatile keyword do in Java?

It guarantees that reads and writes of the variable go to main memory and establishes happens-before ordering, so all threads see the latest value. It does not make compound operations such as count++ atomic.

CSE-202 · What is the difference between const and #define in C/C++?

#define is a preprocessor text substitution with no type or scope. const creates a typed, scoped variable that the compiler checks and that debuggers can see; constexpr additionally guarantees compile-time evaluation.

Operating Systems

CSE-203 · What is virtual memory?

An abstraction that gives each process a large, private, contiguous address space, mapped to physical RAM and disk by the OS and MMU through paging and page tables. It enables isolation, memory overcommit and demand paging.

CSE-204 · What is a TLB?

The Translation Lookaside Buffer is a small, fast cache of recent virtual-to-physical page translations inside the MMU. A TLB hit avoids walking the page table in memory; misses add latency.

CSE-205 · What are the common page replacement algorithms?

FIFO evicts the oldest page; LRU evicts the least recently used; Optimal (Bélády's) evicts the page used farthest in the future and is a theoretical benchmark; Clock (second-chance) approximates LRU with a reference bit.

CSE-206 · What is thrashing?

When processes spend more time paging than executing because their combined working sets exceed physical memory, causing very high page-fault rates and collapsing CPU utilization. Reducing multiprogramming or adding RAM fixes it.

CSE-207 · What is the difference between internal and external fragmentation?

Internal fragmentation is wasted space inside an allocated block, such as a partially used page. External fragmentation is free memory split into small non-contiguous pieces that cannot satisfy a large request; paging eliminates it, compaction reduces it.

CSE-208 · How does Round Robin scheduling work?

Each ready process runs for a fixed time quantum and is then preempted and placed at the back of the queue. A very small quantum increases context-switch overhead; a very large one degrades toward FCFS.

CSE-209 · What is the producer-consumer problem and how is it solved?

Producers add items to a bounded buffer and consumers remove them without overflow, underflow or races. A classic solution uses a mutex plus two counting semaphores, empty (initially N) and full (initially 0).

CSE-210 · What is a race condition?

A bug where the outcome depends on the unpredictable interleaving of threads accessing shared data, such as two threads incrementing a counter without a lock. It is prevented with mutexes, atomics or immutable data.

CSE-211 · What is the critical section problem and what must a solution satisfy?

Ensuring that only one process executes code that accesses shared resources at a time. A solution must provide mutual exclusion, progress and bounded waiting.

CSE-212 · What does fork() do in Unix?

It creates a child process that is a copy of the parent, usually with copy-on-write pages. It returns 0 in the child, the child's PID in the parent and −1 on failure; exec() then often replaces the child's program image.

CSE-213 · What is the difference between preemptive and non-preemptive scheduling?

In preemptive scheduling the OS can interrupt a running process, for example when its quantum expires or a higher-priority task arrives (Round Robin, SRTF). In non-preemptive scheduling a process runs until it blocks or finishes (FCFS, non-preemptive SJF).

CSE-214 · What is starvation and how is it prevented?

Starvation is when a process waits indefinitely because others keep getting the resource, common in priority scheduling. Aging, which gradually raises the priority of waiting processes, prevents it.

CSE-215 · What is an inode?

A Unix file-system structure storing a file's metadata (owner, permissions, size, timestamps and pointers to data blocks) but not its name. Directory entries map names to inode numbers.

DBMS & SQL

CSE-216 · What are the ACID properties?

Atomicity (all or nothing), Consistency (a transaction moves the database between valid states), Isolation (concurrent transactions do not interfere) and Durability (committed changes survive crashes, usually via a write-ahead log).

CSE-217 · Why normalize a database, and what are 1NF, 2NF and 3NF?

Normalization removes redundancy and insert/update/delete anomalies. 1NF requires atomic values with no repeating groups. 2NF removes partial dependencies of non-key attributes on part of a composite key. 3NF removes transitive dependencies between non-key attributes.

CSE-218 · What is BCNF?

Boyce-Codd Normal Form requires that for every non-trivial functional dependency X → Y, X is a super key. It is stricter than 3NF, but decomposition into BCNF may not preserve all dependencies.

CSE-219 · What are the SQL transaction isolation levels?

Read Uncommitted (allows dirty reads), Read Committed (prevents dirty reads), Repeatable Read (also prevents non-repeatable reads) and Serializable (also prevents phantoms). Higher levels reduce anomalies but also concurrency.

CSE-220 · What is the difference between clustered and non-clustered indexes?

A clustered index determines the physical order of table rows, so a table has only one. A non-clustered index is a separate structure holding keys and pointers to rows, and a table can have many.

CSE-221 · How do you find the second-highest salary in SQL?

Use a subquery or a window function.

SELECT MAX(salary) FROM emp
WHERE salary < (SELECT MAX(salary) FROM emp);
-- or
SELECT DISTINCT salary FROM emp
ORDER BY salary DESC LIMIT 1 OFFSET 1;

CSE-222 · What are window functions in SQL?

Functions that compute a value over a set of rows related to the current row without collapsing them, using OVER (PARTITION BY … ORDER BY …). Examples include ROW_NUMBER, RANK, LAG and running SUM.

CSE-223 · What is the difference between UNION and UNION ALL?

UNION combines result sets and removes duplicates, which requires a sort or hash step. UNION ALL keeps all rows including duplicates and is faster.

CSE-224 · What is a stored procedure?

A precompiled set of SQL statements stored in the database and invoked by name with parameters. It reduces network round trips and centralizes logic but can tie applications to one vendor's dialect.

CSE-225 · What is a trigger?

A procedure that runs automatically before or after an INSERT, UPDATE or DELETE on a table. It is used for auditing, enforcing complex constraints or maintaining derived data.

CSE-226 · What is two-phase locking (2PL)?

A concurrency protocol in which a transaction acquires all its locks in a growing phase and releases them in a shrinking phase, never acquiring after releasing. It guarantees conflict-serializability; strict 2PL holds write locks until commit to avoid cascading aborts.

CSE-227 · What is a write-ahead log (WAL)?

A log of changes written to durable storage before the data pages themselves are modified. After a crash, the DBMS redoes committed and undoes uncommitted changes from the log, providing atomicity and durability.

CSE-228 · What is a correlated subquery?

A subquery that references columns of the outer query and is logically evaluated once per outer row, for example finding employees earning more than their department's average. It can be slow and is often rewritten as a join or window function.

Computer Networks

CSE-229 · How does the TCP three-way handshake work?

The client sends SYN with its initial sequence number x; the server replies SYN-ACK with its own sequence y and ack x + 1; the client sends ACK y + 1. Both sides then have synchronized sequence numbers and the connection is established.

CSE-230 · How is a TCP connection closed and what is TIME_WAIT?

Each side sends FIN and receives an ACK, usually four segments. The side that closes first enters TIME_WAIT for 2 × MSL so delayed segments die out and its final ACK can be retransmitted if lost.

CSE-231 · What is the difference between flow control and congestion control?

Flow control protects the receiver from being overwhelmed, using the advertised receive window. Congestion control protects the network, using a congestion window adjusted by slow start, congestion avoidance (AIMD) and fast retransmit/recovery.

CSE-232 · What is a sliding window protocol?

A scheme allowing a sender to transmit several frames or segments up to a window size before needing acknowledgements, improving link utilization. Go-Back-N retransmits from the lost frame onward; Selective Repeat retransmits only lost frames.

CSE-233 · How many usable hosts are in a /26 subnet?

A /26 leaves 32 − 26 = 6 host bits, so 2⁶ = 64 addresses, minus the network and broadcast addresses gives 62 usable hosts. Its mask is 255.255.255.192.

CSE-234 · What is NAT?

Network Address Translation rewrites private source IP addresses (such as 192.168.x.x) to a public IP at a router, usually with port translation (PAT), so many hosts share one public address. It conserves IPv4 addresses.

CSE-235 · What are the key differences between HTTP/1.1 and HTTP/2?

HTTP/1.1 is text-based and processes requests on a connection in order, causing head-of-line blocking. HTTP/2 is binary, multiplexes many streams over one TCP connection and compresses headers with HPACK. HTTP/3 runs over QUIC on UDP.

CSE-236 · What is the difference between GET and POST?

GET retrieves data, sends parameters in the URL, is safe and idempotent, and can be cached and bookmarked. POST submits data in the request body, is not idempotent and is not cached by default.

CSE-237 · What do the HTTP status code classes mean?

1xx informational, 2xx success (200 OK, 201 Created), 3xx redirection (301 Moved Permanently, 302 Found, 304 Not Modified), 4xx client error (400, 401, 403, 404, 429) and 5xx server error (500, 502, 503).

CSE-238 · What is the difference between cookies and sessions?

A cookie is data stored in the browser and sent with each request to its domain. A session stores user state on the server, with the browser holding only a session ID, usually in a cookie.

CSE-239 · What is ICMP and how do ping and traceroute use it?

ICMP carries network-layer error and diagnostic messages. Ping sends Echo Requests and measures Echo Replies. Traceroute sends packets with increasing TTL and records the routers that return "Time Exceeded" messages.

CSE-240 · What are WebSockets?

A protocol providing full-duplex, persistent communication over one TCP connection, started with an HTTP Upgrade handshake. It suits real-time apps such as chat, live dashboards and multiplayer games, avoiding repeated polling.

System Design

CSE-241 · What are the common caching strategies?

Cache-aside: the app reads the cache and loads from the DB on a miss. Write-through: writes go to cache and DB together. Write-back: writes go to the cache and are flushed later. Write-around: writes bypass the cache.

CSE-242 · What are common cache eviction policies?

LRU evicts the least recently used item, LFU the least frequently used, FIFO the oldest, and TTL-based expiry removes items after a set time. LRU is the most common default.

CSE-243 · How does the token bucket rate limiter work?

Tokens are added to a bucket at a fixed rate r up to capacity b; each request consumes one token and is rejected or delayed when the bucket is empty. It allows bursts up to b while enforcing an average rate r.

CSE-244 · What is an API gateway?

A single entry point in front of microservices that handles routing, authentication, rate limiting, request transformation, TLS termination and aggregation, simplifying clients.

CSE-245 · Why are stateless services easier to scale?

A stateless service keeps no client session data between requests, so any instance can serve any request. Instances can be added, removed or replaced freely behind a load balancer; state lives in a shared database or cache.

CSE-246 · What is replication lag and how do you handle it?

The delay before writes on the primary appear on asynchronous replicas, which can make users miss their own updates. Mitigations include reading your own writes from the primary, session stickiness, or monitoring lag and routing away from lagging replicas.

CSE-247 · What is the difference between offset and cursor pagination?

Offset pagination (LIMIT 20 OFFSET 1000) is simple but slows on large offsets and can skip or duplicate rows when data changes. Cursor (keyset) pagination uses the last seen key (WHERE id > last_id), giving stable, index-friendly performance.

CSE-248 · What is an idempotent API and why does it matter?

An operation that produces the same result whether it is applied once or many times. It makes retries after timeouts safe; for non-idempotent operations like payments, clients send an idempotency key that the server deduplicates.

CSE-249 · When should services communicate synchronously versus asynchronously?

Synchronous calls (REST, gRPC) suit requests needing an immediate answer but couple availability and latency. Asynchronous messaging (queues, events) decouples services, absorbs spikes and improves resilience, at the cost of eventual consistency and harder debugging.

CSE-250 · What is the difference between a forward proxy and a reverse proxy?

A forward proxy sits in front of clients and makes requests on their behalf, for filtering or anonymity. A reverse proxy sits in front of servers, receiving client requests for load balancing, caching and TLS termination, as Nginx often does.

CSE-251 · Estimate the average QPS for 100 million daily requests.

100,000,000 ÷ 86,400 s ≈ 1,157 requests per second on average. Peak is often planned at a multiple of this, for example 2–3×, giving roughly 2,300–3,500 QPS.

CSE-252 · What is connection pooling?

Keeping a pool of open, reusable database or network connections instead of opening a new one per request. It avoids handshake and authentication overhead and caps the load on the database.

Software Engineering & Testing

CSE-253 · What is test-driven development (TDD)?

Writing a failing test first, writing just enough code to pass it, then refactoring: the red-green-refactor cycle. It produces testable designs and a regression suite as a by-product.

CSE-254 · What are the main types of code coverage?

Statement coverage (every line executed), branch coverage (every true/false outcome taken), path coverage (every path) and condition coverage (every boolean subexpression evaluated both ways). Branch coverage subsumes statement coverage.

CSE-255 · What is the difference between a mock and a stub?

A stub returns canned data so the code under test can run. A mock also records how it was called and lets the test assert on interactions, such as "save was called once with X".

CSE-256 · What is the test pyramid?

A guideline to have many fast unit tests at the base, fewer integration tests in the middle and a small number of slow end-to-end UI tests at the top, balancing speed, cost and confidence.

CSE-257 · What is the difference between git merge and git rebase?

Merge combines branches with a merge commit and preserves the actual history. Rebase replays your commits on top of another branch, giving a linear history but rewriting commit IDs, so avoid rebasing shared public branches.

CSE-258 · What is the difference between continuous delivery and continuous deployment?

Continuous delivery keeps every change in a releasable state, with production releases triggered manually. Continuous deployment releases every change that passes the pipeline to production automatically.

CSE-259 · What is semantic versioning?

A MAJOR.MINOR.PATCH scheme: increment MAJOR for incompatible API changes, MINOR for backward-compatible features and PATCH for backward-compatible bug fixes, as in 2.4.1.

CSE-260 · What is technical debt?

The future cost of rework caused by choosing a quick or limited solution now. Like financial debt it accrues "interest" as slower development and more bugs until it is repaid through refactoring.

CSE-261 · What are equivalence partitioning and boundary value analysis?

Equivalence partitioning divides inputs into classes expected to behave alike and tests one value from each. Boundary value analysis tests at and around the edges; for an age field valid from 18 to 60, test 17, 18, 60 and 61.

CSE-262 · What is cyclomatic complexity?

A measure of the number of independent paths through code: M = E − N + 2P, where E is edges, N is nodes and P is connected components of the control-flow graph. For a single function it equals decision points + 1, and it gives the minimum tests for full branch coverage.

CSE-263 · What is the difference between smoke and sanity testing?

Smoke testing is a broad, shallow check that a new build's critical functions work at all. Sanity testing is a narrow, focused check that a specific fix or change works before deeper testing.

CSE-264 · What is trunk-based development?

A branching strategy where developers integrate small changes into the main trunk at least daily, using short-lived branches and feature flags. It reduces merge conflicts compared with long-lived branch models like GitFlow.

Computer Security

CSE-265 · What happens during a TLS handshake?

Client and server agree on the protocol version and cipher suite, the server presents its certificate, they perform a key exchange (typically ephemeral ECDHE) to derive shared session keys, and they verify the handshake with Finished messages. TLS 1.3 completes this in one round trip.

CSE-266 · How should passwords be stored?

Never in plain text or with a fast hash. Use a slow, salted, adaptive algorithm such as bcrypt, scrypt or Argon2; the unique salt defeats precomputed rainbow tables, and the work factor slows brute force.

CSE-267 · What is CSRF and how is it prevented?

Cross-Site Request Forgery tricks a logged-in user's browser into sending an unwanted request to a site that trusts its cookies. Defences include anti-CSRF tokens, SameSite cookie attributes and checking the Origin header.

CSE-268 · How does a digital signature work?

The sender hashes the message and signs the hash with their private key; the receiver verifies it using the sender's public key. It provides integrity, authentication and non-repudiation, but not confidentiality.

CSE-269 · What is a digital certificate and the role of a CA?

An X.509 certificate binds a public key to an identity, such as a domain name, and is signed by a Certificate Authority. Browsers trust it by verifying the chain up to a trusted root CA, and check validity dates and revocation.

CSE-270 · What is a JWT?

A JSON Web Token is a compact, URL-safe token of the form header.payload.signature, base64url-encoded and signed with HMAC or RSA/ECDSA. It carries claims for stateless authentication; the payload is encoded, not encrypted, so it must not hold secrets.

CSE-271 · What is OAuth 2.0?

An authorization framework that lets a third-party app obtain limited access to a user's resources via access tokens, without receiving the user's password. The authorization code flow with PKCE is recommended for most clients; OpenID Connect adds authentication on top.

CSE-272 · What is a buffer overflow?

Writing more data into a buffer than it can hold, overwriting adjacent memory such as return addresses, which attackers can exploit to run code. Mitigations include bounds checking, stack canaries, ASLR, non-executable stacks and memory-safe languages.

CSE-273 · What is the principle of least privilege?

Granting each user, process or service only the minimum permissions needed for its task, for the shortest time necessary. It limits the damage from compromise or mistakes.

CSE-274 · What is a man-in-the-middle attack?

An attacker secretly intercepts and possibly alters communication between two parties who believe they are talking directly, for example on rogue Wi-Fi or via ARP spoofing. TLS with certificate validation and HSTS defends against it.

CSE-275 · What is Diffie-Hellman key exchange?

A method for two parties to derive a shared secret over an insecure channel. Each picks a private value and exchanges gᵃ mod p and gᵇ mod p; both compute gᵃᵇ mod p. Plain DH is vulnerable to man-in-the-middle without authentication.

CSE-276 · What is the difference between an IDS and an IPS?

An Intrusion Detection System monitors traffic or hosts and raises alerts on suspicious activity. An Intrusion Prevention System sits inline and can also block or drop malicious traffic automatically.

Computer Architecture

CSE-277 · What are the cache mapping techniques?

Direct-mapped: each memory block maps to exactly one line, which is simple but suffers conflict misses. Fully associative: a block can go in any line, which is flexible but costly to search. Set-associative (n-way): a block maps to one set and any line within it, a compromise.

CSE-278 · How is average memory access time calculated?

AMAT = hit time + miss rate × miss penalty. With a 1 ns hit time, 5% miss rate and 100 ns penalty, AMAT = 1 + 0.05 × 100 = 6 ns.

CSE-279 · What are pipeline hazards?

Structural hazards occur when hardware resources conflict. Data hazards occur when an instruction needs a result not yet produced (RAW), handled by forwarding or stalls. Control hazards come from branches and are reduced with branch prediction.

CSE-280 · What is branch prediction?

Guessing the outcome of a branch before it is resolved so the pipeline keeps fetching. Static predictors use fixed rules; dynamic predictors use history, such as 2-bit saturating counters. Mispredictions flush the pipeline.

CSE-281 · What is the difference between write-through and write-back caches?

Write-through updates both cache and main memory on every write, which is simple and consistent but uses more bandwidth. Write-back updates only the cache and marks the line dirty, writing to memory on eviction, which reduces traffic.

CSE-282 · What is Amdahl's law?

Speedup = 1 / ((1 − P) + P / N), where P is the parallelizable fraction and N the number of processors. With P = 0.9 and N = 10, speedup = 1 / (0.1 + 0.09) ≈ 5.3; the limit as N → ∞ is 1 / (1 − P) = 10.

CSE-283 · How is CPU execution time calculated?

CPU time = instruction count × CPI × clock period = (IC × CPI) / clock rate. For 10⁹ instructions at CPI 2 on a 2 GHz CPU: (10⁹ × 2) / (2 × 10⁹) = 1 s.

CSE-284 · What is endianness?

The byte order of multi-byte values in memory. Big-endian stores the most significant byte at the lowest address; little-endian (x86, most ARM configurations) stores the least significant byte first. Network byte order is big-endian.

CSE-285 · What is cache coherence and the MESI protocol?

In multicore systems, cache coherence ensures all cores see a consistent value for shared memory. MESI tracks each line as Modified, Exclusive, Shared or Invalid, using bus snooping or directories to invalidate or update other copies on writes.

CSE-286 · What is the difference between pipelining and superscalar execution?

Pipelining overlaps the stages of successive instructions in one pipeline. Superscalar processors have multiple execution pipelines and can issue more than one instruction per cycle, so ideal CPI falls below 1.

CSE-287 · What is Flynn's taxonomy?

A classification by instruction and data streams: SISD (classic uniprocessor), SIMD (one instruction on many data, such as vector units and GPUs), MISD (rare) and MIMD (multicore and clusters).

CSE-288 · How are negative integers represented in two's complement?

Invert all bits of the positive value and add 1. In 8 bits, −5 is 11111011. The range for n bits is −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1, there is a single zero and addition works the same for signed and unsigned values.

Cloud & Distributed Systems

CSE-289 · What is the difference between strong and eventual consistency?

Strong consistency guarantees every read returns the most recent committed write. Eventual consistency guarantees only that replicas converge if no new writes occur, allowing stale reads in exchange for lower latency and higher availability.

CSE-290 · What is the difference between a Docker image and a container?

An image is an immutable, layered template containing the application and its file system. A container is a running instance of an image with a thin writable layer; many containers can run from one image.

CSE-291 · What is a Kubernetes Pod?

The smallest deployable unit in Kubernetes: one or more tightly coupled containers sharing a network namespace (IP and ports) and volumes, scheduled together on one node. Pods are ephemeral and usually managed by Deployments.

CSE-292 · What are the Kubernetes Service types?

ClusterIP exposes a stable internal virtual IP (the default). NodePort opens a port on every node. LoadBalancer provisions an external cloud load balancer. ExternalName maps to a DNS name.

CSE-293 · What is Infrastructure as Code (IaC)?

Defining and provisioning infrastructure through version-controlled, declarative configuration files instead of manual setup, using tools such as Terraform, CloudFormation or Pulumi. It gives repeatable, reviewable environments.

CSE-294 · What are regions and availability zones?

A region is a geographic area containing multiple availability zones; an AZ is one or more isolated data centres with independent power and networking. Deploying across AZs protects against a single data-centre failure.

CSE-295 · What is consistent hashing?

A scheme that maps both nodes and keys onto a hash ring, assigning each key to the next node clockwise. Adding or removing a node remaps only about 1/N of keys, and virtual nodes even out the load.

CSE-296 · How do distributed systems detect failed nodes?

Through heartbeats sent periodically and timeouts: a node missing heartbeats for a set period is suspected dead. Gossip protocols spread membership information, and phi-accrual detectors output a suspicion level instead of a binary verdict.

CSE-297 · What is split brain?

A failure where a network partition causes two parts of a cluster to each believe they are the active primary, accepting conflicting writes. Quorum-based election and fencing tokens prevent it.

CSE-298 · What does the quorum condition R + W > N guarantee?

With N replicas, a write acknowledged by W nodes and a read querying R nodes, R + W > N ensures the read and write sets overlap, so a read sees at least one copy of the latest write. With N = 3, R = W = 2 is common.

CSE-299 · What are Lamport clocks and vector clocks?

A Lamport clock is a counter incremented on each event and updated to max(local, received) + 1, giving an ordering consistent with causality. Vector clocks keep one counter per node and can additionally detect whether two events are concurrent.

CSE-300 · What is the difference between block, file and object storage?

Block storage exposes raw volumes to an OS, such as EBS, with low latency for databases. File storage provides a shared hierarchical file system over NFS or SMB. Object storage holds objects with metadata in a flat namespace over HTTP, such as S3, for massive scale.

Other levels: Basic · Advanced · Tricky · All Computer Science questions