Q. Optimal oil flow problem.
asked 1xmediumGraphsOnline test2020
Ans. Model it as a maximum flow problem from the oil source to the destination. Store the pipeline network as an adjacency list with residual capacities, then run Dinic’s algorithm using BFS levels and DFS blocking flows. The answer is the total flow pushed. Time complexity is O(EV²) in the standard bound.
Q. Explain 1NF, 2NF, and 3NF.
asked 1xmediumDBMSTechnical2017
Ans. 1NF means each column holds atomic values, 2NF means every non-key attribute depends on the whole primary key, and 3NF means non-key attributes do not depend on other non-key attributes. The key point is that each step removes redundancy and update anomalies by ensuring facts are stored in the right table.
Q. How does load balancing work?
asked 1xmediumNetworkingTechnical2022
Ans. Load balancing distributes incoming requests across multiple servers so no single server is overloaded and the service stays available. A load balancer sits in front of the servers and chooses a target using rules such as round robin, least connections, or health checks. The key detail is that unhealthy servers are removed from rotation.
Q. How is deletion done in heaps?
asked 1xmediumHeapsTechnical2020
Ans. Deletion in a heap is usually done by removing the root, replacing it with the last element, reducing the heap size, and heapifying down to restore the heap property. For deleting an arbitrary element, replace it with the last element, then heapify up or down as needed. The time complexity is O(log n).
Q. Explain OOPS concepts in Python.
asked 1xmediumOOPTechnical2024
Ans. OOPS in Python means modelling programs using classes and objects, with encapsulation, abstraction, inheritance and polymorphism. A class defines data and behaviour, while an object is an instance. Encapsulation groups state with methods, inheritance reuses or extends behaviour, and polymorphism lets different objects respond to the same method call appropriately.
Q. How do you calculate percent rank in SQL?
asked 1xmediumDBMSTechnical2024
Ans. Use the SQL window function PERCENT_RANK over an ordered set, usually with an OVER clause and ORDER BY. It calculates relative standing as rank minus one divided by total rows minus one within the partition. The key detail is that ties share the same rank, so gaps can appear.
Q. How do servers communicate with each other?
asked 1xmediumNetworkingTechnical2015
Ans. Servers communicate by sending data over a network using agreed protocols, usually on top of TCP/IP. One server opens a connection to another server’s IP address and port, sends a request, and receives a response. Protocols such as HTTP, gRPC, or message queues define the data format, routing, and reliability expectations.
Q. Explain function overriding and its advantages
asked 1xmediumOOPTechnical2020
Ans. Function overriding is when a subclass provides its own implementation of a method already defined in its superclass, using the same method signature. Its main advantage is runtime polymorphism: code can call the superclass type while the actual subclass behaviour runs, making programs easier to extend, reuse, and maintain.
Q. Find the grandparent of a given node in a tree.
asked 1xmediumTreesTechnical2015
Ans. If each node has a parent pointer, the grandparent is simply node.parent.parent, provided both exist. If not, traverse from the root using DFS or BFS while carrying the current node’s parent and grandparent. When the target is found, return the stored grandparent. This takes O(n) time and O(h) space with DFS.
Q. What is the order of execution of an SQL query?
asked 1xmediumDBMSTechnical2024
Ans. The logical order is FROM and JOIN, WHERE, GROUP BY, HAVING, SELECT, DISTINCT, ORDER BY, then LIMIT or OFFSET. The most important detail is that this is logical processing order, not necessarily the physical execution plan, because the database optimiser may reorder operations while preserving the same result.
Q. How do you connect to a database in Spring Boot?
asked 1xmediumDBMSTechnical2022
Ans. Add the relevant database driver and Spring Boot starter, then configure the datasource URL, username, password and driver in application.properties or application.yml. Spring Boot auto-configures a DataSource from these settings. For JPA, add spring-boot-starter-data-jpa, define entities and repositories, and inject repositories or JdbcTemplate into services.
Q. What is HashMap and how does it work internally?
asked 1xmediumOOPTechnical2022
Ans. A HashMap is a key value data structure that uses hashing to store and find values quickly. Internally, it hashes the key to choose a bucket in an array. If multiple keys map to the same bucket, it resolves collisions, commonly with a linked list or tree, using equality checks to find the right entry.
Q. Explain inheritance and abstract classes in Java.
asked 1xmediumOOPTechnical2020
Ans. Inheritance in Java lets one class extend another, reusing and specialising its fields and methods. An abstract class is a class that cannot be instantiated and may contain abstract methods that subclasses must implement. The key point is that Java supports single class inheritance, so a class can extend only one class.
Q. What is a circuit breaker and what are its states?
asked 1xmediumSystem designTechnical2022
Ans. A circuit breaker is a resilience pattern that stops calls to a failing service to avoid cascading failures. Its states are closed, where calls pass normally; open, where calls fail fast; and half-open, where limited trial calls are allowed to check recovery. Failures trip it open, and successful probes close it again.
Q. Write an SQL query to find the nth highest salary.
asked 1xmediumDBMSTechnical2024
Ans. Select the distinct salaries, order them in descending order, then skip N minus 1 rows and return the next one. The key detail is using distinct values, otherwise duplicate salaries can make the result wrong. In databases with window functions, DENSE_RANK over salary descending is the usual robust approach.
Q. Explain some SQL queries and the use of SQL clauses.
asked 1xmediumSQLTechnical2020
Ans. SQL queries are used to read, insert, update and delete data in relational tables. SELECT chooses columns, FROM chooses tables, WHERE filters rows, JOIN combines tables, GROUP BY groups results, HAVING filters groups, ORDER BY sorts results, and LIMIT restricts output. The key point is that clauses define each step of the result.
Q. Explain OS concepts like paging, semaphore, and deadlock.
asked 1xmediumOperating systemsTechnical2020
Ans. Paging is a memory management technique, a semaphore is a synchronisation primitive, and deadlock is a state where processes wait forever. Paging maps virtual memory to fixed-size physical frames. Semaphores control access to shared resources using counters. Deadlock needs mutual exclusion, hold and wait, no pre-emption, and circular wait.
Q. Find the maximum distance between two leaf nodes in a tree
asked 1xmediumTreesOnline test2021
Ans. Use a postorder DFS and compute the height of each subtree while updating a global maximum leaf-to-leaf distance. For each node with both children, the best path through it is left height plus right height, measured in edges. Return one plus the larger child height. Time is O(n), space is O(h).
Q. Explain the Diamond Problem in Java (multiple inheritance).
asked 1xmediumOOPTechnical2023
Ans. The Diamond Problem is the ambiguity caused when a class inherits the same method through two different parent paths. Java avoids it for classes by not allowing multiple class inheritance. With interfaces, default methods can create a similar conflict, and Java requires the implementing class to override the method and choose the behaviour explicitly.
Q. How do you deal with conflicts that arise during a project?
asked 1xmediumConflict resolutionHR2020
Ans. Choose a real conflict with meaningful stakes, such as priorities, ownership, or technical direction. Emphasise listening first, separating facts from assumptions, aligning on project goals, and agreeing clear actions. Show you stayed professional and followed up. Interviewers listen for maturity, collaboration, accountability, and evidence that the conflict improved the outcome.
Q. What is a Singleton class in Java? Write code to implement it.
asked 1xmediumOOPTechnical2017
Ans. A Singleton class in Java allows exactly one object of that class to exist and provides a global access point to it. Implement it with a private constructor, a private static final instance, and a public static getInstance method. The stored instance is the only data needed, and access time is O(1).
Q. Print the longest common substring among a given set of strings
asked 1xmediumStringsOnline test2021
Ans. Use the shortest string as the base and binary search the answer length, checking whether any substring of that length appears in every other string. Store rolling hashes of substrings in hash sets, intersect candidates across strings, then print a verified candidate. Time is about O(total characters log minLength), with hashing.
Q. Explain different sorting algorithms and their time complexities
asked 1xmediumSortingTechnical2020
Ans. Common sorting algorithms include bubble, selection and insertion sort at O(n²), merge sort and heap sort at O(n log n), and quicksort at average O(n log n) but worst O(n²). Merge sort needs extra space, heap sort is in place, quicksort is usually fastest in practice, and counting/radix sort can be linear for limited integer ranges.
Q. Explain the Merge Sort algorithm and analyze its time complexity.
asked 1xmediumSortingTechnical2020
Ans. Merge Sort is a divide and conquer sorting algorithm that splits the array into halves, recursively sorts each half, then merges the sorted halves. The key detail is that merging is linear in the number of elements. Its time complexity is O(n log n) in best, average, and worst cases, with O(n) extra space.
Q. How can you pivot a table in SQL without using the PIVOT function?
asked 1xmediumDBMSTechnical2024
Ans. You can pivot a table using conditional aggregation: group by the row key and compute each output column with an aggregate over a CASE expression. For example, each target column sums or counts values only when a category matches. The key detail is that the pivoted column values must be known, unless you build dynamic SQL.
Q. How do you combine two unsorted arrays into a single sorted array?
asked 1xmediumSortingTechnical2020
Ans. Concatenate the two arrays into one array, then sort the combined array. This is usually the simplest and most practical approach for unsorted input. If the arrays have lengths m and n, the time complexity is O((m + n) log(m + n)), with space depending on the sorting algorithm used.
Q. How would you design and implement a search feature for a website?
asked 1xmediumSearch systemsTechnical2021
Ans. I would build search around an inverted index, using Elasticsearch, OpenSearch, or a similar engine fed from the main database via events or batch sync. The key detail is keeping indexing separate from serving traffic, with tokenisation, stemming, ranking, filters, pagination, caching for common queries, and monitoring for freshness and relevance.
Q. Explain fragmentation in Operating Systems, its types, and reasons.
asked 1xmediumOperating systemsTechnical2015
Ans. Fragmentation is wasted memory caused when free or allocated space is split or unused inefficiently. Internal fragmentation occurs when an allocated block is larger than requested, leaving unused space inside it. External fragmentation occurs when free memory exists in small scattered blocks. It happens due to variable-sized allocation, deallocation, and long-running memory reuse patterns.
Q. Explain object-oriented programming concepts with real-time examples
asked 1xmediumOOPTechnical2020
Ans. Object-oriented programming models software as objects that combine data and behaviour. For example, a Car object has data like speed and fuel, and methods like brake or accelerate. Encapsulation protects data, inheritance lets ElectricCar reuse Car features, polymorphism lets different vehicles implement start differently, and abstraction hides engine details from the driver.
Q. Given an expression string in prefix form, convert it to postfix form.
asked 1xmediumStringsOnline test2017
Ans. Scan the prefix expression from right to left using a stack. When you see an operand, push it. When you see an operator, pop the top two strings, concatenate them as first operand, second operand, then operator, and push back. At the end, the stack top is postfix. Time and space are O(n).
Q. Explain the Collections interface and the different types present in it
asked 1xmediumOOPTechnical2022
Ans. The Collection interface in Java is the root interface for groups of objects, defining common operations like add, remove, size and iteration. Its main subinterfaces are List for ordered, indexed elements, Set for unique elements, Queue for processing elements in order, and Deque for double-ended queues. Map is related but not a Collection.
Q. How do you extract data from JSON in Python and generate a PDF from it?
asked 1xmediumPythonTechnical2024
Ans. Parse the JSON with Python’s json module into dictionaries and lists, extract the needed fields by key or iteration, then pass the formatted values to a PDF library such as ReportLab or FPDF. The key detail is to validate missing or unexpected fields before rendering. Processing is usually linear in the JSON size.
Q. Detect a loop in a linked list and explain the algorithm and its purpose
asked 1xmediumLinked listsTechnical2020
Ans. Use Floyd’s cycle detection algorithm with two pointers, slow and fast, to detect a loop in a linked list. Move slow one step and fast two steps each time. If they meet, a loop exists. If fast reaches null, there is no loop. It uses constant extra space and runs in linear time.
Q. Given a table that is not in 1NF, decompose it so that it satisfies 1NF.
asked 1xmediumDBMSTechnical2017
Ans. Replace every repeating group or multi-valued column with separate rows or a separate child table, so each field contains one atomic value. Keep the original table’s key in the child table as a foreign key, and use it with the extracted value, or a new identifier, to preserve uniqueness and relationships.
Q. How would you apply machine learning techniques to an eCommerce website?
asked 1xmediumScalable systemsTechnical2021
Ans. I would apply machine learning to personalise product recommendations, improve search ranking, predict demand, detect fraud, and optimise marketing. The most important detail is the feedback loop: collect clean behavioural and transaction data, train models offline, serve predictions with low latency, and validate impact through A/B tests on conversion, revenue, and customer retention.
Q. Tell me about a time you worked in a team and how you handled conflicts.
asked 1xmediumConflict resolutionHR2015
Ans. Pick a real team situation with a clear goal, shared pressure, and a disagreement you helped resolve. Emphasise how you listened, separated facts from opinions, stayed calm, and moved the group towards a decision. Interviewers listen for self-awareness, respect for others, accountability, and evidence that the outcome improved because of your approach.
Q. Write an SQL query to find the second highest salary from an employee table.
asked 1xmediumSQLTechnical2020
Ans. Select the distinct salaries, sort them in descending order, and return the second row using an offset. The key detail is using distinct, so duplicate top salaries do not hide the true second highest salary. This approach sorts the salary values, so its typical time complexity is O(n log n).
Q. On what basis does Google decide which links to show on a search results page?
asked 1xmediumGeneral csTechnical2020
Ans. Google ranks pages mainly by relevance to the query and the authority or quality of each page. The classic idea is PageRank: a page is more important if many important pages link to it. Modern ranking also uses content, freshness, location, usability, spam detection and many other signals.
Q. How would you perform data cleaning on a SQL table for a column containing dates?
asked 1xmediumDBMSTechnical2024
Ans. I would profile the column, trim obvious whitespace, convert valid strings to a proper DATE or TIMESTAMP type using safe parsing, and quarantine rows that fail conversion. The key detail is never overwriting raw values until invalid, ambiguous, null, and out-of-range dates have been reviewed or handled by clear rules.
Q. Write SQL queries demonstrating LEFT JOIN, RIGHT JOIN, INNER JOIN, and OUTER JOIN
asked 1xmediumSQLTechnical2020
Ans. Use Customers and Orders joined on customer_id: INNER JOIN returns only customers with matching orders, LEFT JOIN returns all customers and matching orders, RIGHT JOIN returns all orders and matching customers, and FULL OUTER JOIN returns every row from both sides. The key detail is unmatched columns become NULL in outer joins.
Q. Does Python support multithreading? Explain Python GIL, mutex locks, and semaphores.
asked 1xmediumOperating systemsTechnical2023
Ans. Yes, Python supports multithreading, but in CPython the Global Interpreter Lock allows only one thread to execute Python bytecode at a time. This limits CPU-bound parallelism, but threads still help with I/O-bound work. A mutex lock protects one shared resource, while a semaphore allows a fixed number of concurrent accesses.
Q. Given an array and a number n, return the first n highest numbers without sorting the array
asked 1xmediumArraysSystem design2022
Ans. Use a min heap of size n while scanning the array once. Add each number until the heap has n items, then replace the smallest heap item when a larger number appears. At the end, the heap contains the n highest numbers. Time complexity is O(m log n), space is O(n).
Q. How will you convince your teammates when there is a discrepancy while proposing a new idea?
asked 1xmediumLeadershipHR2020
Ans. Choose a real example where your idea faced reasoned disagreement, not personal conflict. Emphasise listening first, clarifying the discrepancy with data or user impact, inviting critique, and adapting your proposal. Interviewers listen for collaboration, evidence-based persuasion, respect for teammates, and willingness to change your view rather than simply “win” the argument.
Q. Between linked list and array, which is better for searching and insertion operations and why?
asked 1xmediumLinked listsTechnical2020
Ans. Arrays are generally better for searching, while linked lists are better for insertion when the insertion position is already known. Arrays allow direct indexing and, if sorted, binary search in O(log n). Linked lists need O(n) search, but can insert in O(1) by changing pointers, unlike arrays which may need shifting.
Q. Differentiate between a Data Warehouse and a Database, and explain the need for a Data Warehouse.
asked 1xmediumDBMSTechnical2015
Ans. A database is designed for day-to-day transactions, while a data warehouse is designed for analysis and reporting over large historical data. Databases are usually normalised and frequently updated. Data warehouses combine data from multiple sources, store cleaned historical data, and help businesses run complex queries, spot trends, and make decisions without slowing operational systems.
Q. Explain different types of joins in SQL and determine the result of a LEFT OUTER JOIN on two given tables.
asked 1xmediumDBMSTechnical2017
Ans. A LEFT OUTER JOIN returns every row from the left table, matching rows from the right table, and NULLs for right-side columns where no match exists. INNER JOIN returns only matches, RIGHT JOIN keeps all right rows, FULL OUTER JOIN keeps all rows from both sides, and CROSS JOIN returns every combination.
Q. Explain surrogate key, primary key, and foreign key with differences and relate them to real-time situations.
asked 1xmediumDBMSTechnical2015
Ans. A primary key uniquely identifies a row, a foreign key links one table to another, and a surrogate key is an artificial primary key with no business meaning. In an orders system, CustomerID may identify customers, Order.CustomerID is a foreign key, and an auto-generated OrderID is a surrogate key used because it is stable and simple.
Q. How does a SQL query from an IDE like NetBeans reach the MySQL server if the server is not explicitly launched?
asked 1xmediumDBMSTechnical2015
Ans. The query reaches MySQL because the MySQL server process is already running, usually as a background service or daemon started by the operating system. NetBeans is only a client. It uses a JDBC driver to open a connection, usually over TCP to port 3306 or a local socket, and sends the SQL to mysqld.
Q. Design a data structure to store elements in sorted order without using built-in sorting (e.g., no ordered maps)
asked 1xmediumLinked listsTechnical2021
Ans. Use a self-balancing binary search tree, such as an AVL tree, Red Black tree, Treap, or skip list. Store smaller elements on the left and larger on the right, rebalance after updates, and return elements by inorder traversal. Insert, delete, and search take O(log n), traversal takes O(n).
Q. How will you increase memory size if it is already allocated, and what is the maximum size you can increase it to?
asked 1xmediumOperating systemsTechnical2017
Ans. Use realloc to increase an already allocated memory block, by passing the existing pointer and the new required size. It may extend the same block or allocate a new one and copy existing data. The maximum size is not fixed by C. It is limited by available heap, address space, and SIZE_MAX.
Q. Imagine you worked on a solution for one week and your team members rejected it. How would you handle the situation?
asked 1xmediumTeamworkTechnical2023
Ans. Pick a real example where you had invested effort but stayed open to feedback. Emphasise that you asked why the solution was rejected, separated ego from the decision, compared options against team goals, and adapted quickly. Interviewers listen for humility, collaboration, resilience, sound judgement, and learning rather than defensiveness.
Q. Find a given number in a matrix that is sorted both row-wise and column-wise. Explain the best algorithm and trace it.
asked 1xmediumArraysTechnical2015
Ans. Start at the top right and do a staircase search in O(m+n) time and O(1) space. Compare the current value with the target. If it is equal, return found. If it is larger, move left. If it is smaller, move down. Trace repeats until found or indices leave the matrix.
Q. How would you choose appropriate data visualizations (bar chart, histogram, box plot, line chart) for a given dataset?
asked 1xmediumData visualizationTechnical2024
Ans. I choose the chart based on the data type and the question being asked. Use a bar chart for comparing categories, a histogram for showing the distribution of one numeric variable, a box plot for spread and outliers across groups, and a line chart for trends over time or ordered sequences.
Q. Explain SQL concepts such as SELECT queries, JOINs, Primary Key and Foreign Key constraints, Normalization, and ACID properties.
asked 1xmediumDBMSTechnical2020
Ans. SQL retrieves and manages relational data: SELECT reads rows, JOIN combines related tables, primary keys uniquely identify rows, foreign keys enforce relationships, normalisation reduces duplication, and ACID makes transactions reliable. The key detail is integrity: constraints and normal forms keep data consistent, while atomicity, consistency, isolation, and durability protect changes during failures and concurrency.
Q. Given a binary tree, perform a level order traversal starting from the bottom level (reverse level order traversal). Write code using a queue and a stack.
asked 1xmediumTreesTechnical2015
Ans. Use a queue for normal breadth first traversal and a stack to reverse the output order. Enqueue the root, then repeatedly dequeue a node, push it onto the stack, enqueue its right child first and left child second. Finally pop all stack items to print bottom-up left-to-right. Time is O(n), space is O(n).
Q. Given a source point (x1, y1) and a destination point (x2, y2), you can move only to (x1 + y1, y1) or (x1, x1 + y1). Print "Yes" if it is possible to reach the destination from the source, otherwise print "No".
asked 1xmediumMathOnline test2017
Ans. Work backwards from the destination to the source. Since each forward move adds one coordinate to the other, the reverse move subtracts the smaller coordinate from the larger. Repeated subtraction can be optimised with modulo. If you reach exactly (x1, y1), print “Yes”; if any coordinate becomes smaller than the source, print “No”. Time is logarithmic.
Q. Given a tuple (1, 2, [1,2,3], "ABC"), print any element that is a list or a string without using if statements. Additionally, print each element of the list on a new line, but print the string in a single line.
asked 1xmediumStringsTechnical2023
Ans. Iterate through the tuple and dispatch by type using a dictionary that maps list to a function printing its items with newline separators, and str to a function printing the string directly. Use type(element) to select the action, avoiding if statements. The time complexity is O(n + m), where m is printed list items.
Q. Design Instagram at a low level
asked 1xhardLow level designSystem design2022
Ans. Model Instagram around User, Post, Media, Follow, Like, Comment and Feed objects, backed by separate services for identity, posting, social graph, engagement, media storage and feed generation. The key detail is feed fan-out: push new posts to follower feed caches for normal users, but pull and rank posts on read for celebrities.
Q. Reverse a linked list
asked 1xeasyLinked listsTechnical2020
Ans. Reverse a linked list by iterating through it and changing each node’s next pointer to point to the previous node. Keep three pointers: previous, current, and next, so you do not lose the rest of the list. At the end, previous is the new head. Time complexity is O(n), space complexity is O(1).
Q. Aptitude and logical reasoning questions (quantitative aptitude and logical reasoning)
asked 1xunknownLogical reasoningOnline test2020
Ans. Identify the question type first, then write down the given data clearly. Convert words into equations, ratios, tables, or diagrams as needed. Use shortcuts only when they are reliable. For reasoning, look for patterns, conditions, and eliminations. Check the final answer against the question to avoid calculation or interpretation errors.
Showing 60 of 149 questions. Ranked by how often the same question came back across interviews.