Q. Solve the Rat in a Maze problem using backtracking
asked 3xmediumBacktrackingOnline test2019-2021
Ans. Use backtracking by starting at the top-left cell, marking it as part of the path, and recursively trying valid moves until the bottom-right cell is reached. Use a visited or solution matrix to avoid cycles and store the path. If a move fails, unmark it and try another. Time complexity is exponential, typically O(4^(n*m)).
Q. Generate the Gray code sequence for a given number of bits
asked 3xmediumBit manipulationOnline test2017-2020
Ans. Generate the n-bit Gray code sequence by producing numbers from 0 to 2^n minus 1 and converting each i to i XOR i shifted right by one. Store the results in a list. This works because consecutive values differ by exactly one bit. Time complexity is O(2^n), with O(2^n) output space.
Q. What is object-oriented programming? How is it different from procedural programming? Explain the pillars of OOP with real-life examples.
asked 2xmediumOOPTechnical2021
Ans. Object-oriented programming organises software as objects that combine data and behaviour, while procedural programming organises it as functions operating on data. Its pillars are encapsulation, like a bank account hiding balance changes; abstraction, like a car exposing pedals not engine details; inheritance, like electric car from car; and polymorphism, like different payments using pay().
Q. Explain the differences between C and C++.
asked 2xeasyOOPTechnical2020
Ans. C is a procedural language, while C++ is largely a superset of C with object oriented and generic programming features. C++ adds classes, inheritance, polymorphism, templates, exceptions, references, function overloading and the standard library. The most important difference is abstraction: C gives low level control, while C++ supports higher level design without losing that control.
Q. Implement a queue using two stacks
asked 1xmediumStacks queuesTechnical2021
Ans. Use two stacks, one for incoming elements and one for outgoing elements. Enqueue pushes onto the incoming stack. Dequeue pops from the outgoing stack; if it is empty, move all elements from incoming to outgoing first. This reverses order correctly. Each operation is amortised O(1), with O(n) extra space.
Q. Explain any two normal forms in DBMS.
asked 1xmediumDBMSTechnical2020
Ans. First normal form means each table cell contains a single atomic value, with no repeating groups or arrays. Second normal form means the table is already in first normal form, and every non-key attribute depends on the whole primary key, not just part of it. This mainly matters for tables with composite keys.
Q. Sort elements of an array by frequency
asked 1xmediumSortingTechnical2021
Ans. Count each element with a hash map, then sort the array elements by their frequency, usually in decreasing order. The key detail is tie handling: use value order or first occurrence, depending on the requirement. This takes O(n) to count and O(n log n) to sort, with O(n) extra space.
Q. Check whether a given graph is bipartite
asked 1xmediumGraphsOnline test2020
Ans. Use BFS or DFS to colour each node with one of two colours, ensuring every edge connects nodes of different colours. Start from every unvisited node, since the graph may be disconnected. Store colours in an array or map. If a neighbour has the same colour, it is not bipartite. Time complexity is O(V + E).
Q. Sort elements by frequency without using STL
asked 1xmediumSortingOnline test2017
Ans. Use an array of records storing each distinct value, its frequency, and its first index, then sort those records manually by decreasing frequency. Scan the input to update or insert records, using linear search if no hashing is allowed. Apply insertion sort, merge sort, or quicksort on the records. Time is O(nk + k log k), or O(n + k log k) with a custom hash table.
Q. Implement a traversal of a binary tree in C++.
asked 1xmediumTreesTechnical2020
Ans. Implement it with depth first search, usually as a recursive function taking a TreeNode pointer and a result vector. For inorder traversal, visit left child, process the current node, then visit right child. The call stack stores the path. Time complexity is O(n), and space is O(h), where h is tree height.
Q. What is a database trigger? Explain in detail.
asked 1xmediumDBMSTechnical2014
Ans. A database trigger is a stored database routine that runs automatically when a specified event occurs on a table or view, such as an insert, update or delete. Triggers are commonly used to enforce rules, maintain audit logs, update derived data or validate changes. They can run before or after the event, depending on the database.
Q. Sort elements of an array by decreasing frequency
asked 1xmediumSortingTechnical2021
Ans. Count each value with a hash map, then sort the distinct values by decreasing frequency and expand them back into the array. If equal frequencies must preserve first appearance, store each value’s first index and use it as a tie breaker. This takes O(n + k log k) time and O(k) space, where k is distinct values.
Q. Explain database normalization and its normal forms
asked 1xmediumDBMSTechnical2020
Ans. Database normalization is the process of organising relational tables to reduce duplication and avoid update, insert and delete anomalies. 1NF makes values atomic, 2NF removes partial dependency on a composite key, 3NF removes transitive dependency, and BCNF is stricter, requiring every determinant to be a candidate key.
Q. Which algorithm is used for phone face recognition?
asked 1xmediumMachine learningTechnical2020
Ans. Modern phones use deep learning based face recognition, usually convolutional neural networks or related neural network models. The key step is converting the detected face into a compact embedding, then comparing it with the enrolled embedding. Some phones also use infrared or depth data to prevent spoofing.
Q. Write SQL queries based on a given problem statement
asked 1xmediumSQLTechnical2020
Ans. Start by identifying the required output columns, source tables, join keys, filters, grouping, and ordering. Use joins for related data, where for row filters, group by with aggregates for summaries, and having for aggregate filters. Validate edge cases such as duplicates, nulls, and missing relationships before finalising the query.
Q. Given a matrix, find its eigenvalues and eigenvectors
asked 1xmediumLinear algebraTechnical2017
Ans. Eigenvalues are the roots of det(A minus λI) equals zero, and eigenvectors are non-zero vectors v satisfying Av equals λv. For each eigenvalue λ, solve the homogeneous system (A minus λI)v equals 0. The key detail is that eigenvectors are not unique, since any non-zero scalar multiple is also valid.
Q. What are abstract classes and pure virtual functions?
asked 1xmediumOOPTechnical2020
Ans. An abstract class is a class that cannot be instantiated and is used as a base for derived classes. In C++, a pure virtual function is declared with = 0 and has no required implementation in the base class. Any class with at least one pure virtual function is abstract, and derived classes must implement it to be concrete.
Q. Check whether a given tree is a subtree of another tree
asked 1xmediumTreesOnline test2017
Ans. Traverse the larger tree and, at each node whose value matches the smaller tree’s root, check whether the two trees are identical. Use recursion or a stack for traversal and a recursive same-tree comparison. The simple approach takes O(nm) time in the worst case and O(h) space for recursion.
Q. What happens when you type google.com in a web browser?
asked 1xmediumNetworkingTechnical2020
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. Explain the different types of CPU scheduling algorithms
asked 1xmediumOperating systemsTechnical2020
Ans. CPU scheduling algorithms include First Come First Served, Shortest Job First, Shortest Remaining Time First, Priority Scheduling, Round Robin, and Multilevel Queue or Feedback Queue scheduling. The key difference is how they choose the next process, balancing fairness, response time, waiting time, throughput, and whether a running process can be preempted.
Q. How do you handle disputes or conflicts in a team project?
asked 1xmediumConflict resolutionHR2020
Ans. Pick a real disagreement where the stakes were clear and you helped move the team forward. Emphasise listening first, separating facts from opinions, keeping the goal visible, and agreeing a practical next step. Interviewers listen for calm judgement, respect for others, ownership, and evidence that the outcome improved because of your approach.
Q. Sort elements by their frequency of occurrence in an array
asked 1xmediumSortingOnline test2020
Ans. Count each element with a hash map, then sort the array or unique elements using the stored frequency as the key. Use descending frequency for most common first, and define a tie rule such as original order or smaller value. Counting is O(n); sorting is O(n log n), or O(k log k) for k distinct elements.
Q. Explain database normalization and normal forms up to BCNF.
asked 1xmediumDBMSTechnical2014
Ans. Database normalization is organising relational tables to reduce redundancy and avoid update, insert, and delete anomalies. 1NF requires atomic values and no repeating groups. 2NF requires every non-key attribute to depend on the whole candidate key. 3NF removes transitive dependencies on keys. BCNF is stricter: every determinant must be a candidate key.
Q. Determine how many statements are true based on given information
asked 1xmediumLogical reasoningOnline test2020
Ans. Compare each statement only with the information given, not with outside knowledge or assumptions. Mark a statement true if it must follow, false if it contradicts the facts, and uncertain if it cannot be proved. Count only the statements that are definitely true. Check wording carefully, especially words like all, some, only, and always.
Q. Solve the Rat in a Maze (Rat and Cheese) problem using backtracking
asked 1xmediumBacktrackingOnline test2017
Ans. Use DFS backtracking from the start cell, moving only to valid, unblocked and unvisited cells until the cheese or destination is reached. Keep a visited matrix and optionally a path list. For each move, mark the cell, recurse in four directions, then unmark it if it fails. Time is O(4^(n*m)), space is O(n*m).
Q. Find a path for a rat in a maze using backtracking with given constraints
asked 1xmediumBacktrackingOnline test2020
Ans. Use backtracking by starting at the top-left cell, marking it visited, and recursively trying each allowed move until the destination is reached or all choices fail. Keep a visited matrix or path list to avoid cycles and undo choices when returning. For an n by n maze with four directions, worst-case time is exponential, about O(4^(n²)).
Q. Traverse a binary tree without using recursion or any auxiliary data structures.
asked 1xmediumTreesTechnical2020
Ans. Use Morris traversal, which performs an inorder traversal in O(n) time and O(1) extra space. For each node, find its inorder predecessor in the left subtree, temporarily link that predecessor’s right pointer back to the current node, visit nodes when appropriate, then remove the temporary link to restore the tree.
Q. Given a maze with obstacles, determine if cheese is reachable using graph traversal
asked 1xmediumGraphsOnline test2021
Ans. Use BFS or DFS from the mouse’s start cell and return true if you reach the cheese cell. Treat each open maze cell as a graph node, explore its four neighbours, and skip walls, out-of-bounds cells, and already visited cells. Use a queue for BFS or stack for DFS. Time is O(rows × columns).
Q. Determine the maximum number of calls required for a special function to sort a list
asked 1xmediumSortingOnline test2021
Ans. At most Θ(n log n) calls are required for an efficient comparison-based sort of n items. The key detail is that any comparison sort has a decision-tree lower bound of ⌈log2(n!)⌉ calls, so n log n is both achievable and asymptotically optimal.
Q. How would you design and implement an auto-complete feature like the one in MS Word?
asked 1xmediumDesign basicsHR2019
Ans. I would build a local prefix index using a trie, populated from the product dictionary, document terms, and the user’s correction history. On each keystroke, look up the current token prefix and return ranked completions. Ranking matters most: combine frequency, recency, context, and user-specific choices, while keeping lookup roughly O(length of prefix).
Q. Given a maze with obstacles, determine whether cheese is reachable using graph traversal
asked 1xmediumGraphsOnline test2021
Ans. Use BFS or DFS from the mouse’s starting cell and return true if you visit the cheese cell. Treat each open maze cell as a graph node, with edges to valid up, down, left and right neighbours. Keep a visited set to avoid cycles. Time is O(rows × columns), and space is O(rows × columns).
Q. Explain database normalization. Why is it used and when is a table in Second Normal Form (2NF)?
asked 1xmediumDBMSTechnical2021
Ans. Database normalization is the process of organising tables to reduce duplication and avoid update, insert and delete anomalies. It is used to improve data consistency and make relationships clearer. A table is in Second Normal Form when it is in First Normal Form and every non-key attribute depends on the whole primary key, not just part of it.
Q. Explain database normalization. Why is it used, and when is a table said to be in Second Normal Form (2NF)?
asked 1xmediumDBMSTechnical2021
Ans. Database normalization is the process of organising relational tables to reduce duplication and avoid update, insert, and delete anomalies. It is used to keep data consistent and easier to maintain. A table is in Second Normal Form when it is in First Normal Form and every non-key attribute depends on the whole primary key, not just part of it.
Q. Write an SQL query to find the 3rd lowest salary from a table and generalize it to find the Nth lowest salary
asked 1xmediumSQLTechnical2021
Ans. Use a distinct salary ordering and pick the third row in ascending order; for the Nth lowest, pick the Nth row. The usual solution is either DENSE_RANK over salary ascending and filter rank = N, or ORDER BY salary ASC with DISTINCT plus OFFSET N minus 1. The key detail is handling duplicate salaries correctly.
Q. Write an SQL query to find the 3rd lowest salary from a table and generalize the solution for the Nth lowest salary
asked 1xmediumSQLTechnical2021
Ans. Use distinct salaries ordered ascending, then skip the first two and take one row to get the 3rd lowest salary. For the Nth lowest salary, skip N minus 1 rows and take one. The key detail is using distinct salaries, otherwise duplicate salaries can change the rank. This sorts in O(n log n).
Q. Given the numbers 7, 9, 21, 63, and 100, find how many numbers between 1 and 50000 are exactly divisible by all of them.
asked 1xmediumLogical reasoningTechnical2014
Ans. 7 numbers. To solve this type, find the LCM of all given divisors, then count its multiples in the range. Here the LCM of 7, 9, 21, 63 and 100 is 6300. The number of multiples between 1 and 50000 is floor(50000 ÷ 6300) = 7.
Q. A grocery shop is experiencing a decline in sales over recent months. What possible reasons would you analyze to identify the cause?
asked 1xmediumLogical reasoningTechnical2014
Ans. A strong answer should cover both internal and external causes: pricing, product range, stock availability, service quality, store layout, local competition, seasonality, economic pressure, and changing customer habits. Emphasise using sales data, customer feedback, basket trends, and competitor comparison. Interviewers listen for structured thinking, commercial awareness, and avoiding assumptions.
Q. Given a table, pie chart, or line graph, answer questions based on data interpretation such as comparisons, percentages, and trends.
asked 1xmediumLogical reasoningOnline test2017
Ans. Read the title, units, scale, and legend first. Identify exactly what is being asked: difference, ratio, percentage change, average, or trend. Extract only the needed values, then calculate carefully. For percentages, use part divided by whole times 100. Check whether values are approximate and ensure comparisons use the same units or time period.
Q. Given a table with customer_id, order_date, and order_amount where a customer can place at most one order per day, find the latest transaction of every customer along with the amount.
asked 1xmediumSQLTechnical2014
Ans. Use a window function: assign each row a row number partitioned by customer_id and ordered by order_date descending, then keep only row number 1 to get the latest order and its amount. The key detail is that at most one order per day avoids ties on the latest date.
Q. Given a list of numbers, determine the maximum number of calls required for a special function to obtain a list sorted in ascending order (solution involved factorial and dividing by repetition factorial).
asked 1xmediumMathOnline test2020
Ans. The maximum number of calls is the number of distinct permutations of the list: n! divided by the factorial of each repeated value’s frequency. For example, for [1, 1, 2, 3], it is 4! / 2! = 12. This accounts for duplicates producing identical arrangements.
Q. Given a building with 100 floors and 2 eggs, determine the minimum number of drops needed to find the critical floor
asked 1xhardLogical reasoningTechnical2017
Ans. The minimum worst case is 14 drops. Use decreasing intervals: first drop from floor 14, then 27, 39, 50, and so on, reducing the step by one each time. If the first egg breaks, test upwards one floor at a time with the second. Since 14 + 13 + ... + 1 = 105, 14 covers 100 floors.
Q. Compare C and C++
asked 1xeasyProgramming languagesTechnical2021
Ans. C is a procedural systems programming language, while C++ extends C with object oriented and generic programming features. Both give low level memory control and compile to efficient native code, but C++ adds classes, templates, RAII, exceptions and the standard library, making abstraction easier while also increasing language complexity.
Q. Print "Hello word!" in C++
asked 1xeasyC cpp basicsTechnical2020
Ans. Use the standard output stream to print the exact text “Hello word!” from the main function. In C++, include the input output stream header, then write the string literal to std::cout, usually followed by a newline. No data structure is needed, and the time complexity is O(1).
Q. Print a simple pattern using loops
asked 1xeasyPatternsOnline test2019
Ans. Use nested loops: the outer loop controls the rows, and the inner loop prints the required characters or spaces for each row. For example, to print a triangle, print one more star on each next row. No extra data structure is needed. Time complexity is proportional to the total characters printed.
Q. Explain LIFO and FIFO with examples
asked 1xeasyData structuresTechnical2020
Ans. LIFO means “last in, first out”, while FIFO means “first in, first out”. A stack uses LIFO, like a pile of plates where the last plate placed is removed first. A queue uses FIFO, like people waiting in line where the first person to arrive is served first.
Q. Explain binary trees and their types.
asked 1xeasyTreesTechnical2020
Ans. A binary tree is a hierarchical data structure where each node has at most two children, usually called left and right. Common types include full trees, where every node has 0 or 2 children, complete trees, filled level by level, perfect trees, with all leaves at the same depth, balanced trees, and binary search trees.
Q. Explain static keyword in programming
asked 1xeasyOOPTechnical2020
Ans. Static means a member belongs to the class itself, not to each object instance. A static variable is shared by all instances, and a static method can be called without creating an object. In languages like C, a static local variable also keeps its value between function calls.
Q. Find the duplicate element in an array
asked 1xeasyArraysTechnical2020
Ans. Use a hash set to scan the array and return the first element that is already present in the set. For each value, check membership, then insert it if unseen. This handles unsorted arrays and any values. It takes O(n) time and O(n) extra space.
Q. Find the GCD of all elements in an array
asked 1xeasyArraysOnline test2021
Ans. Compute the GCD by scanning the array and maintaining a running GCD. Start with the first element, then replace the running value with gcd(current value, next element) for each remaining element. Use the Euclidean algorithm for each pair. No extra data structure is needed. Time complexity is O(n log M), where M is the largest value.
Q. Find synonyms or antonyms of a given word
asked 1xeasyVerbalOnline test2020
Ans. Identify the exact meaning of the word in context, then decide whether the question asks for a synonym or antonym. Eliminate options with the wrong tone, part of speech, or intensity. Check prefixes, roots, and common usage if unsure. Choose the option closest in meaning, not just generally related.
Q. Print a given pattern based on input size
asked 1xeasyPatternsOnline test2020
Ans. Use nested loops to print the pattern row by row, where the outer loop controls the number of rows and the inner loop controls spaces, symbols, or numbers for each row. The key detail is deriving the character count from the current row index. No extra data structure is needed, and time complexity is O(n²).
Q. Why are manholes round instead of square?
asked 1xeasyLogical reasoningHR2020
Ans. Manholes are round because a round cover cannot fall through its own opening, whatever its orientation. The cover has the same diameter in every direction, so there is no shorter diagonal or side that can slip through. A square cover could be turned diagonally and dropped into the square hole.
Q. Which is the most stable sorting algorithm?
asked 1xeasySortingTechnical2020
Ans. Merge sort is the standard stable sorting algorithm to name. It preserves the relative order of equal elements, provided the merge step takes equal items from the left side first. It runs in O(n log n) time and is reliable for large inputs, though it usually needs extra memory.
Q. Check whether a given number is prime or not
asked 1xeasyMathTechnical2020
Ans. A number is prime if it is greater than 1 and has no divisors other than 1 and itself. Check small cases first: numbers less than 2 are not prime, 2 is prime, and other even numbers are not. Then test odd divisors up to square root of n. Time is O(sqrt n), space is O(1).
Q. Difference between data structures and DBMS.
asked 1xeasyDBMSTechnical2020
Ans. Data structures organise data in memory for efficient use by a program, while a DBMS stores, manages, and retrieves persistent data for many users and applications. The key difference is scope: data structures focus on algorithmic efficiency, such as fast search or insertion, while a DBMS adds persistence, queries, security, transactions, and concurrency control.
Q. Perform basic string manipulation operations
asked 1xeasyStringsTechnical2017
Ans. Use built in string methods for operations such as length, indexing, slicing, concatenation, comparison, search, replace, split, trim, and case conversion. The key detail is whether strings are immutable: repeated concatenation can be costly, so use a character array or string builder. Most single pass operations take O(n) time.
Q. Python functions and basic language features
asked 1xeasyPythonTechnical2020
Ans. Python functions are reusable blocks of code defined with def, taking arguments and optionally returning a value. The most important detail is that Python treats functions as first class objects, so they can be assigned to variables, passed as arguments, returned from other functions, and used with features like default arguments and keyword arguments.
Q. What is the difference between SQL and PL/SQL?
asked 1xeasyDBMSTechnical2014
Ans. SQL is a declarative language used to query and manipulate relational data, while PL/SQL is Oracle’s procedural extension to SQL. The key difference is that SQL runs single data operations, whereas PL/SQL can group SQL with variables, loops, conditions, exceptions and stored procedures for application logic.
Q. What are the qualities of a good leader?
asked 1xunknownLeadershipTechnical2020
Ans. A strong answer should focus on a real example where leadership improved a team outcome. Choose a situation involving pressure, conflict, change, or unclear ownership. Emphasise communication, accountability, judgement, empathy, and the ability to develop others. Interviewers listen for self-awareness, measurable impact, and evidence that you lead through influence, not just authority.
Q. Solve logical puzzles during the technical interview
asked 1xunknownLogical reasoningTechnical2017
Ans. I would solve it by clarifying the rules, naming the unknowns, and working through constraints aloud. I would start with the most restrictive condition, eliminate impossible cases, and check edge cases before giving the final answer. If I get stuck, I would state assumptions, try a smaller example, and refine the logic.
Showing 60 of 112 questions. Ranked by how often the same question came back across interviews.