Q. What is the difference between Mutex and Semaphore?
asked 2xeasyOperating systemsTechnical2021
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. Explain the difference between a process and a thread.
asked 2xeasyOperating systemsManagerial, Technical2019
Ans. A process is an independent running program with its own memory space, while a thread is a smaller unit of execution within a process that shares that process’s memory. Processes are more isolated and cost more to create or switch between. Threads are lighter, but shared memory makes synchronisation and race conditions important.
Q. Explain how DNS lookup works
asked 1xmediumNetworkingTechnical2023
Ans. DNS lookup translates a domain name into an IP address by querying DNS servers, usually starting with a local cache or resolver. If not cached, the resolver asks root servers, then the relevant top-level domain server, then the authoritative server for the domain. The result is returned and cached for its TTL.
Q. Find all bridges in a 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 how a load balancer works
asked 1xmediumScalabilitySystem design2019
Ans. A load balancer sits in front of multiple servers and distributes incoming traffic across them so no single server is overwhelmed. It chooses a backend using rules such as round robin, least connections, or latency. The most important detail is health checking, so failed or slow servers are removed from rotation.
Q. Traverse a matrix in spiral order
asked 1xmediumArraysTechnical2023
Ans. Traverse the matrix by maintaining four boundaries: top, bottom, left and right. Repeatedly visit the top row, right column, bottom row and left column, then move the boundaries inward. Store values in an output list. Stop when boundaries cross. This runs in O(mn) time and uses O(1) extra space besides the result.
Q. Explain Semaphores and their properties
asked 1xmediumOperating systemsTechnical2023
Ans. A semaphore is a synchronisation primitive that controls access to shared resources using an integer counter. Threads call wait to decrement it and may block if the value is unavailable, and signal to increment it and wake a waiting thread. Key properties are atomic operations, mutual exclusion or resource counting, and possible blocking.
Q. Explain Shared locks vs Exclusive locks
asked 1xmediumDBMSTechnical2023
Ans. Shared locks allow multiple transactions or threads to read the same resource at the same time, while exclusive locks allow only one transaction or thread to modify it. The key point is compatibility: shared locks can coexist with other shared locks, but an exclusive lock conflicts with both shared and exclusive locks to prevent inconsistent updates.
Q. Explain and implement Kadane’s Algorithm
asked 1xmediumArraysTechnical2023
Ans. Kadane’s Algorithm finds the maximum sum of a contiguous subarray in linear time. It scans the array while keeping the best sum ending at the current position and the best sum seen overall. At each element, either extend the previous subarray or start a new one. It runs in O(n) time and O(1) space.
Q. Explain indexing in DBMS and how it works
asked 1xmediumDBMSTechnical2021
Ans. Indexing in a DBMS is a way to speed up data retrieval by keeping a separate data structure that maps column values to the locations of matching rows. Most indexes use B-trees or similar structures, allowing searches without scanning the whole table. The trade-off is extra storage and slower inserts, updates, and deletes.
Q. Explain virtual memory and its advantages
asked 1xmediumOperating systemsTechnical2019
Ans. Virtual memory is a memory management technique that gives each process the illusion of a large, private, continuous address space, while the operating system maps it to physical RAM and disk. Its main advantages are process isolation, simpler programming, efficient sharing, and the ability to run programs larger than available RAM using paging.
Q. Explain deadlocks and methods to avoid them
asked 1xmediumOperating systemsTechnical2019
Ans. A deadlock is when two or more processes wait forever because each holds a resource another needs. It requires mutual exclusion, hold and wait, no preemption, and circular wait. Avoid it by breaking one condition, commonly using a fixed lock ordering, acquiring all resources upfront, using timeouts, or applying Banker’s algorithm for safe allocation.
Q. Explain the TCP three-way handshake process
asked 1xmediumNetworkingTechnical2023
Ans. The TCP three-way handshake establishes a reliable connection using SYN, SYN-ACK, and ACK messages. The client sends a SYN with its initial sequence number, the server replies with SYN-ACK and its own sequence number, then the client sends ACK. The key detail is that both sides synchronise sequence numbers before data transfer.
Q. How and why is Fourier Transform used in MFCC?
asked 1xmediumMachine learningManagerial2019
Ans. Fourier Transform is used in MFCC to convert each short, windowed speech frame from the time domain into its frequency spectrum. Usually an FFT computes the power spectrum, which is then passed through Mel filter banks. This matters because MFCCs model the spectral envelope of speech, where phonetic information is most visible.
Q. Print each word of a string in vertical fashion
asked 1xmediumStringsTechnical2021
Ans. Split the string into words, then print characters column by column: for each index from 0 to the maximum word length, take that character from every word, or a space if the word is shorter. Store each row as a string and trim trailing spaces. Time complexity is O(n), where n is total characters.
Q. Solve medium-level DSA problems based on arrays
asked 1xmediumArraysTechnical2024
Ans. I solve medium array problems by first identifying the pattern, such as two pointers, sliding window, prefix sums, sorting, or hashing. The key detail is to reduce repeated work by storing useful state, like frequencies or running sums. Most medium array solutions should aim for O(n) or O(n log n) time.
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. Design a chatting application similar to WhatsApp.
asked 1xmediumScalable systemsSystem design2023
Ans. Use mobile clients connected by WebSockets to regional chat gateways, backed by messaging services, queues, user/device storage, media storage, and push notifications. The key detail is reliable delivery: assign each message an id, persist it before acknowledgement, fan it out to recipient devices, track sent, delivered and read states, and retry from queues when users reconnect.
Q. Explain what a load balancer is and why it is 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. Difference between soft link and 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. Arrange given numbers to form the biggest possible number
asked 1xmediumSortingTechnical2021
Ans. Convert the numbers to strings and sort them with a custom comparator: for two strings x and y, put x before y if xy is larger than yx. Then concatenate the sorted strings. Use an array or list of strings. Sorting dominates the cost, taking O(n log n) comparisons, with extra string comparison cost. Return 0 if all values are zero.
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. Given the rank array and N, reconstruct the original array
asked 1xmediumArraysTechnical2021
Ans. Reconstruct the permutation by treating the rank array as a Lehmer code. Keep the unused values 1 to N in sorted order, then for each rank from left to right pick the rank[i] plus 1-th smallest unused value and remove it. Use an order statistic tree or Fenwick tree for O(N log N).
Q. Merge all overlapping intervals given a list of intervals.
asked 1xmediumArraysTechnical2019
Ans. Sort the intervals by start time, then scan them and keep a result list of merged intervals. For each interval, compare its start with the end of the last interval in the result. If it overlaps, extend that end; otherwise append it. Sorting dominates, so time is O(n log n) and space is O(n).
Q. What is database indexing and how does it work internally?
asked 1xmediumDBMSTechnical2019
Ans. Database indexing is a way to speed up reads by storing an extra data structure that maps column values to the locations of matching rows. Internally, most databases use B-trees or B+ trees, which keep keys sorted and allow logarithmic lookup, range scans, and ordered access, at the cost of extra storage and slower writes.
Q. Object-Oriented Design question (design-level OOP problem).
asked 1xmediumOOPTechnical2020
Ans. Model the domain with clear entities, responsibilities, and relationships, then define the public behaviours before fields or implementation details. Use interfaces for variation, composition for shared behaviour, and keep classes small. The most important detail is showing how the design handles change, such as adding a new type without rewriting existing logic.
Q. Explain man-in-the-middle attack and how it can 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. Why is composition preferred over inheritance in most cases?
asked 1xmediumDesign principlesTechnical2019
Ans. Composition is preferred because it gives more flexible, loosely coupled designs than inheritance. With composition, an object uses other objects for behaviour, so parts can be replaced, tested, or reused independently. Inheritance creates tight parent child coupling and can make changes risky because subclasses depend on base class behaviour and hierarchy.
Q. Write SQL queries involving GROUP BY, JOINs, and subqueries.
asked 1xmediumSQLTechnical2019
Ans. I would use JOINs to bring related tables together, GROUP BY to aggregate by the required key, and subqueries to filter or compare against derived results. For example, join orders to customers, group by customer, calculate total spend, then use a subquery to keep only customers above the average total.
Q. Write SQL queries to retrieve data based on given conditions
asked 1xmediumSQLTechnical2024
Ans. Use SELECT to choose columns, FROM to choose tables, WHERE to filter rows, JOIN to combine related tables, GROUP BY for aggregation, HAVING to filter groups, and ORDER BY to sort results. The key detail is applying row conditions in WHERE and aggregate conditions in HAVING, because they run at different stages.
Q. Explain functionalities and protocols of different OSI layers
asked 1xmediumNetworkingTechnical2019
Ans. OSI has seven layers: physical transmits bits, data link handles frames and MAC, network routes packets using IP, transport provides TCP or UDP delivery, session manages conversations, presentation formats and encrypts data, and application provides user protocols like HTTP, DNS, SMTP and FTP. The key idea is encapsulation, where each layer adds its own header.
Q. How would you scale this chat box system to production level?
asked 1xmediumScalabilityTechnical2019
Ans. I would scale it by making chat servers stateless behind a load balancer, using WebSockets for live delivery, and a pub-sub layer like Kafka or Redis Streams to route messages between servers. The most important detail is separating connection handling from durable message storage, so reconnects, retries and horizontal scaling remain reliable.
Q. Explain Cookies and Sessions and their use in web applications
asked 1xmediumNetworkingTechnical2023
Ans. Cookies are small pieces of data stored in the user’s browser, while sessions store user state on the server and usually identify it using a session ID kept in a cookie. Web applications use them for login state, preferences, baskets, and tracking. The key point is that sensitive data should stay server side.
Q. Explain what happens when you type www.google.com in a browser
asked 1xmediumNetworkingSystem design2023
Ans. The browser resolves www.google.com to an IP address, connects to it, requests the page, receives a response, and renders it. The key detail is DNS lookup first, often using caches. Then the browser opens a TCP connection, negotiates TLS for HTTPS, sends an HTTP request, downloads resources, and builds the page.
Q. Given an array, return the product of all elements except self
asked 1xmediumArraysTechnical2023
Ans. Use two passes with a result array: first store each index’s prefix product, then multiply by the suffix product while scanning from the right. This avoids division and handles zeros correctly. The data structure is the output array plus two running products. Time complexity is O(n), with O(1) extra space excluding the output.
Q. Explain virtual table (vtable) and virtual table pointer (vptr).
asked 1xmediumOOPTechnical2017
Ans. A vtable is a compiler-created table of function addresses for a class’s virtual functions, and a vptr is a hidden pointer in each polymorphic object that points to that table. When a virtual function is called through a base pointer or reference, the vptr selects the correct function at runtime.
Q. Find a tour that visits all petrol pumps (circular tour problem).
asked 1xmediumGreedyOnline test2019
Ans. Use a greedy single pass. Track current surplus fuel from a tentative start, and total surplus over all pumps. If current surplus becomes negative at pump i, no earlier pump in that segment can start the tour, so set start to i + 1 and reset current surplus. If total surplus is non-negative, return start, otherwise no tour exists.
Q. Explain search and insertion operations in linear probing hashing.
asked 1xmediumHashingTechnical2019
Ans. In linear probing, search and insertion start at the key’s hash index and then check the next table slots one by one, wrapping around if needed. Search stops when the key is found or an empty slot proves it is absent. Insertion places the key in the first empty or deleted slot. Average time is O(1), worst case O(n).
Q. Construct a binary tree given its inorder and postorder traversals.
asked 1xmediumTreesOnline test2020
Ans. Take the last value in postorder as the root, find it in inorder, and recursively build the left and right subtrees from the two inorder partitions. The key detail is to process postorder backwards, building the right subtree before the left. Use a hash map for inorder indices. Time is O(n), space is O(n).
Q. Convert number M to N using the minimum number of given operations.
asked 1xmediumGraphsTechnical2019
Ans. Use breadth first search, treating each reachable number as a node and each allowed operation as an edge of cost one. Start from M, generate valid next numbers, and stop when N is first reached. Store visited numbers to avoid loops. Time is O(V plus E) over the explored state space.
Q. Explain dynamic binding and write a code example to demonstrate it.
asked 1xmediumOOPTechnical2017
Ans. Dynamic binding means the method to run is chosen at runtime based on the actual object type, not the reference type. For example, a Shape reference can point to a Circle or Square, and calling draw runs the correct overridden method. This enables polymorphism. Method dispatch is typically constant time using a virtual table.
Q. What is the significance of Delta and Double Delta features in MFCC?
asked 1xmediumMachine learningManagerial2019
Ans. Delta and Double Delta features add temporal dynamics to MFCCs, capturing how the spectral shape changes over time. Delta represents the first-order change, similar to velocity, while Double Delta represents the second-order change, similar to acceleration. They improve speech recognition by including context and transitions between neighbouring frames, not just static spectral information.
Q. Write an SQL query to find the nth largest element using any method.
asked 1xmediumSQLTechnical2023
Ans. Use a query that selects the distinct values, sorts them in descending order, skips the first n minus 1 rows, and returns the next row. In MySQL or PostgreSQL this is done with ORDER BY descending plus LIMIT 1 and OFFSET n minus 1. Sorting dominates the cost, usually O(m log m).
Q. Check whether a given string is an interleaving of two other strings.
asked 1xmediumDynamic programmingOnline test2019
Ans. Use dynamic programming to check if the target can be formed by preserving the order of characters from both strings. First ensure the lengths add up. Let dp[i][j] mean the first i and j characters can form the first i plus j target characters. Fill it by matching from either string. Time is O(mn), space can be O(n).
Q. Explain TCP 3-way handshake and why 2-way handshake is not sufficient
asked 1xmediumNetworkingTechnical2019
Ans. TCP uses a three way handshake: client sends SYN, server replies SYN-ACK, and client sends ACK. This proves both sides can send and receive, agrees initial sequence numbers, and establishes the connection state. A two way handshake is not sufficient because the server cannot know its SYN-ACK reached the client, causing half-open or stale connections.
Q. Find the length of the maximum non-decreasing subsequence in an array
asked 1xmediumDynamic programmingTechnical2023
Ans. Use a longest non-decreasing subsequence algorithm: maintain a tails array where tails[i] is the smallest possible ending value of a non-decreasing subsequence of length i + 1. For each number, place it after the last value less than or equal to it using upper bound. The tails length is the answer, in O(n log n) time.
Q. Implement a basic UDP client and echo server using socket programming
asked 1xmediumNetworkingTechnical2024
Ans. Create a UDP server socket, bind it to a port, receive datagrams with the sender address, and send the same bytes back to that address. The client creates a UDP socket, sends a message to the server address, then waits for the echoed reply. Use a byte buffer. Each request is O(n) in message size.
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. Explain your test strategy and test plan for a medium-scale application
asked 1xmediumSoftware testingTechnical2024
Ans. I would use a risk-based test strategy covering unit, integration, API, UI, performance, security and regression tests. The plan would define scope, test environments, data, responsibilities, entry and exit criteria, and automation targets. The most important detail is prioritising critical user journeys and business risks before testing lower-impact edge cases.
Q. Why is transfer learning used, and what are its benefits and drawbacks?
asked 1xmediumMachine learningManagerial2019
Ans. Transfer learning is used to reuse knowledge from a model trained on a large source task for a related target task with less data. It can reduce training time, improve accuracy, and work well with limited labelled data. Drawbacks include negative transfer, bias from the source data, and poor fit if tasks differ too much.
Q. Write an SQL query to find the second largest element using subqueries.
asked 1xmediumSQLTechnical2023
Ans. Use a subquery to find the maximum value, then find the maximum value smaller than that. In SQL terms, select the maximum element from the table where the element is less than the maximum element returned by an inner subquery. This handles duplicates correctly if you mean the second distinct largest value.
Q. Explain how you handled complex UI scenarios and frames in UI automation
asked 1xmediumSoftware testingTechnical2024
Ans. I handled complex UI scenarios by breaking them into stable page objects and using explicit waits, robust locators, and clear state checks. For frames, I identified the correct iframe, switched context before interacting, and always switched back afterwards. The key detail was isolating frame handling in reusable helper methods to avoid flaky tests.
Q. Given a very large array, which sorting algorithm would you use and why?
asked 1xmediumSortingTechnical2017
Ans. I would use merge sort, or external merge sort if the array cannot fit in memory. It has guaranteed O(n log n) time and works well on large data because it splits the input and merges sorted runs sequentially. If memory is tight, the runs can be stored and merged from disk.
Q. Design an API to track total number of calls received in the last 5 minutes
asked 1xmediumApi designSystem design2023
Ans. Use a rolling time-window counter: every received call records its timestamp, and GET /calls/count returns how many timestamps are within the last 5 minutes. Store timestamps in a queue or ring buffer, evict entries older than now minus 300 seconds on each write or read. Writes are O(1), reads are O(k) evicted.
Q. Given 51 cards from a standard deck of 52, find the missing card with minimum memory usage and discuss iterations and comparisons required.
asked 1xmediumLogical reasoningTechnical2018
Ans. Encode each card as a unique number 0 to 51. XOR all 52 possible codes, then XOR the 51 given card codes. Equal values cancel, leaving the missing card’s code. This uses one accumulator, so constant memory. It needs 51 input iterations, plus 52 setup iterations if not precomputed, and no comparisons.
Q. Draw a square with double the area of a given square such that the original square is fully covered and its corners lie on the edges of the new square.
asked 1xmediumGeometryTechnical2018
Ans. Draw the new square at 45 degrees to the original. Through each corner of the given square, draw a line parallel to one of its diagonals, choosing the four lines so they enclose it. These lines form a larger square. Its side equals the original diagonal, so its area is s² + s² = 2s².
Q. Two ducks move in opposite directions along the circumference of a circular pond at speeds 10 km/hr and 18 km/hr, starting from diametrically opposite points. Find the time of their second meeting given the radius of the pond is 7 km.
asked 1xmediumTime speed distanceTechnical2018
Ans. The second meeting is after 33/14 hours, or about 2 hours 21 minutes. For such problems, use relative speed. The circumference is 2πr = 44 km. They start half a circumference apart, so meetings occur after closing 22 km, then another 44 km. Total for second meeting is 66 km at 28 km/hr.
Q. Two people A and B stand on the diameter of a circle of diameter 7. A moves towards B at 10 m/s and B moves towards A at 8 m/s, both moving only along the circumference. After how much time will they meet for the second time?
asked 1xhardLogical reasoningTechnical2017
Ans. The second meeting occurs after 7π/12 seconds, about 1.83 seconds. Use arc distance, not diameter. The first gap is half the circumference, 7π/2 metres, and closing speed is 18 m/s. First meeting takes 7π/36 seconds. Each later meeting needs one full circumference more in relative motion, so add 7π/18.
Q. Given a rectangle with diagonal corners at (0,0) and (l,b). Inside it are N points representing centers of circles with radius R (circles may overlap and extend outside the rectangle). Starting at (0,0), you can move in any direction without leaving the rectangle or touching any circle. Determine whether you can reach (l,b).
asked 1xhardGeometryTechnical2021
Ans. Treat circles as closed obstacles. Union circles with centre distance at most 2R, and record which sides each component touches: x<=R, l-x<=R, y<=R, b-y<=R. If start or finish is inside a circle, fail. A component touching left-bottom, top-right, left-right, or bottom-top forms a continuous barrier, so fail. Otherwise succeed.
Q. Logical reasoning questions testing analytical thinking
asked 1xeasyLogical reasoningOnline test2021
Ans. Identify the rule or relationship before trying to answer. Separate facts from assumptions, look for patterns, categories, sequences, cause and effect, or exclusions. Work step by step, eliminate impossible options, and check that the remaining answer fits every condition. If stuck, test simple examples rather than guessing.
Showing 60 of 215 questions. Ranked by how often the same question came back across interviews.