Q. Detect a loop in a linked list
asked 3xeasyLinked listsTechnical2016-2023
Ans. Use Floyd’s cycle detection with two pointers, slow and fast, starting at the head. Move slow one node at a time and fast two nodes at a time. If they ever meet, there is a loop. If fast reaches null, there is no loop. This runs in O(n) time and O(1) space.
Q. Explain OOP concepts such as inheritance, association, aggregation, composition, and polymorphism with examples
asked 2xmediumOOPTechnical2023
Ans. OOP models software as objects, with inheritance reusing behaviour, association linking objects, aggregation and composition modelling whole-part relationships, and polymorphism allowing different implementations behind one interface. For example, Car inherits Vehicle; Driver is associated with Car; Team aggregates Players; House composes Rooms; and different Shape classes implement draw differently.
Q. Find the height of a binary tree
asked 2xeasyTreesTechnical2023
Ans. Find the height by doing a depth first traversal and returning 1 plus the maximum height of the left and right subtrees. Use recursion, or an explicit stack if recursion depth is a concern. With height measured in nodes, an empty tree has height 0 and a leaf has height 1. Time is O(n).
Q. Write an SQL coding query
asked 1xmediumSQLOnline test2024
Ans. A correct SQL query depends on the table schema, required output, filters, and expected grouping or ordering. I would identify the source tables, join keys, filter rows with where, aggregate with group by if needed, and sort with order by. SQL engines use indexes and execution plans, so performance depends mainly on predicates and joins.
Q. Binary Search related problem
asked 1xmediumBinary searchTechnical2023
Ans. Use binary search when the search space is sorted or the answer has a monotonic property. Keep low and high pointers, test the middle value, and discard the half that cannot contain the answer. For answer-search problems, define the condition carefully. Time complexity is O(log n), with O(1) extra space.
Q. Design a pattern lock system.
asked 1xmediumDesignTechnical2019
Ans. Design it as a local authentication component that records a 3 by 3 grid gesture, normalises it to a sequence of node IDs, validates it against rules, then compares a salted hash of the sequence with the stored hash. The key detail is never storing the pattern itself, and rate limiting failed attempts.
Q. What is pure abstraction in Java?
asked 1xmediumOOPTechnical2023
Ans. Pure abstraction in Java means exposing only behaviour contracts and no implementation details, most commonly through an interface. A class that implements the interface must provide the method bodies. In modern Java, interfaces can also have default and static methods, so pure abstraction specifically means using only abstract method declarations in the interface.
Q. What is the diamond problem in Java?
asked 1xmediumOOPTechnical2023
Ans. The Diamond Problem is an ambiguity that happens when a class inherits the same method through two different parent paths. Java avoids it by not allowing multiple inheritance of classes. With interfaces, if two default methods conflict, the implementing class must override the method and choose the behaviour explicitly.
Q. Print the right view of a binary tree.
asked 1xmediumTreesTechnical2023
Ans. Use level order traversal and print the last node seen at each level. Keep a queue of nodes, process one level at a time using the current queue size, and record or print the node when it is the last in that level. Time complexity is O(n), and space complexity is O(w).
Q. Medium-level string manipulation problem
asked 1xmediumStringsTechnical2023
Ans. I would solve it by scanning the string once and maintaining the needed state in a suitable structure, such as a hash map, set, stack, or two pointers. The key detail is avoiding repeated substring work, since that often turns a linear solution into a quadratic one. Time complexity is usually O(n).
Q. Find the top view of a given binary tree.
asked 1xmediumTreesTechnical2019
Ans. Use level order traversal with a horizontal distance for each node, root at 0, left child minus 1 and right child plus 1. Store the first node seen at each horizontal distance in a map, since BFS sees topmost nodes first. Finally output map values by increasing distance. Time is O(n log n), or O(n) with ordered handling.
Q. Explain Java Collections and synchronization.
asked 1xmediumOOPTechnical2016
Ans. Java Collections are the standard framework for storing and manipulating groups of objects, such as List, Set, Queue and Map, with implementations like ArrayList, HashSet and HashMap. Most modern collections are not thread safe. Use Collections.synchronizedList or similar wrappers, or preferably java.util.concurrent classes like ConcurrentHashMap for scalable synchronization.
Q. Print all root-to-leaf paths of a binary tree.
asked 1xmediumTreesTechnical2023
Ans. Do a depth first traversal, keeping the current path from the root to the current node. Add each visited node to a list; when you reach a leaf, print the list. After returning from a child, remove the node to backtrack. Time is O(n), excluding output size, and space is O(h).
Q. Find the top 10 maximum elements from an array.
asked 1xmediumHeapTechnical2019
Ans. Use a min-heap of size 10 while scanning the array. Insert elements until the heap has 10 values, then for each remaining element, compare it with the heap minimum and replace it if larger. The heap contains the top 10 maximum elements. Time complexity is O(n log 10), effectively O(n), with O(10) space.
Q. What are database indexes and why are they used?
asked 1xmediumDBMSTechnical2023
Ans. Database indexes are separate data structures that let a database find rows faster without scanning the whole table. They are commonly built on columns used in filters, joins, or ordering, often using B-trees or hash structures. The trade-off is extra storage and slower writes, because indexes must be updated when data changes.
Q. What is a stack? Implement a queue using stacks.
asked 1xmediumStackTechnical2019
Ans. A stack is a LIFO data structure where the last item pushed is the first popped. Implement a queue using two stacks: push new items onto an input stack, and for dequeue, pop from an output stack; if it is empty, move all input items to it first. Enqueue is O(1), dequeue is amortised O(1).
Q. Discuss the topic: 'The future of Nuclear Power'.
asked 1xmediumCommunicationGroup discussion2023
Ans. A strong answer should take a balanced, evidence-based view. Pick examples such as energy security, decarbonisation, high capital cost, waste, safety, and public trust. Emphasise trade-offs rather than ideology. Interviewers listen for clear judgement, awareness of climate and economic pressures, and the ability to discuss risk responsibly.
Q. Answer theoretical questions on DBMS, OOP, and SQL.
asked 1xmediumMixedTechnical2023
Ans. DBMS manages structured data, OOP organises programs around objects, and SQL is the standard language for querying relational databases. The key link is data modelling: DBMS ensures storage, integrity, concurrency and recovery, OOP improves modular design through encapsulation, inheritance and polymorphism, and SQL handles definition, manipulation and retrieval of data.
Q. Determine the normal form of a given database table
asked 1xmediumDBMSTechnical2023
Ans. Determine the highest normal form by checking dependencies in order: 1NF, 2NF, 3NF, then BCNF. A table is 1NF if values are atomic, 2NF if no non-key attribute depends on part of a composite key, 3NF if there are no transitive dependencies, and BCNF if every determinant is a candidate key.
Q. Explain multithreading and synchronization in Java.
asked 1xmediumOOPTechnical2016
Ans. Multithreading in Java means running multiple threads within one process so tasks can execute concurrently and share memory. Synchronization controls access to shared mutable data so threads do not corrupt state or see inconsistent values. Java supports this with synchronized, locks, volatile, atomic classes, and higher-level concurrency utilities.
Q. How to measure 45 minutes using two identical wires
asked 1xmediumLogical reasoningTechnical2021
Ans. Assuming each wire takes 60 minutes to burn, light the first wire at both ends and the second at one end. The first wire burns out in 30 minutes. At that moment, light the other end of the second wire. Its remaining burn time is 30 minutes, so burning from both ends takes 15 more minutes: 45 total.
Q. Check whether a binary tree is a binary search tree.
asked 1xmediumTreesTechnical2016
Ans. Check it by doing a DFS with valid lower and upper bounds for each node. A node must be greater than its lower bound and less than its upper bound, then pass updated bounds to its children. Use recursion or an explicit stack. Time is O(n) and space is O(h).
Q. Solve coding questions involving array manipulation.
asked 1xmediumArraysTechnical2020
Ans. Use a systematic scan of the array, choosing the right pattern such as two pointers, sliding window, prefix sums, or in-place swapping. The key detail is to avoid unnecessary nested loops by tracking needed state as you traverse. Most array manipulation solutions run in O(n) time with O(1) or O(n) extra space.
Q. What is serialization? Explain its internal working.
asked 1xmediumOOPTechnical2019
Ans. Serialization is the process of converting an object or data structure into a byte stream or text format so it can be stored or transmitted and later rebuilt. Internally, the serializer records the object’s type, fields and values, handles nested objects and references, then writes them in a defined format such as JSON, XML or binary.
Q. Write a medium-level SQL query using JOIN operations
asked 1xmediumSQLOnline test2023
Ans. Use an INNER JOIN between customers and orders, then join order_items and products to calculate each customer’s total spend, grouping by customer and filtering totals above a chosen threshold. The key detail is joining on primary and foreign keys, such as customer_id and order_id, then aggregating with SUM and GROUP BY.
Q. Explain pointers including referencing and addressing
asked 1xmediumPointersTechnical2021
Ans. A pointer is a variable that stores the memory address of another object, rather than the object’s value directly. Addressing means getting an object’s address, commonly with the address-of operator. Dereferencing means following the pointer to read or change the value at that address. Pointers enable indirect access, sharing, dynamic memory, and efficient data structures.
Q. Explain the different types of database normalization.
asked 1xmediumDBMSTechnical2023
Ans. Database normalization organises data to reduce duplication and avoid update anomalies, usually through normal forms. 1NF requires atomic values and no repeating groups. 2NF removes partial dependency on a composite key. 3NF removes transitive dependency between non-key attributes. BCNF is stricter, requiring every determinant to be a candidate key.
Q. What are B-tree and B+ tree? Explain their differences.
asked 1xmediumDBMSTechnical2016
Ans. A B-tree is a balanced multiway search tree where keys and records can be stored in any node, while a B+ tree stores records only in leaf nodes and keeps internal nodes as indexes. The key difference is that B+ tree leaves are linked, making range queries and sequential access faster.
Q. Explain the difference between Merge Sort and Quick Sort
asked 1xmediumSortingTechnical2021
Ans. Merge Sort splits the array, sorts both halves, then merges them, while Quick Sort chooses a pivot and partitions elements around it. Merge Sort has guaranteed O(n log n) time but needs extra space. Quick Sort is usually faster in practice and can be in-place, but its worst case is O(n squared).
Q. Print the zig-zag (spiral) order traversal of a binary tree.
asked 1xmediumTreesTechnical2019
Ans. Use level order traversal, but alternate the printing direction at each level. Keep a queue for BFS, process one level at a time, store its values, and print them left to right or right to left depending on a boolean flag. Toggle the flag after each level. Time complexity is O(n).
Q. Write SQL queries to join tables based on the designed ER model
asked 1xmediumSQLManagerial2021
Ans. Join tables by matching each foreign key to the primary key it references in the ER model, using an inner join for required relationships and a left join for optional ones. For many-to-many relationships, join through the junction table. Use indexed primary and foreign keys; performance is typically near linear in matched rows with proper indexes.
Q. Write a C++ struct for a generic linked list using void pointers.
asked 1xmediumOOPTechnical2016
Ans. Use a node struct containing a void pointer for the payload and a pointer to the next node. A list struct can store the head pointer, optionally a tail pointer and size. This is generic but not type safe, so callers must cast correctly. Insertion at head is O(1), traversal is O(n).
Q. Write a SQL query using JOIN operations to retrieve required data
asked 1xmediumSQLOnline test2023
Ans. Use an inner join between the main table and related table on their matching key, then select only the required columns and apply any needed filters. For example, join customers to orders using customer ID. The database uses indexed relational tables, and with proper indexes the join is typically near logarithmic lookup per matched row.
Q. Explain internal working of HashMap, ConcurrentHashMap, and TreeMap.
asked 1xmediumOOPTechnical2019
Ans. HashMap stores entries in an array of buckets, using hashCode to choose a bucket and equals to resolve matches. Collisions use linked lists, treeified to red-black trees after a threshold. ConcurrentHashMap uses lock-free reads and fine-grained bucket-level locking for updates. TreeMap stores keys in a red-black tree, keeping sorted order with O(log n) operations.
Q. Explain the difference between wait() and sleep() in Java threading.
asked 1xmediumOperating systemsTechnical2019
Ans. wait() releases the object’s monitor and pauses the thread until another thread calls notify() or notifyAll(), while sleep() pauses the current thread for a set time without releasing any locks. wait() must be called inside a synchronized block or method. sleep() is a static Thread method and is mainly used for timed pauses.
Q. Find the nearest smaller element on the left for each array element.
asked 1xmediumStackTechnical2019
Ans. Use a monotonic increasing stack while scanning the array from left to right. For each element, pop stack elements greater than or equal to it; the new stack top is the nearest smaller element to its left, or none if the stack is empty. Then push the current element. Time is O(n), space is O(n).
Q. Given a list of strings, group all anagrams together into a 2D array.
asked 1xmediumStringsTechnical2019
Ans. Use a hash map where the key is each string’s characters sorted, and the value is the list of strings with that key. For every string, sort it, add the original string to the matching group, then return all map values. Time complexity is O(n k log k), where k is maximum string length.
Q. Design a stack that supports retrieving the minimum element in O(1) time.
asked 1xmediumStackTechnical2016
Ans. Use two stacks: one normal stack for all values and one min stack storing the current minimum at each level or only new minimum values with counts. On push, update the min stack if needed. On pop, remove from it when the popped value was the current minimum. Push, pop, top and getMin are O(1).
Q. Explain processes, threads, semaphores, mutexes, deadlock, and starvation.
asked 1xmediumOperating systemsTechnical2016
Ans. A process is an independent running program, while threads are lighter execution paths within a process sharing memory. A mutex gives exclusive access to one thread at a time. A semaphore limits access using a counter. Deadlock occurs when tasks wait forever on each other. Starvation occurs when a task is repeatedly denied resources.
Q. Delete a node from a linked list given only reference to that node in O(1).
asked 1xmediumLinked listsTechnical2019
Ans. Copy the data from the next node into the given node, then change the given node’s next pointer to skip that next node. This deletes the effect of the current node in O(1) time and O(1) space. The important limitation is that this does not work if the given node is the tail.
Q. Explain operating system concepts including processes, threads, and caching
asked 1xmediumOperating systemsTechnical2023
Ans. An operating system manages hardware and provides services such as scheduling, memory management, file systems and I/O. A process is an isolated running program with its own address space. Threads are lighter execution paths within a process that share memory. Caching stores frequently used data closer to the CPU or application to reduce latency.
Q. Improve the robustness of the tree construction code to handle extreme cases.
asked 1xmediumEdge casesTechnical2019
Ans. Use input validation, an index map, and iterative construction where depth may be large. Check for null or empty input, mismatched lengths, duplicate or missing keys, and invalid traversal ranges before building nodes. Avoid recursive stack overflow on skewed trees by using an explicit stack. Construction stays O(n) time with O(n) extra space.
Q. Design a database schema for an eCommerce system and write required SQL queries
asked 1xmediumDBMSOnline test2023
Ans. Use normalised tables: users, addresses, products, categories, orders, order_items, payments, shipments, carts, cart_items and inventory, with primary keys and foreign keys between customers, orders and products. Core queries fetch order history, product search, cart total, stock availability and top-selling products using joins, indexes on keys, and aggregates over order_items.
Q. Find the most frequently occurring palindromic words of length 4 in a given text.
asked 1xmediumStringsTechnical2025
Ans. Scan the text word by word, normalise case, keep only words of length 4, and check whether each equals its reverse. Store counts in a hash map, then return all palindromic words whose count equals the maximum count. This takes O(n) time over the text and O(k) space for distinct matches.
Q. Exceptions hierarchy in Java and rules for overridden methods throwing exceptions.
asked 1xmediumOOPTechnical2019
Ans. Java exceptions inherit from Throwable, with Error and Exception as main branches. RuntimeException and its subclasses are unchecked; other Exception subclasses are checked. An overriding method may throw no exception, the same checked exception, or a narrower checked exception, but not a broader or new checked exception. Unchecked exceptions are unrestricted.
Q. Design a system to find the largest N files and folders from a directory structure.
asked 1xmediumFile systemSystem design2025
Ans. Traverse the directory tree depth first, compute each file size directly and each folder size after summing its children, and keep a min heap of size N for the largest entries seen. For each file or folder, compare its size with the heap minimum. Time is O(M log N), space is O(N plus tree depth).
Q. Check whether a given number is a perfect cube without using math library functions.
asked 1xmediumBinary searchOnline test2016
Ans. Use binary search on the possible cube root range and check whether any mid value satisfies mid multiplied by mid multiplied by mid equals the number. Handle negative numbers by checking the absolute value and preserving the sign. Use only integer arithmetic, compare carefully to avoid overflow. Time complexity is logarithmic, space is constant.
Q. Print a linked list in reverse order without modifying the linked list in O(n) time.
asked 1xmediumLinked listsOnline test2016
Ans. Use recursion or an explicit stack to visit the linked list from head to tail, then print values while unwinding or popping. This keeps the list unchanged and takes O(n) time because each node is processed once. It needs O(n) extra space, either on the call stack or in the stack data structure.
Q. SQL: Find names of students enrolled in more than 3 courses using subquery and join.
asked 1xmediumSQLTechnical2019
Ans. Join the Students table to a subquery that groups Enrolments by student_id and keeps only groups with more than three courses. The subquery returns qualifying student IDs using GROUP BY and HAVING COUNT greater than 3, then the outer query selects matching student names. With indexing on student_id, this is efficient.
Q. How would you train a machine learning model to detect outliers in bank transactions?
asked 1xmediumMl systemManagerial2019
Ans. I would train a fraud or anomaly model on historical transactions using features such as amount, merchant, location, device, time, account age, and customer spending patterns. Because true outliers are rare and labels are imperfect, I would combine supervised learning on known cases with unsupervised anomaly detection, then validate with precision, recall, and analyst feedback.
Q. Difference between abstract class and interface. Explain default methods in interfaces.
asked 1xmediumOOPTechnical2019
Ans. An abstract class can hold shared state, constructors, and implemented or abstract methods, while an interface defines a contract a class can implement, usually without instance state. A class extends one abstract class but can implement many interfaces. Default methods in interfaces provide a method body, allowing new interface methods without breaking existing implementations.
Q. Explain Operating System concepts including processes, threads, caching, and page faults
asked 1xmediumOperating systemsTechnical2023
Ans. An operating system manages hardware and provides abstractions such as processes, threads, memory, files, and I/O. A process is an isolated running program, while threads share a process’s memory and run concurrently. Caching stores frequently used data for speed. A page fault occurs when needed memory is not in RAM and must be loaded from disk.
Q. Construct a binary tree given its inorder and postorder traversals (write runnable code).
asked 1xmediumTreesTechnical2019
Ans. Build the tree recursively using postorder’s last element as the root, then split inorder around that root into left and right subtrees. Use a hash map from value to inorder index for O(1) lookup, and process postorder from right to left, building right subtree before left. Time is O(n), space is O(n).
Q. Explain your approach to the written coding solutions and discuss possible optimizations.
asked 1xmediumProblem solvingTechnical2023
Ans. I first state the algorithm clearly, justify the main data structure, and analyse time and space complexity. I then check edge cases and invariants to show correctness. For optimisation, I look for repeated work, unnecessary storage, and better choices such as hashing, sorting, two pointers, or dynamic programming where they improve complexity.
Q. List the data structures used in constructing a page table with an LRU swapping algorithm.
asked 1xmediumOperating systemsTechnical2019
Ans. Use a page table, a frame table, and an LRU tracking structure, usually a doubly linked list or stack of pages ordered by recent use. A hash map from page number to list node is often added so pages can be moved to the most recent position in constant time.
Q. Given a multi-paragraph text, find the most frequently occurring words across the entire text.
asked 1xmediumStringsTechnical2025
Ans. Use a hash map to count each normalised word across all paragraphs, then return the word or words with the highest count. Treat the text as one stream: lowercase words, remove punctuation if required, split on whitespace, update counts, and track the maximum. Time is O(n), space is O(k).
Q. Solve another query-based array problem requiring efficient handling of queries on array data.
asked 1xmediumArraysOnline test2020
Ans. Use a Fenwick tree if queries are prefix or range sums with point updates, and use a segment tree if queries need more general range information such as minimum, maximum or gcd. Build it once from the array, answer each query by combining stored intervals, and update only affected nodes. This gives O(log n) per query.
Q. Design an ER model for a shopping site or app, including tables, primary keys, and foreign keys
asked 1xmediumDatabase designManagerial2021
Ans. Use Customer(customer_id PK), Address(address_id PK, customer_id FK), Product(product_id PK), Category(category_id PK), ProductCategory(product_id FK, category_id FK, composite PK), Cart(cart_id PK, customer_id FK), CartItem(cart_id FK, product_id FK, composite PK), Order(order_id PK, customer_id FK, address_id FK), OrderItem(order_id FK, product_id FK, composite PK), Payment(payment_id PK, order_id FK), and Shipment(shipment_id PK, order_id FK). Store price on OrderItem to preserve history.
Q. Given matrices of sizes 2x2, 2x3, and 3x3, how would you store them in a single database table?
asked 1xmediumDBMSTechnical2016
Ans. Store each matrix cell as one row with columns like matrix_id, row_index, column_index, value, row_count, and column_count. This handles 2x2, 2x3, and 3x3 without nullable columns or separate tables. The key detail is using matrix_id plus row_index and column_index as a unique key.
Q. Find a subarray whose sum adds up to a given value when the array may contain negative integers.
asked 1xmediumArraysTechnical2019
Ans. Use prefix sums with a hash map to find whether a previous prefix sum equals current prefix sum minus the target. Store each prefix sum with its earliest index; when found, the subarray between the next index and current index has the required sum. This works with negative numbers in O(n) time and O(n) space.
Showing 60 of 149 questions. Ranked by how often the same question came back across interviews.