Q. What is the difference between a process and a thread?
asked 5xeasyOperating systemsTechnical2019-2024
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. Find the Longest Common Subsequence between two strings
asked 3xmediumDynamic programmingOnline test, Technical2020-2021
Ans. Use dynamic programming to build the longest common subsequence length for every pair of prefixes of the two strings. Store results in a two-dimensional table where a character match adds one from the diagonal, otherwise take the maximum of left and top. Backtrack through the table to reconstruct the subsequence. Time is O(nm), space is O(nm).
Q. What is the difference between threads and processes?
asked 3xeasyOperating systemsTechnical2016-2024
Ans. A process is an independent running program with its own memory space, while a thread is a smaller unit of execution inside a process that shares that process’s memory. Processes are more isolated but heavier to create and switch between. Threads are lighter and communicate easily, but shared memory makes bugs and races more likely.
Q. Find the maximum root-to-leaf path sum in a binary tree
asked 2xmediumTreesTechnical2021
Ans. Use depth first search from the root, carrying the running sum, and update the answer only when a leaf is reached. The key detail is that a valid path must end at a leaf, so do not stop at missing children. Visit each node once, using the recursion stack, with O(n) time and O(h) space.
Q. Explain the differences between Java and C++.
asked 2xeasyOOPTechnical2019-2023
Ans. C is a procedural, compiled, low-level language with manual memory management, while Java is object-oriented, runs on a virtual machine, and uses garbage collection. C gives more control over memory and hardware, so it is common in systems programming. Java favours portability, safety, and large application development through its standard runtime.
Q. Perform level order traversal of a binary tree
asked 2xeasyTreesOnline test2024
Ans. Use breadth first search with a queue. Put the root in the queue, then repeatedly remove the front node, visit it, and add its left and right children if they exist. This visits nodes level by level from left to right. The time complexity is O(n), and the space complexity is O(w), where w is the maximum width.
Q. Delete a node in a linked list without having access to the head pointer
asked 2xeasyLinked listsTechnical2020
Ans. Copy the data from the next node into the given node, then link the given node to the next node’s next pointer, effectively removing the next node. This works in O(1) time and O(1) space, but it cannot be done if the given node is the tail.
Q. Explain the difference between call by value and call by reference with an example
asked 2xeasyOOPTechnical2024
Ans. Call by value passes a copy of the variable, while call by reference passes access to the original variable. If a function changes a call by value parameter, the caller’s variable is unchanged. With call by reference, the caller’s variable can change, such as a swap function actually swapping two original numbers.
Q. Write a complex SQL query
asked 1xmediumSQLTechnical2019
Ans. I would write a query that joins orders, customers, and payments, groups by customer, filters recent orders, and uses a window function to rank customers by total spend. The key detail is to aggregate before ranking, so each customer has one row. With indexed join and filter columns, performance is mainly driven by scan and sort cost.
Q. Design a parking lot system
asked 1xmediumObject designSystem design2019
Ans. Design it with levels, parking spots by type, vehicles, tickets, gates and a payment service. Keep an in-memory or database-backed index of available spots per spot type, so entry can allocate the nearest valid spot quickly and exit can free it, calculate fees from the ticket, and update occupancy atomically.
Q. Design the Google Play Store
asked 1xmediumScalable systemsTechnical2020
Ans. Design it as services for catalogue, search, recommendations, reviews, payments, developer publishing, entitlement, and downloads, backed by relational metadata, object storage for APKs or bundles, and a CDN. The key detail is versioned, signed artefacts with staged rollout rules, so clients securely fetch the right app build for device, region, and user entitlement.
Q. Design a train booking system
asked 1xmediumScalable systemsTechnical2021
Ans. Design it with search, booking, payment, ticketing and notification services over train, schedule, fare and seat inventory data. The key detail is preventing double booking: lock or reserve seats with a short expiry during payment, then confirm atomically after payment succeeds. Use caches for search, but keep inventory in a strongly consistent store.
Q. Fibonacci Minimum Jumps problem
asked 1xmediumDynamic programmingOnline test2020
Ans. Use BFS to find the minimum number of Fibonacci jumps from position -1 to the bank at N. Precompute Fibonacci numbers up to N + 1, then explore reachable leaf positions and the bank with a queue and visited array. Each level is one jump. Time complexity is O(N log N).
Q. Implement a Trie data structure.
asked 1xmediumTreesTechnical2016
Ans. Implement a Trie using nodes that store a map from character to child node and a boolean marking the end of a word. To insert or search, walk character by character, creating nodes for insert and failing early for search if a child is missing. Insert, search, and prefix lookup take O(L) time, where L is the string length.
Q. Remove a loop from a linked list.
asked 1xmediumLinked listsTechnical2021
Ans. Use Floyd’s slow and fast pointers to detect the loop, then find the loop start and set the last node in the loop to null. After detection, move one pointer to the head and advance both one step until they meet. Then traverse the loop to find its previous node. Time is O(n), space is O(1).
Q. Merge overlapping sorted intervals
asked 1xmediumArraysOnline test2020
Ans. Scan the sorted intervals once, keeping the current merged interval and extending it while the next interval overlaps. If the next start is greater than the current end, add the current interval to the result and start a new one. Use a list for output. Time complexity is O(n), with O(n) extra space.
Q. Design a Parking Management System.
asked 1xmediumScalable systemsSystem design2014
Ans. Design it as a service that tracks car parks, floors, bays, vehicle entries, payments and exits, with real-time bay availability. Gate devices call APIs to allocate the nearest suitable bay, create a ticket, calculate fees on exit and update occupancy atomically. The most important detail is preventing double allocation using transactions or distributed locks.
Q. Explain Paging in Operating Systems
asked 1xmediumOperating systemsTechnical2021
Ans. Paging is a memory management technique where a process’s virtual address space is split into fixed-size pages, and physical memory is split into same-size frames. The OS maps pages to frames using a page table, allowing non-contiguous allocation. The key benefit is avoiding external fragmentation while supporting virtual memory.
Q. Find the median of an unsorted array
asked 1xmediumArraysTechnical2013
Ans. Use Quickselect to find the middle element without fully sorting the array. For odd length, select index n/2; for even length, select both middle indices and average them. Quickselect partitions like Quicksort and runs in average O(n) time with O(1) extra space, though worst case is O(n²).
Q. How is a map implemented internally?
asked 1xmediumDsaTechnical2017
Ans. A map is usually implemented as either a hash table or a balanced search tree. In a hash table, a key is hashed to find a bucket, and collisions are handled by chaining or probing. Average lookup, insert and delete are constant time. Ordered maps often use balanced trees with logarithmic time operations.
Q. Number of Dice Rolls With Target Sum
asked 1xmediumDynamic programmingTechnical2023
Ans. Use dynamic programming where dp[s] stores the number of ways to reach sum s after processing some dice. For each die, build a new array by trying every face value from 1 to k and adding previous counts. Take modulo 1,000,000,007. Time complexity is O(n target k), space is O(target).
Q. Explain Virtual Memory and Thrashing.
asked 1xmediumOperating systemsTechnical2021
Ans. Virtual memory is an OS mechanism that gives each process a large logical address space by mapping virtual pages to physical RAM or disk. Thrashing happens when memory is overcommitted and the system spends most of its time swapping pages instead of running programs. It is reduced by adding RAM or limiting active processes.
Q. Explain polymorphic references in Java
asked 1xmediumOOPTechnical2017
Ans. A polymorphic reference in Java is a superclass or interface variable that refers to an object of a subclass or implementing class. It lets code treat different concrete objects uniformly. The key detail is dynamic dispatch: overridden instance methods are chosen at runtime based on the actual object type, not the reference type.
Q. Explain the internal working of Hadoop
asked 1xmediumBig dataManagerial2021
Ans. Hadoop works by storing large files across a cluster using HDFS and processing them in parallel using MapReduce, usually managed by YARN. HDFS splits files into blocks, replicates them on DataNodes, and tracks metadata in the NameNode. Jobs run near the data, then map, shuffle, and reduce results with fault recovery.
Q. Explain virtual memory and semaphores.
asked 1xmediumOperating systemsTechnical2021
Ans. Virtual memory is an OS memory abstraction that gives each process its own address space, while semaphores are synchronisation primitives used to control access to shared resources. Virtual memory maps virtual addresses to physical memory or disk pages. A semaphore holds a count, with wait decreasing it and signal increasing it, blocking when needed.
Q. Print the spiral traversal of a matrix
asked 1xmediumArraysTechnical2021
Ans. Print the matrix by maintaining four boundaries: top, bottom, left, and right, and repeatedly traverse right, down, left, and up while shrinking those boundaries. After each direction, check the boundaries have not crossed. This visits every cell once, uses no extra data structure apart from output, and runs in O(rows × columns) time.
Q. Explain RAID and different RAID levels.
asked 1xmediumOperating systemsTechnical2021
Ans. RAID combines multiple disks to improve performance, reliability, or both. RAID 0 stripes data for speed but has no redundancy. RAID 1 mirrors data for fault tolerance. RAID 5 uses striping with distributed parity and can survive one disk failure. RAID 6 survives two failures. RAID 10 combines mirroring and striping.
Q. Explain hashing with quadratic probing.
asked 1xmediumData structuresOnline test2013
Ans. Hashing with quadratic probing stores keys in a hash table and resolves collisions by trying positions at quadratic distances from the original hash index. For key k, probes are typically h(k), h(k)+1², h(k)+2², modulo table size. It reduces primary clustering, but needs a suitable table size and load factor.
Q. Explain thrashing in operating systems.
asked 1xmediumOperating systemsTechnical2020
Ans. Thrashing is a state where an operating system spends most of its time swapping pages between memory and disk instead of executing processes. It usually happens when there is not enough physical memory for the active working sets, causing constant page faults, very low CPU utilisation, and poor overall performance.
Q. Find the diagonal sum of a binary tree.
asked 1xmediumTreesTechnical2023
Ans. Use a breadth first traversal with a queue, where each queue entry starts a diagonal. For each popped node, follow its right pointers, adding values to the current diagonal sum and pushing any left child into the queue for the next diagonal. This visits every node once, so time is O(n) and space is O(w).
Q. How will you detect a cycle in a graph?
asked 1xmediumGraphsTechnical2017
Ans. Use DFS to detect a cycle by tracking visited nodes and the current recursion stack. In a directed graph, reaching a node already in the recursion stack means a cycle exists. In an undirected graph, a visited neighbour is a cycle only if it is not the parent. Time complexity is O(V + E).
Q. What is virtual memory? Explain paging.
asked 1xmediumOperating systemsTechnical2017
Ans. Virtual memory is an abstraction that gives each process its own large, private address space, independent of physical RAM. Paging implements this by splitting virtual memory and physical memory into fixed-size pages and frames. A page table maps virtual pages to frames, and missing pages can be loaded from disk on demand.
Q. Compute the factorial of a large number.
asked 1xmediumMathTechnical2020
Ans. Store the result as an array or string of decimal digits and simulate multiplication from 2 to n with carry. For each multiplier, multiply every stored digit, update it with value modulo 10, and carry forward the quotient. The time complexity is O(n d), where d is the number of digits in n!.
Q. Implement the Topological Sort algorithm.
asked 1xmediumGraphsTechnical2017
Ans. Use Kahn’s algorithm: compute indegree for every vertex, push all zero-indegree vertices into a queue, repeatedly remove one, add it to the order, and reduce indegrees of its neighbours. If a neighbour becomes zero, enqueue it. Use an adjacency list and indegree array. Time complexity is O(V + E).
Q. All-Pairs Shortest Path problem on a graph
asked 1xmediumGraphsOnline test2016
Ans. All-pairs shortest path means finding the shortest distance between every ordered pair of vertices in a weighted graph. The standard solution is Floyd-Warshall, using a distance matrix and relaxing through each intermediate vertex. It handles negative edges but not negative cycles, and runs in O(V³) time with O(V²) space.
Q. Explain Java Garbage Collection in detail.
asked 1xmediumOOPTechnical2021
Ans. Java Garbage Collection automatically frees heap memory by removing objects that are no longer reachable from live references. The key idea is reachability from GC roots, such as thread stacks, static fields and JNI references. Most JVMs use generational collection, treating young objects and long-lived objects differently to reduce pause time and improve throughput.
Q. Count the number of islands in a graph/grid
asked 1xmediumGraphsOnline test2019
Ans. Scan the grid and start a DFS or BFS whenever you find an unvisited land cell, counting that as one island. Use a visited set or mark cells in place, and explore the four neighbouring cells to consume the whole island. The time complexity is O(rows × columns), with similar worst-case space.
Q. Explain the internal workflow of Cassandra.
asked 1xmediumDBMSSystem design2017
Ans. Cassandra routes each request through a coordinator node, which uses the partition key and token ring to find replica nodes. Writes go to the commit log and memtable, then flush to immutable SSTables and are compacted. Reads check memtables and SSTables using indexes and Bloom filters, then reconcile replicas by timestamp.
Q. How can concurrency be achieved in MongoDB?
asked 1xmediumDBMSTechnical2021
Ans. Concurrency in MongoDB is achieved through the storage engine’s locking and transaction model, mainly document-level concurrency in WiredTiger. Multiple clients can read and write different documents in the same collection at the same time. Operations on a single document remain atomic, while conflicting writes to the same document are serialised.
Q. How does ConcurrentHashMap work internally?
asked 1xmediumConcurrencyTechnical2016
Ans. ConcurrentHashMap stores entries in an internal hash table and allows safe concurrent access by locking only small parts of the table, not the whole map. In modern Java, reads are mostly lock-free using volatile reads, while updates use CAS and synchronisation on individual bins. Collisions use linked lists or tree bins, and resizing is shared across threads.
Q. What are Delta tables and their advantages?
asked 1xmediumBig dataManagerial2021
Ans. Delta tables are storage tables in Delta Lake that store data in Parquet files with a transaction log. Their main advantage is reliable data lake processing with ACID transactions, so reads and writes stay consistent. They also support schema enforcement, time travel, updates, deletes, merges, and efficient batch or streaming workloads.
Q. Difference between arrays and lists in Python
asked 1xmediumData structuresTechnical2021
Ans. In Python, a list is the built-in general-purpose sequence, while an array usually means a typed sequence from the array module or NumPy. Lists can hold mixed types and resize dynamically. Arrays store elements of one type, so they are more memory efficient and better for numeric data. Both support indexed access.
Q. Differentiate between a semaphore and a mutex
asked 1xmediumOperating systemsTechnical2024
Ans. A mutex provides exclusive access to one shared resource, while a semaphore controls access to a limited number of resource instances. A mutex is locked and unlocked by the same thread, giving ownership. A semaphore is usually a counter, and any thread may signal it, making it useful for coordination as well as resource limiting.
Q. Explain how garbage collection works in Java.
asked 1xmediumOOPTechnical2023
Ans. Garbage Collection in Java automatically reclaims heap memory used by objects that are no longer reachable from live references. The collector starts from GC roots such as stack variables, static fields and active threads, marks reachable objects, then frees or compacts the rest. Most collectors are generational, because short-lived objects are common.
Q. Explain the concept of object slicing in C++.
asked 1xmediumOOPTechnical2014
Ans. Object slicing happens when a derived class object is copied or assigned to a base class object by value, so only the base part is kept and the derived fields and behaviour are lost. The key point is to use references or pointers, often smart pointers, when polymorphic behaviour must be preserved.
Q. Find the boundary traversal of a binary tree.
asked 1xmediumTreesTechnical2020
Ans. Boundary traversal is usually root, left boundary, all leaves, then right boundary in reverse order. Add the root if it is not null, collect left boundary excluding leaves, collect leaves by DFS left to right, then collect right boundary excluding leaves and append it reversed. This avoids duplicates. Time complexity is O(n).
Q. Generate all possible words from phone digits
asked 1xmediumBacktrackingTechnical2021
Ans. Use backtracking over a digit-to-letters map, building one character choice at each digit position until a complete word is formed. Store the current path in a string or character array and append completed words to a result list. Time complexity is O(k^n), more exactly the product of letters per digit, with O(n) recursion depth.
Q. How would you store a 2D array in a database?
asked 1xmediumDBMSTechnical2014
Ans. Store it as a table with one row per cell: array_id, row_index, column_index, and value. The key detail is access pattern: this normalised form is best if you need to query or update individual cells, while a JSON or binary blob is simpler if you only load and save the whole array.
Q. Design an in-place algorithm to sort n numbers
asked 1xmediumSortingTechnical2019
Ans. Use heapsort: first rearrange the array into a max heap in place, then repeatedly swap the maximum element at the root with the last unsorted element and shrink the heap. Restore the heap property after each swap. It runs in O(n log n) time and uses O(1) extra space.
Q. Implement Huffman Coding for data compression.
asked 1xmediumGreedyTechnical2014
Ans. Implement Huffman coding by counting character frequencies, pushing each character node into a min heap, then repeatedly merging the two lowest frequency nodes until one tree remains. Assign 0 to one branch and 1 to the other to build prefix codes. Use a priority queue. Time complexity is O(n + k log k).
Q. Find the maximum sum subarray in a given array.
asked 1xmediumArraysOnline test2023
Ans. Use Kadane’s algorithm: scan the array once, keeping the best subarray sum ending at the current position and the best overall sum seen so far. At each element, either extend the previous subarray or start a new one. This uses only variables, runs in O(n) time, and O(1) space.
Q. Describe a situation where you had to think out of the box.
asked 1xmediumProblem solvingHR2017
Ans. Pick a real example where the usual approach was blocked by time, budget, data, or process constraints. Emphasise how you reframed the problem, involved others, tested a practical alternative, and measured the result. Interviewers listen for originality balanced with judgement, not creativity for its own sake.
Q. At 3:00 PM, at what time will the hour and minute hands of a clock meet?
asked 1xmediumLogical reasoningTechnical2021
Ans. The hands meet at about 3:16:22 PM. At 3:00, the hour hand is 90 degrees ahead of the minute hand. The minute hand gains on it at 5.5 degrees per minute, since it moves 6 degrees per minute and the hour hand moves 0.5. Time taken is 90 ÷ 5.5 minutes.
Q. Answer situational HR questions assessing behavior in different scenarios.
asked 1xmediumConflict resolutionHR2023
Ans. Choose a real situation with enough complexity to show judgement, not a perfect success story. Explain the context briefly, your specific actions, the reasoning behind them, and the outcome. Emphasise ownership, communication, fairness, and learning. Interviewers listen for self-awareness, sound judgement under pressure, and behaviour that matches company values.
Q. Describe a situation where you led a team and handled teamwork challenges.
asked 1xmediumLeadershipHR2023
Ans. Pick a real example where the team faced conflict, unclear ownership, or pressure, and your leadership changed the outcome. Emphasise how you set direction, listened, resolved tensions, delegated, and kept people accountable. Interviewers listen for maturity, collaboration, self-awareness, measurable results, and whether you give credit to the team rather than only yourself.
Q. Solve aptitude and reasoning problems involving quantitative and logical reasoning.
asked 1xmediumLogical reasoningOnline test2021
Ans. Break the problem into known facts, unknowns, and relationships. Convert words into equations, tables, ratios, or diagrams as needed. Use elimination for logical reasoning and test assumptions carefully. Check units, percentages, and boundary cases. Finally, verify the answer by substituting it back into the original conditions.
Q. Compare two sets of numbers and determine relationships within a limited time frame.
asked 1xmediumLogical reasoningOnline test2023
Ans. Compare the two sets by first checking totals, averages, ranges, or ratios, depending on what the question asks. Look for the quickest relationship, not every possible calculation. Eliminate clearly wrong options early. If numbers are large, estimate first, then calculate only where the comparison is close.
Q. Measure exactly 4 litres of water using only 3-litre and 5-litre cans, minimizing water wastage.
asked 1xmediumLogical reasoningManagerial2023
Ans. Fill the 5-litre can and pour into the 3-litre can, leaving 2 litres. Empty the 3-litre can, wasting 3 litres. Pour the 2 litres into it. Fill the 5-litre can again, then pour 1 litre into the 3-litre can. The 5-litre can now holds exactly 4 litres.
Q. There are 5 switches in one room and 5 bulbs on different floors. Find the minimum number of trips required to determine which switch controls which bulb.
asked 1xmediumLogical reasoningTechnical2014
Ans. One trip is enough, assuming the bulbs get warm. Give each switch a different heat signature: leave one on, leave one off, turn three others on for long, medium, and short times, then switch them off before leaving. Visit the bulbs once. The lit bulb, hot bulb, warm bulb, slightly warm bulb, and cold bulb identify all switches.
Q. Three boxes puzzle: All boxes are incorrectly labeled (R, B, R+B). By removing one ball at a time, find the minimum number of turns required to correctly label all boxes.
asked 1xmediumLogical reasoningTechnical2021
Ans. One turn is enough. Take one ball from the box labelled R+B. Since every label is wrong, that box cannot be mixed, so it must contain only the colour you draw. If it is red, label it R. The box labelled B cannot be B, so it is R+B, and the last is B. Reverse colours if needed.
Showing 60 of 867 questions. Ranked by how often the same question came back across interviews.