Q. What is the worst-case time complexity of Quick Sort?
asked 3xeasySortingOnline test, Technical2020-2021
Ans. The worst-case time complexity of Quick Sort is O(n squared). This happens when the pivot repeatedly splits the array very unevenly, such as choosing the smallest or largest element each time. In that case, each partition only reduces the problem by one element, leading to many repeated comparisons.
Q. What is transaction serialization in databases?
asked 2xmediumDBMSOnline test2021
Ans. Transaction serialization means making concurrent transactions produce the same final result as if they had run one after another in some serial order. It is the correctness goal behind the serializable isolation level, preventing anomalies such as lost updates, dirty reads, and inconsistent reads while still allowing safe concurrency.
Q. Analyze the output of the Linux command free -m.
asked 2xmediumOperating systemsOnline test2021
Ans. free -m shows memory usage in megabytes for RAM and swap. The Mem row lists total, used, free, shared, buff/cache and available memory. The most important value is usually available, because Linux uses spare RAM for buffers and cache, which can be reclaimed when applications need memory.
Q. Which is better: Heap Sort or Merge Sort? Explain why.
asked 2xmediumSortingHR, Technical2019-2020
Ans. Merge Sort is usually better when stability and predictable performance matter, while Heap Sort is better when extra memory must be minimal. Both are O(n log n), but Merge Sort is stable and often faster in practice due to better access patterns. Heap Sort sorts in place, but is not stable and has poorer cache behaviour.
Q. Given a string, find the longest palindromic substring.
asked 2xmediumStringsOnline test, Technical2020-2023
Ans. Use expand around centres: for each index, expand once for an odd-length palindrome and once between indices for an even-length palindrome, tracking the best start and length. The key detail is handling both centre types. This uses only a few variables, runs in O(n squared) time, and uses O(1) extra space.
Q. What is the full form of CDN?
asked 2xeasyNetworkingOnline test2021
Ans. CDN stands for Content Delivery Network. It is a distributed network of servers that delivers web content, such as images, videos, scripts, and pages, from locations closer to the user. This reduces latency, improves load times, and helps websites handle high traffic more reliably.
Q. What is load average in Linux?
asked 2xeasyOperating systemsOnline test2020-2021
Ans. Load average in Linux is the average number of processes that are either running or waiting to run, including tasks stuck in uninterruptible I/O sleep. It is usually shown for 1, 5, and 15 minutes. Compare it with CPU core count to judge pressure.
Q. What are the differences between TCP and UDP?
asked 2xeasyNetworkingOnline test2021
Ans. TCP is connection-oriented and reliable, while UDP is connectionless and does not guarantee delivery, order, or duplicate protection. TCP uses handshakes, acknowledgements, retransmission, flow control, and congestion control, so it is slower but safer. UDP has lower overhead and latency, so it suits streaming, gaming, VoIP, DNS, and cases where speed matters more than perfect delivery.
Q. Explain the DOM (Document Object Model) in JavaScript.
asked 2xeasyWebTechnical2023
Ans. The DOM is a tree-like programming interface that represents an HTML or XML document as nodes, such as elements, text and attributes. JavaScript uses the DOM to read, change, add or remove page content and styles. The key point is that DOM changes update the rendered page, often without reloading it.
Q. How do you execute a command as another user in Linux?
asked 2xeasyOperating systemsOnline test2021
Ans. Use sudo with the -u option, for example sudo -u username command, to run a command as another user. You need appropriate sudo privileges, usually configured in /etc/sudoers or a file under /etc/sudoers.d. Alternatively, su - username switches to that user’s shell if you know their password.
Q. What HTTP status code is returned for invalid credentials?
asked 2xeasyWebOnline test2021
Ans. Invalid credentials should return 401 Unauthorized. This means the request has not been authenticated successfully, usually because the username, password, token, or API key is missing or wrong. A 403 Forbidden is different: it means the user is authenticated, but does not have permission to access the resource.
Q. Which HTTP method is used to retrieve information of a resource?
asked 2xeasyWebOnline test2021
Ans. GET is used to retrieve information about a resource. It is a safe and idempotent HTTP method, meaning it should not change server state and repeated identical requests should have the same effect. Parameters are commonly sent in the URL query string, and the response contains the requested representation.
Q. How can you center a paragraph using HTML, CSS, JavaScript, or jQuery?
asked 2xeasyWebOnline test2021
Ans. Centre a paragraph by applying CSS text-align: centre to the paragraph or its container. CSS is the preferred approach because presentation belongs in stylesheets. In HTML, the old align attribute is obsolete. With JavaScript or jQuery, you would set the same CSS property dynamically, usually only when the alignment must change at runtime.
Q. Which permissions are required to open, modify, and save a file in Linux?
asked 2xeasyOperating systemsOnline test2021
Ans. To open and modify an existing file, you need read and write permission on the file, plus execute permission on each directory in its path. Saving changes to the same file needs write permission on the file. If the editor saves by creating or replacing a file, you also need write permission on the containing directory.
Q. Evaluate a postfix expression.
asked 1xmediumStackTechnical2020
Ans. Evaluate a postfix expression using a stack, scanning tokens from left to right. Push operands onto the stack; when an operator appears, pop the required operands, apply the operator, and push the result back. For binary operators, preserve operand order. The final stack value is the answer. Time complexity is O(n).
Q. Implement Heap Sort algorithm.
asked 1xmediumSortingTechnical2020
Ans. Heap Sort sorts an array by first building a binary heap, usually a max heap, then repeatedly moving the largest element to the end and restoring the heap property. The key detail is heapify: it fixes a subtree in logarithmic time. Overall time is O(n log n), with O(1) extra space.
Q. Optimize the computation of a^b.
asked 1xmediumMathTechnical2014
Ans. Use exponentiation by squaring to compute a^b in O(log b) multiplications instead of multiplying a by itself b times. Repeatedly square the base and halve the exponent; when the exponent is odd, multiply the current result by the base. For negative exponents, compute the reciprocal of the positive power.
Q. Find the median of a stream of numbers.
asked 1xmediumHeapsTechnical2014
Ans. Use two heaps: a max heap for the lower half of numbers and a min heap for the upper half. Keep their sizes equal, or let one heap have one extra element. Insert in O(log n), rebalance after each insert, and get the median in O(1) from the heap tops.
Q. How is Heap Sort better than Merge Sort?
asked 1xmediumAlgorithmsTechnical2019
Ans. Heap Sort is better than Merge Sort mainly because it sorts in place, using only constant extra memory. Both have O(n log n) worst-case time complexity, but Merge Sort usually needs O(n) extra space for arrays. The trade-off is that Merge Sort is stable and often faster in practice due to better cache behaviour.
Q. Find the k-th largest element in an array.
asked 1xmediumArraysTechnical2014
Ans. Use a min-heap of size k: insert each element, and whenever the heap grows beyond k, remove the smallest. After processing the array, the heap root is the k-th largest element. This takes O(n log k) time and O(k) space, and handles duplicates naturally.
Q. What does loss percentage indicate in MTR?
asked 1xmediumNetworkingOnline test2021
Ans. Loss percentage in MTR shows the proportion of probe packets sent to a hop that did not receive a reply. The key detail is that loss on an intermediate hop may be caused by ICMP rate limiting, not real network loss. It matters most when the loss continues to later hops or the destination.
Q. How do you optimize queries on a big table?
asked 1xmediumDBMSOnline test2021
Ans. Optimise queries on a big table by first checking the execution plan, then adding or adjusting indexes for the columns used in filters, joins, and ordering. The most important detail is to index for real query patterns, not every column. Also avoid selecting unused columns, keep statistics updated, and consider partitioning for very large tables.
Q. Answer queries on a Binary Search Tree (BST)
asked 1xmediumTreesTechnical2024
Ans. Convert the BST to a sorted array using inorder traversal, then answer each query with binary search. For a query value, find the first element greater than or equal to it. That gives the ceiling, and the previous element gives the floor. Preprocessing is O(n), each query is O(log n), with O(n) extra space.
Q. Flatten an N-ary tree into a linear structure.
asked 1xmediumTreesTechnical2024
Ans. Flatten the N-ary tree by doing a depth first preorder traversal and appending each visited node to a list. Visit the root first, then recursively visit its children from left to right. Use recursion or an explicit stack. The time complexity is O(n), and the extra space is O(h) or O(n).
Q. Explain Binary Search Trees and their properties
asked 1xmediumTreesTechnical2020
Ans. A Binary Search Tree is a binary tree where each node’s left subtree contains smaller values and its right subtree contains larger values. This ordering makes search, insertion and deletion efficient, taking O(log n) time in a balanced tree. In the worst case, if the tree becomes skewed, operations take O(n).
Q. Explain heap data structure and its applications
asked 1xmediumHeapTechnical2020
Ans. A heap is a complete binary tree, usually stored in an array, where each parent has higher priority than its children. In a max heap the parent is larger, and in a min heap it is smaller. Heaps support fast access to the highest priority item and are used in priority queues, heap sort, scheduling, and graph algorithms.
Q. Implement the heapify function used in Heap Sort.
asked 1xmediumHeapTechnical2020
Ans. Heapify restores the heap property for a subtree in an array-based binary heap. For a max heap, compare the current node with its left and right children, swap with the largest if needed, then continue down that affected child. It takes O(log n) time and O(1) extra space if done iteratively.
Q. What does packet loss percentage indicate in MTR?
asked 1xmediumNetworkingOnline test2021
Ans. Packet loss percentage in MTR shows the proportion of probe packets sent to a hop that did not receive a reply. The key detail is that loss at an intermediate hop is only significant if it continues to later hops or the destination, because routers often rate-limit or deprioritise MTR replies.
Q. Explain algorithms and solve a binary tree problem
asked 1xmediumTreesTechnical2019
Ans. An algorithm is a step-by-step method to solve a problem, and most binary tree problems are solved with depth-first or breadth-first traversal. I would choose DFS for recursive structure, keep needed state such as height, sum, or parent result, visit each node once, and get O(n) time with O(h) space.
Q. What will you do if you are selected as GDSC Lead?
asked 1xmediumLeadershipManagerial2023
Ans. A strong answer should focus on a clear plan for growing the community, not personal status. Pick examples showing leadership, inclusion and execution. Emphasise running useful workshops, building a core team, collaborating with faculty and industry, and measuring impact. Interviewers listen for initiative, consistency, empathy and realistic goals.
Q. What is the best practice to save passwords securely?
asked 1xmediumSecurityOnline test2021
Ans. Store passwords only as salted hashes using a slow, adaptive password hashing function such as Argon2id, bcrypt, scrypt, or PBKDF2. Each password should have a unique random salt, and the work factor should be high enough to make brute force attacks expensive while still acceptable for login performance.
Q. Conceptual questions on Graphs and traversal techniques
asked 1xmediumGraphsTechnical2024
Ans. Graphs model entities as vertices and relationships as edges, and traversal means systematically visiting vertices. The two core techniques are BFS, which uses a queue and explores level by level, and DFS, which uses recursion or a stack and explores deeply first. Both usually run in O(V + E) time with a visited set.
Q. Evaluate an arithmetic expression with given conditions
asked 1xmediumStacksTechnical2020
Ans. Use two stacks: one for numbers and one for operators, scanning the expression left to right. Push numbers, handle parentheses, and before pushing an operator, apply any stacked operator with higher or equal precedence. Pop and apply remaining operators at the end. This gives O(n) time and O(n) space.
Q. Solve general aptitude questions under time constraints
asked 1xmediumLogical reasoningOnline test2017
Ans. Use a fast triage method: read the question, identify the topic, write only the needed formula or relationship, estimate where possible, then calculate carefully. Skip long questions and return later. Eliminate impossible options in multiple choice. Practise common areas like percentages, ratios, time and work, speed, averages, and probability.
Q. How can queries on very large (big) tables be optimized?
asked 1xmediumDBMSOnline test2021
Ans. Optimise queries on very large tables by reducing how much data the database must scan. Use indexes that match common filters, joins, and sort keys, and partition tables by a frequently filtered column such as date or tenant. Check the query plan to confirm index use, partition pruning, and no unnecessary full table scans.
Q. What are the best practices to store passwords securely?
asked 1xmediumSecurityOnline test2021
Ans. Store passwords only as salted, slow, one way hashes using a modern password hashing algorithm such as Argon2id, bcrypt, or scrypt. The most important detail is to use a unique random salt per password and tune the work factor so guessing is expensive, while never logging, encrypting, or storing plaintext passwords.
Q. Explain indexing and normalization in DBMS with examples.
asked 1xmediumDBMSTechnical2023
Ans. Indexing speeds up data retrieval by creating a separate search structure, such as a B-tree index on Employee(id), so the DBMS can find rows without scanning the whole table. Normalization organises data to reduce duplication and anomalies, for example splitting customer and order details into separate Customer and Order tables linked by customer_id.
Q. How would you improve the revenue of an office cafeteria?
asked 1xmediumProblem solvingTechnical2013
Ans. Pick a situation where you improved sales or usage through data, customer insight, and practical execution. Emphasise diagnosing demand, pricing, menu mix, queue times, promotions, and partnerships with offices. Interviewers listen for commercial thinking, low-cost experiments, measurable impact, and awareness that higher revenue must not damage customer satisfaction or margins.
Q. Conceptual questions on Self-balancing Binary Search Trees
asked 1xmediumTreesTechnical2024
Ans. Self-balancing binary search trees keep their height logarithmic by reorganising nodes after insertions and deletions. This prevents the tree from becoming a linked list in the worst case. The key detail is that operations such as search, insert and delete remain O(log n), using rotations and balance rules in structures like AVL or Red-Black trees.
Q. Design a brand-new feature for an existing Google product.
asked 1xmediumProduct designSystem design2023
Ans. I would add a “verified answer timeline” to Google Search for fast-changing topics such as outages, elections, and product recalls. The key detail is provenance: each answer would show source, timestamp, confidence, and change history, backed by a streaming ingestion pipeline, entity matching, ranking, and human escalation for high-risk topics.
Q. Explain database indexing and normalization with examples.
asked 1xmediumDBMSTechnical2023
Ans. Database indexing speeds up lookups, while normalization structures data to reduce duplication and inconsistency. An index on a customer_id column lets the database find matching orders quickly instead of scanning every row. Normalization might split customers and orders into separate tables, storing customer details once and referencing them by customer_id.
Q. Follow-up to the hashing problem with increased difficulty
asked 1xmediumHashingTechnical2024
Ans. Use hashing to store the extra information needed by the harder constraint, rather than searching again. Keep a hash map from each key to its frequency, index, or best value so far, depending on the follow-up. This preserves near linear time, O(n), with O(n) extra space.
Q. Given an N x M matrix, find the minimum sum 3x3 sub-matrix.
asked 1xmediumArraysTechnical2024
Ans. Use a 2D prefix sum to compute every 3x3 sub-matrix sum in constant time, then keep the minimum. Build prefix sums where each cell stores the sum from the top-left to that cell. For each possible top-left corner, query its 3x3 sum. Time is O(NM), space is O(NM).
Q. How can very large database queries be handled efficiently?
asked 1xmediumDBMSOnline test2020
Ans. Handle very large database queries by making the database do less work and by returning results in chunks. Use proper indexes, filter early, select only needed columns, and aggregate in the database where possible. For huge result sets, use cursor-based pagination or streaming rather than loading everything into memory at once.
Q. How much time does it take to sort a heap in reverse order?
asked 1xmediumHeapsTechnical2019
Ans. It takes O(n log n) time to sort a heap into reverse order. A heap only gives quick access to the minimum or maximum element, not a fully sorted order. Repeatedly extracting the root and restoring the heap costs O(log n) each, done n times.
Q. How do you detect a loop in a linked list in an optimal way?
asked 1xmediumLinked listsOnline test2021
Ans. Use Floyd’s cycle detection with two pointers, slow and fast. Move slow one node at a time and fast two nodes at a time. If they ever meet, the linked list has a loop. If fast reaches null, there is no loop. This runs in O(n) time and O(1) space.
Q. How would you split a search query across multiple machines?
asked 1xmediumDistributed systemsTechnical2014
Ans. Split the index into shards across machines, usually by document id, and send each query to all relevant shards in parallel. Each shard searches its local inverted index and returns its top results with scores. A coordinator merges these partial top lists, re-ranks if needed, applies timeouts, and returns the final top results.
Q. Which type of content is not suitable to be served by a CDN?
asked 1xmediumWebOnline test2021
Ans. Highly dynamic, personalised, or non-cacheable content is not suitable to be served directly by a CDN. Examples include user-specific account pages, real-time transaction data, or responses that change on every request. CDNs work best for cacheable content, so serving such data from the edge risks stale, incorrect, or insecure responses.
Q. C++ language fundamentals and Standard Template Library (STL)
asked 1xmediumOOPTechnical2020
Ans. C++ fundamentals cover types, scope, pointers and references, object lifetime, classes, inheritance, polymorphism, templates, and RAII. The STL provides reusable containers, iterators, algorithms, and function objects, such as vector, map, set, sort, and find. The key point is choosing the right container and understanding its complexity.
Q. Conceptual questions covering almost all major data structures
asked 1xmediumData structuresTechnical2020
Ans. Major data structures are chosen by access pattern, update cost, ordering needs, and memory trade-offs. Arrays give fast indexing, linked lists fast local insertion, stacks and queues control processing order, hash tables give average constant lookup, trees keep data ordered, heaps support priorities, graphs model relationships, and tries optimise prefix searches.
Q. Count all submatrices with sum equal to zero in a given matrix
asked 1xmediumArraysTechnical2024
Ans. Fix pairs of rows, compress the columns between them into a 1D array, then count zero-sum subarrays in that array. Use a prefix sum frequency hash map: if the same prefix sum appears again, the subarray between them sums to zero. This gives O(rows squared times columns), or transpose to minimise the squared dimension.
Q. How does a web server handle multiple requests simultaneously?
asked 1xmediumWebOnline test2021
Ans. A web server handles multiple requests simultaneously by using concurrency, typically through worker processes, threads, or an event loop with non-blocking I/O. The key detail is that waiting for network, file, or database operations should not block the whole server, so other requests can continue being processed.
Q. Find the missing term in the series: 34, 42, 58, 82, 114, 154, ?, 258
asked 1xmediumNumber seriesOnline test2021
Ans. 202. Look at the differences between consecutive terms: 42 minus 34 is 8, then 16, 24, 32 and 40. These differences increase by 8 each time, so the next difference is 48. Therefore, the missing term is 154 plus 48, which equals 202.
Q. If you were designing Google Photos, how would you identify smiling faces?
asked 1xmediumDesignHR2020
Ans. I would detect faces in each photo, align and crop them, then run a trained facial expression model that outputs a smile probability. The key detail is separating face detection from smile classification, so the smile model only sees normalised face crops. Results can be stored as metadata for fast search and filtering.
Q. If you are planning to conduct an event as GDSC Lead, what steps would you follow?
asked 1xmediumPlanningManagerial2023
Ans. A strong answer should describe a real or realistic event plan from idea to review. Pick a student-focused event, then emphasise goal setting, audience needs, team roles, budget, venue, promotion, speaker coordination, risk planning and feedback. Interviewers listen for ownership, organisation, inclusion, clear communication and how you measure success after the event.
Q. Evaluate and rate websites based on given images and provide explanations for the ratings
asked 1xmediumLogical reasoningOnline test2017
Ans. Rate each website by comparing visible evidence against clear criteria: layout, readability, navigation, visual appeal, consistency, trust signals, accessibility, and mobile suitability if shown. Give a score that matches the overall quality, then justify it with specific observations from the image rather than personal taste. Mention both strengths and weaknesses.
Q. There are three rooms containing a Princess, Flowers, and a Snake. All rooms have incorrect nameplates. How do you find the Princess’s room without entering the Snake’s room?
asked 1xmediumLogical reasoningOnline test2013
Ans. Enter the room labelled Snake. Its label must be wrong, so it cannot contain the Snake and is safe. If it contains the Princess, you have found her. If it contains Flowers, then the room labelled Princess must contain the Snake, so the room labelled Flowers contains the Princess.
Q. Design a treasure hunt problem where a treasure is hidden in one of n rooms. You start from Room 1 and have r keys that allow movement between rooms, but you do not know which key opens which room pair. Find a strategy to locate the treasure.
asked 1xhardLogical reasoningTechnical2020
Ans. Treat the rooms and keys as an unknown graph. From Room 1, try every key on every available door, record which key works, then move through newly opened doors using depth first search, backtracking with known keys. Check each reached room for treasure. This guarantees success exactly when the room graph is connected from Room 1. Worst case, test about nr key-room possibilities.
Q. Implement a queue using two stacks
asked 1xeasyStack queueTechnical2024
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. What is the time complexity of Heap Sort?
asked 1xeasySortingTechnical2021
Ans. Heap sort sorts an array by first building a binary heap, usually a max heap, then repeatedly swapping the largest element with the last unsorted position and heapifying the reduced heap. Building the heap takes O(n), each removal costs O(log n), so total time is O(n log n). Space is O(1).
Showing 60 of 506 questions. Ranked by how often the same question came back across interviews.