Q. Find all bridges in a given graph.
asked 1xmediumGraphsTechnical2020
Ans. Use Tarjan’s DFS algorithm on an undirected graph, tracking discovery time and the lowest reachable discovery time for each vertex. For every DFS tree edge u to v, if low[v] is greater than disc[u], that edge is a bridge. Store the graph as an adjacency list. Time complexity is O(V + E).
Q. Explain the concept of virtual memory.
asked 1xmediumOperating systemsTechnical2019
Ans. Virtual memory is an operating system technique that gives each process the illusion of a large, private, continuous memory space. It maps virtual addresses to physical RAM using page tables. The key detail is paging: inactive pages can be kept on disk and loaded into RAM when needed, enabling isolation and efficient memory use.
Q. How would you design a scalable service?
asked 1xmediumScalabilityTechnical2016
Ans. I would design it as stateless application instances behind a load balancer, with data stored in scalable managed databases and caches. The most important detail is to identify the bottleneck early, usually reads, writes, or coordination, then scale that part with caching, partitioning, queues, replication, and clear service-level objectives.
Q. How does a load balancer work internally?
asked 1xmediumScalabilitySystem design2019
Ans. A load balancer accepts incoming traffic, chooses a healthy backend using a policy such as round robin, least connections, hashing or weights, then forwards the request or connection. Internally it maintains backend health, connection state and sometimes TLS or HTTP routing rules. The key detail is that unhealthy servers are removed from rotation quickly.
Q. How is DNS data maintained by DNS servers?
asked 1xmediumNetworkingTechnical2017
Ans. DNS data is maintained in a distributed, hierarchical system of authoritative DNS servers. Each server is responsible for one or more zones and stores resource records such as A, AAAA, MX and NS records. Changes are made on authoritative servers and propagated using zone transfers, while caching servers keep copies only until their TTL expires.
Q. What is a load balancer and why is it used?
asked 1xmediumScalabilityTechnical2019
Ans. A load balancer distributes incoming traffic across multiple servers so no single server is overloaded. It is used to improve availability, scalability and performance. The key detail is that it also detects unhealthy servers and stops sending traffic to them, helping the system continue serving users during failures.
Q. Write and explain the structure of an IP packet.
asked 1xmediumNetworkingTechnical2017
Ans. An IP packet consists of an IP header followed by a payload, usually a TCP, UDP, or ICMP segment. For IPv4, the header includes version, header length, service type, total length, identification, flags, fragment offset, TTL, protocol, header checksum, source address, destination address, and options. The key role is routing data between hosts.
Q. Explain loading and linking in program execution.
asked 1xmediumOperating systemsTechnical2019
Ans. Loading brings a program from storage into memory so the operating system can start executing it, while linking combines compiled code with required libraries and resolves symbol references. Linking may happen before execution as static linking, or at load time or run time as dynamic linking, which allows shared libraries and smaller executables.
Q. What is the difference between semaphore and mutex?
asked 1xmediumOperating systemsTechnical2016
Ans. A mutex is a lock for exclusive access by one thread, while a semaphore is a counter that allows a fixed number of threads to access a resource. The key difference is ownership: the thread that locks a mutex should unlock it, but a semaphore can be signalled by another thread.
Q. How would you implement the diff functionality of git?
asked 1xmediumSystem designTechnical2018
Ans. I would compare two commit trees by walking their directory tries, using object hashes to skip unchanged subtrees and identify added, deleted, renamed or modified files. For modified text files, run a Myers diff on lines to find the shortest edit script. The core structure is arrays of lines, with roughly O(ND) time.
Q. Is 172.16.23.1/23 a network address or a host address?
asked 1xmediumNetworkingOnline test2017
Ans. 172.16.23.1/23 is a host address, not a network address. A /23 mask is 255.255.254.0, so the subnet containing it runs from 172.16.22.0 to 172.16.23.255. The network address is 172.16.22.0, and usable hosts include 172.16.23.1.
Q. Design an object-oriented system (OOP design question).
asked 1xmediumOOPTechnical2020
Ans. Start by identifying core entities, their responsibilities, and how they collaborate through clear interfaces. Model each class around one reason to change, keep state private, and use composition over inheritance where possible. Define main workflows, object lifecycles, and extension points, then validate the design against requirements, edge cases, and expected scale.
Q. Which CPU scheduling algorithm can result in starvation?
asked 1xmediumOperating systemsOnline test2016
Ans. Priority scheduling can result in starvation. A low priority process may wait indefinitely if higher priority processes keep arriving and taking the CPU. Shortest Job First can also starve long jobs in a similar way. The usual fix is ageing, where a waiting process gradually gains priority over time.
Q. What happens when you type 'google.com' in a web browser?
asked 1xmediumNetworkingTechnical2019
Ans. The browser resolves google.com to an IP address using DNS, connects to that server, requests the page, receives a response, and renders it. For HTTPS, it first sets up a TCP connection and a TLS handshake, then sends an HTTP request. The browser parses HTML, fetches CSS and JavaScript, and displays the page.
Q. Find the k-th root of a number n. Mention any special cases.
asked 1xmediumBinary searchTechnical2013
Ans. Use binary search to find the integer k-th root of n, usually the greatest x such that x^k is less than or equal to n. Search from 1 to n, compare mid^k with n, and avoid overflow by stopping multiplication early. Special cases are n 0 or 1, k 1, k 0 invalid, and negative n only valid for odd k.
Q. Implement a command to query the remaining TTL for a given key.
asked 1xmediumDistributed systemsTechnical2016
Ans. Store an absolute expiry timestamp with each key, and the TTL command returns expiryTimestamp minus currentTime. Before returning, check whether the key has expired and delete it lazily if needed. Return a sentinel for missing keys and another for keys without expiry, such as Redis’s -2 and -1. Lookup is O(1).
Q. What is a man-in-the-middle attack and how can it be prevented?
asked 1xmediumNetworkingSystem design2019
Ans. A man-in-the-middle attack is when an attacker secretly intercepts and possibly changes communication between two parties who believe they are talking directly. It is prevented mainly by strong authentication and encryption, such as HTTPS with valid certificates, certificate validation, secure key exchange, VPNs on untrusted networks, and avoiding ignored browser security warnings.
Q. Explain Huffman encoding with an example and list its advantages.
asked 1xmediumCompressionTechnical2017
Ans. Huffman encoding is a lossless compression method that gives shorter binary codes to frequent symbols and longer codes to rare ones. For example, in text where A appears most, A might be 0, while rare letters get codes like 1101. It builds a prefix-free tree using frequencies. Advantages include reduced storage, no ambiguity in decoding, and optimal prefix coding for given frequencies.
Q. What are the different types of memory associated with a process?
asked 1xmediumOperating systemsTechnical2016
Ans. A process typically has code or text, initialised data, uninitialised data or BSS, heap, stack, and memory-mapped regions such as shared libraries or files. These sit in the process virtual address space. The key distinction is that the stack holds function calls and local variables, while the heap holds dynamically allocated memory.
Q. What is multiprogramming and how does it improve CPU utilization?
asked 1xmediumOperating systemsTechnical2019
Ans. Multiprogramming is the operating system technique of keeping several programs in memory at the same time and switching the CPU between them. It improves CPU utilisation because when one program waits for I/O, the CPU can run another ready program instead of staying idle. This keeps the processor busy more of the time.
Q. Which routing protocol do you consider best and how does it work?
asked 1xmediumNetworkingTechnical2017
Ans. OSPF is usually the best choice inside an enterprise network because it is open, scalable and converges quickly. It is a link-state protocol: routers advertise link costs, build the same topology database, then run Dijkstra’s shortest path algorithm to choose routes. The key detail is fast convergence after topology changes.
Q. Implement appending data to an existing file on the remote server.
asked 1xmediumFile systemsTechnical2017
Ans. Expose an append endpoint that takes file id, expected current offset, data, and an idempotency key, then the server opens the file in append mode and writes the bytes. The key detail is concurrency: hold a per-file lock or use an atomic append primitive, validate the offset, then fsync and return the new size.
Q. Moderate-level conceptual questions on Database Management Systems.
asked 1xmediumDBMSTechnical2020
Ans. Please provide the specific DBMS interview question you want answered. I can then give a direct 40 to 60 word response, starting with the answer and adding the key detail that matters most, such as the trade-off, mechanism, or complexity where relevant.
Q. Moderate-level conceptual questions on Object-Oriented Programming.
asked 1xmediumOOPTechnical2020
Ans. Object-oriented programming organises software around objects that combine data and behaviour. The key ideas are encapsulation to protect state, abstraction to expose only what matters, inheritance to reuse and specialise behaviour, and polymorphism to let different objects respond to the same interface in their own way.
Q. Which has higher time complexity among malloc, calloc, and realloc?
asked 1xmediumOperating systemsOnline test2017
Ans. realloc usually has the highest possible time complexity, because it may need to allocate a new block and copy the existing contents, which is linear in the block size. calloc is also linear because it zero-initialises memory. malloc is typically treated as constant or allocator-dependent, since it does not initialise the memory.
Q. What is the difference between a soft link and a hard link in Linux?
asked 1xmediumOperating systemsTechnical2019
Ans. A hard link is another directory entry pointing to the same inode, while a soft link, or symbolic link, is a separate file that stores a path to another file. The key difference is that a hard link still works if the original name is deleted, but a soft link breaks if its target path no longer exists.
Q. What happens when a process encounters a function in its text segment?
asked 1xmediumOperating systemsTechnical2019
Ans. When a process calls a function in its text segment, the CPU transfers execution to that function’s code address. The call instruction typically saves the return address on the stack, creates or uses a stack frame for local data, runs the function instructions, then returns control to the instruction after the call.
Q. What happens when you type a web address in a browser and press Enter?
asked 1xmediumNetworkingTechnical2017
Ans. The browser resolves the domain to an IP address, opens a connection to the server, sends an HTTP request, receives a response, and renders the page. The most important detail is DNS lookup: the human-readable address is translated into the server’s IP, after which TCP and usually TLS are used before HTTP data is exchanged.
Q. How would you reduce operation time when a database becomes very large?
asked 1xmediumDBMSTechnical2017
Ans. I would reduce operation time by indexing the columns used most in searches, joins, filters, and ordering. The key detail is to avoid full table scans, because they become very expensive as data grows. I would also review query plans, partition large tables, cache frequent reads, and archive old data.
Q. Why is the hosts file maintained on the client side and how is it used?
asked 1xmediumNetworkingTechnical2017
Ans. The hosts file is kept on the client because hostname resolution can be customised locally for that machine. It is used by the operating system’s resolver to map hostnames to IP addresses, usually before querying DNS. This allows overrides for testing, blocking, local services, or fixed internal mappings without changing external DNS.
Q. Explain TCP three-way handshake and why two-way handshake does not work.
asked 1xmediumNetworkingTechnical2019
Ans. TCP uses a three-way handshake: the client sends SYN, the server replies with SYN-ACK, and the client sends ACK. This proves both sides can send and receive and agrees initial sequence numbers. A two-way handshake cannot confirm that the server’s reply reached the client, so half-open or stale connections could be accepted.
Q. Explain mutex locks and semaphores, their differences, and applications.
asked 1xmediumOperating systemsTechnical2016
Ans. Mutex locks give exclusive access to one thread for a critical section, while semaphores control access to a finite number of resources using a counter. A mutex is owned by the thread that locks it and should be unlocked by that thread. Semaphores are used for resource pools, producer consumer queues, and signalling between threads.
Q. What is thrashing and how is it related to demand paging and segmentation?
asked 1xmediumOperating systemsTechnical2016
Ans. Thrashing is when a system spends most of its time moving pages or segments between memory and disk instead of executing processes. It is closely linked to demand paging because frequent page faults occur when working sets do not fit in RAM. With segmentation, similar excessive swapping can happen at segment level.
Q. Which data structure is used to store data on secondary (permanent) storage?
asked 1xmediumDBMSTechnical2017
Ans. A file is the data structure used to store data on secondary, permanent storage. It keeps data persistently on devices such as hard disks, SSDs, or optical media, unlike main memory which is temporary. Files are managed by the operating system through a file system.
Q. What is subnetting? What is a Network ID? Why do we use classless addressing?
asked 1xmediumNetworkingTechnical2019
Ans. Subnetting divides a larger IP network into smaller logical networks using a subnet mask or prefix length. The Network ID is the part of an IP address that identifies the subnet, found by applying the mask to the address. Classless addressing, or CIDR, is used to allocate address space more flexibly and reduce wastage and routing table size.
Q. How would you efficiently balance load across N servers using a load balancer?
asked 1xmediumScalabilityTechnical2016
Ans. Use a load balancer that tracks healthy servers and routes each request using a simple policy such as weighted round robin or least connections. The key detail is continuous health and capacity awareness, so failed or overloaded servers are removed quickly and traffic shifts without manual intervention.
Q. Given a number, find the next smallest palindrome greater than the given number
asked 1xmediumMathTechnical2017
Ans. Mirror the left half onto the right; if the result is greater than the input, it is the answer. Otherwise, increment the middle digit or digits, propagate any carry leftwards, then mirror again. The all 9s case becomes 100...001. Use a digit string or array, with O(n) time and O(n) space.
Q. List all files on the server, including hidden files, in a tree-like structure.
asked 1xmediumFile systemsTechnical2017
Ans. Use a recursive depth first traversal from the chosen root directory, including names that start with a dot, and print each entry with indentation to form the tree. The key detail is to handle permissions and symbolic links safely to avoid errors or cycles. Time is O(n); space is O(h) when streaming.
Q. How would you detect and handle backend servers that stop responding to clients?
asked 1xmediumReliabilitySystem design2019
Ans. Detect unresponsive backends with client timeouts and active health checks from the load balancer. Mark a server unhealthy after a small failure threshold, stop sending new traffic to it, and retry safe requests elsewhere. The key detail is avoiding retry storms by using backoff, circuit breakers, and idempotency-aware retries.
Q. Why are B-trees preferred over normal binary search trees for database indexing?
asked 1xmediumDBMSTechnical2018
Ans. B-trees are preferred because they keep data shallow and reduce disk reads, which is the main cost in database indexing. Each node stores many keys and children, matching disk or page sizes well. This gives high fan-out, balanced height, and predictable logarithmic search, insert, and delete performance.
Q. Explain the Android ecosystem and how you would build an Android app from scratch
asked 1xmediumMobileTechnical2017
Ans. The Android ecosystem includes the Linux-based OS, Android Runtime, framework APIs, Google Play services, OEM devices, app stores, and developer tools like Android Studio. From scratch, I would define requirements, choose Kotlin, set up Gradle, design screens with Jetpack Compose or XML, implement architecture, data storage, networking, testing, signing, and release through Play Console.
Q. If you had to build a database index, which data structure would you use and why?
asked 1xmediumDBMSTechnical2018
Ans. I would use a B+ tree for a general database index because it keeps keys sorted and gives efficient lookups, inserts, deletes and range scans. Its high branching factor keeps the tree shallow, which reduces disk or page reads. For exact-match only workloads, a hash index can be faster, but it lacks range queries.
Q. Send only those lines of a file that contain a specified substring to the client.
asked 1xmediumStringsTechnical2019
Ans. Read the file line by line, test each line for the specified substring, and send only matching lines to the client as they are found. Use a fixed buffer or line string, not a full file load. This keeps memory usage low. Time complexity is linear in the file size, plus substring matching cost.
Q. Explain concurrency in Java including synchronized methods and synchronized blocks
asked 1xmediumJavaTechnical2017
Ans. Concurrency in Java means multiple threads making progress at the same time, sharing CPU time and sometimes shared data. The key issue is protecting mutable shared state. A synchronized method locks on the object instance, or the class for static methods. A synchronized block locks only the chosen object, allowing smaller, more precise critical sections.
Q. Discuss infrastructure planning and load balancing strategies in distributed systems.
asked 1xmediumDistributed systemsManagerial2016
Ans. Infrastructure planning sizes capacity, regions, networks, storage, failover and observability against expected traffic, growth and failure modes. Load balancing then spreads requests across healthy instances using algorithms such as round robin, least connections or latency based routing. The key detail is designing for redundancy and autoscaling, so failures degrade service rather than taking it down.
Q. Explain the complete DNS message exchange process to convert a URL into an IP address.
asked 1xmediumNetworkingTechnical2019
Ans. The browser extracts the hostname from the URL and asks the OS DNS resolver for its IP address. The resolver checks local cache, then queries a recursive DNS server. If needed, it asks root servers, then TLD servers, then the authoritative server. The IP address is returned through the chain and cached using its TTL.
Q. On client termination using Ctrl+C, print the total number of bytes sent to the server.
asked 1xmediumOperating systemsTechnical2016
Ans. Maintain a running counter of bytes successfully sent, increasing it by the return value of each send call. Install a SIGINT handler for Ctrl+C that sets a volatile sig_atomic_t flag, then let the main loop stop, close the socket, and print the counter. Use one 64-bit integer. Overhead is O(1) per send.
Q. How would you design a chat application where there is no central server to store messages?
asked 1xmediumDistributed systemsSystem design2017
Ans. Use a peer-to-peer design where clients discover each other, establish encrypted connections, and store message history locally on each device. The key detail is offline delivery: without a central store, messages need store-and-forward through trusted peers, a DHT, or must wait until both users are online. Use end-to-end encryption throughout.
Q. Why does the OSI model have multiple layers and what are the functionalities of each layer?
asked 1xmediumNetworkingTechnical2019
Ans. The OSI model uses layers to separate networking responsibilities, making systems easier to design, standardise, troubleshoot and replace independently. Physical sends raw bits, Data Link handles frames and MAC addressing, Network routes packets, Transport provides end-to-end delivery, Session manages connections, Presentation handles encoding and encryption, and Application provides network services to user applications.
Q. How is a database implemented in Android and what is a Content Provider and Content Resolver?
asked 1xmediumDBMSTechnical2017
Ans. Android commonly implements local databases using SQLite, usually through Room or SQLiteOpenHelper to create, upgrade and query tables. A Content Provider is a component that exposes app data through standard URI based CRUD operations. A Content Resolver is the client side API used by apps to query, insert, update or delete data through that provider.
Q. Find the maximum sum path between any two leaf nodes in a binary tree represented as an array.
asked 1xmediumTreesOnline test2016
Ans. Use a postorder DFS on the implicit array tree and keep a global best leaf-to-leaf sum. For each index, compute the maximum sum from that node down to any leaf, using children at 2i+1 and 2i+2. Update the global answer only when both children exist. Time is O(n), space is O(h).
Q. Implement a client-server application using TCP to transfer a text file from client to server.
asked 1xmediumNetworkingTechnical2016
Ans. Create a TCP server that binds to a port, listens, accepts one client, then reads bytes from the socket and writes them to a new text file until EOF. The client connects to the server, reads the source file in fixed-size byte buffers, and sends each buffer. Use a byte array buffer. Time complexity is O(n).
Q. Boggle: Given a dictionary and a character board, find all possible words present in the board.
asked 1xmediumStringsOnline test2016
Ans. Build a trie from the dictionary, then run DFS with backtracking from every board cell to follow valid trie prefixes and collect completed words. Mark cells visited during the current path to avoid reuse. This prunes impossible searches early. Time is roughly proportional to explored trie-valid paths, worst case exponential in word length.
Q. What happens when your system (172.16.1.22) communicates with another system at IP 172.16.1.23?
asked 1xmediumNetworkingTechnical2016
Ans. The source host sees 172.16.1.23 as local, so it sends the packet directly on the LAN rather than to the default gateway. If it does not know the destination MAC address, it uses ARP to ask who has 172.16.1.23, then encapsulates the IP packet in an Ethernet frame to that MAC.
Q. Check whether two strings are anagrams of each other without using any additional data structure
asked 1xmediumStringsTechnical2017
Ans. Sort both strings in place and then compare them character by character. If their lengths differ, they cannot be anagrams. After sorting, anagrams will have exactly the same characters in the same order. This uses no extra data structure if in-place sorting is allowed, with O(n log n) time.
Q. Given two devices with specific IP addresses, how would you connect them so they can communicate?
asked 1xmediumNetworkingTechnical2017
Ans. Connect them to the same network, such as the same switch or Wi-Fi, and configure their IP addresses so they are in the same subnet. The key detail is subnet compatibility: if they share a subnet, they can talk directly using ARP; if not, they need a router and correct default gateways.
Q. Design a client that shards key-value data across two server instances running on different ports.
asked 1xmediumDistributed systemsTechnical2016
Ans. Use a client-side router that hashes each key and sends the request to one of the two server addresses based on the hash result. Store the two host and port entries in a small array, choose index hash(key) modulo 2, and use the same rule for reads, writes, and deletes. Lookup is constant time.
Q. Given a sequence of serves in a tennis game (A or B), find all possible combinations of T (serves to win a set) and S (sets to win the match) such that the sequence is valid and results in a clear winner.
asked 1xmediumLogical reasoningTechnical2019
Ans. No numeric combinations can be found without the actual A/B sequence. The method is to try every T from 1 to n, simulate sets until either player reaches T serves, then reset. A pair is valid only if the sequence ends exactly after a set, the last set winner is the overall winner, and S is their set count.
Q. Two piles contain m red plates and n black plates. A move consists of taking any number of red plates, any number of black plates, or an equal number of red and black plates. Players alternate turns and the player who cannot move loses. Given m and n, determine if the starting player will win or lose assuming optimal play.
asked 1xmediumGame theoryTechnical2014
Ans. The starting player loses exactly at Wythoff positions. Let a = min(m,n), b = max(m,n), and d = b - a. If a = floor(dφ), where φ = (1 + √5) / 2, the position is losing. Otherwise it is winning. These positions are precisely those no move can reach another losing position.
Q. What is the difference between TCP and UDP?
asked 1xeasyNetworkingTechnical2019
Ans. TCP is connection-oriented and reliable, while UDP is connectionless and faster but does not guarantee delivery. TCP orders packets, retransmits lost data, and provides flow and congestion control. UDP sends datagrams with minimal overhead, so it is useful for real-time traffic like video calls, gaming, DNS, or streaming where some loss is acceptable.
Showing 60 of 252 questions. Ranked by how often the same question came back across interviews.