Q. Reverse a singly linked list
asked 2xeasyLinked listsTechnical2021
Ans. Reverse it by walking through the list once and redirecting each node’s next pointer to the previous node. Keep three pointers: previous, current, and next, so you do not lose the remaining list. At the end, previous becomes the new head. Time is O(n), space is O(1).
Q. What is a primary key in DBMS?
asked 2xeasyDBMSTechnical2021
Ans. A primary key is a column, or set of columns, that uniquely identifies each row in a database table. Its values must be unique and not null. A table can have only one primary key, and it is commonly used to create relationships with foreign keys in other tables.
Q. Write an SQL query to find the maximum salary from an employee table
asked 2xeasySQLTechnical2021
Ans. Use the SQL aggregate function MAX on the salary column from the employee table. In words, the query selects the maximum value of salary across all employee rows. MAX ignores NULL salaries, and the database usually scans the salary values, so the time complexity is O(n) unless an index can be used.
Q. Explain the Banker's Algorithm.
asked 1xmediumOperating systemsTechnical2016
Ans. The Banker’s Algorithm is a deadlock avoidance method that grants a resource request only if the system remains in a safe state afterwards. It tracks available resources, current allocations, and each process’s maximum need. If some ordering lets all processes finish, the request is safe; otherwise it is delayed.
Q. What is the Reader-Writer problem?
asked 1xmediumOperating systemsTechnical2016
Ans. The Reader-Writer problem is a classic synchronisation problem where many readers may access shared data at the same time, but a writer must have exclusive access. The key issue is coordinating locks so readers do not see inconsistent data, writers do not corrupt data, and neither readers nor writers starve.
Q. How does AsyncTask work in Android?
asked 1xmediumOOPTechnical2014
Ans. AsyncTask runs short background work on a worker thread and posts results back to the UI thread. You typically start it with execute, do work in doInBackground, publish progress with onProgressUpdate, and update UI in onPostExecute. The key caveat is that it is lifecycle-unaware and deprecated, so modern apps use coroutines, WorkManager, or executors.
Q. Explain the memory structure in C++.
asked 1xmediumOperating systemsTechnical2019
Ans. C++ memory is commonly divided into code, static storage, stack and heap. Code holds instructions, static storage holds globals and static variables, the stack holds function calls and local automatic variables, and the heap holds dynamically allocated objects. The key detail is lifetime: stack objects are automatic, while heap objects must be managed or owned safely.
Q. How do you overcome a deadlock state?
asked 1xmediumOperating systemsTechnical2016
Ans. You overcome a deadlock by breaking one of its necessary conditions, usually by terminating one or more processes or preempting resources and rolling them back safely. The key detail is choosing a victim carefully, based on priority, work done, resources held, and rollback cost, to minimise data loss and system impact.
Q. How does multithreading work in Java?
asked 1xmediumOperating systemsTechnical2014
Ans. Multithreading in Java works by running multiple threads within one JVM process, usually mapped to native operating system threads. Each thread has its own call stack but shares the heap, so objects can be accessed concurrently. The key detail is controlling shared state using synchronisation, locks, volatile, or concurrent utilities to avoid race conditions.
Q. Detect a cycle in an undirected graph.
asked 1xmediumGraphsTechnical2019
Ans. Use DFS and track the parent of each visited node; if you reach an already visited neighbour that is not the parent, a cycle exists. Store the graph as an adjacency list and maintain a visited set or array. Run DFS from every unvisited node to cover disconnected graphs. Time is O(V + E), space is O(V).
Q. How can deadlock be prevented and avoided?
asked 1xmediumOperating systemsTechnical2020
Ans. Deadlock can be prevented by ensuring at least one Coffman condition cannot hold, and avoided by allocating resources only when the system remains in a safe state. Prevention commonly uses lock ordering, no hold-and-wait, preemption, or removing mutual exclusion where possible. Avoidance typically uses Banker’s algorithm with known maximum demands.
Q. What happens when we kill a child process?
asked 1xmediumOperating systemsHR2019
Ans. Killing a child process terminates that process, but it does not terminate its parent. The operating system records its exit status and sends SIGCHLD to the parent. Until the parent calls wait or waitpid, the terminated child remains as a zombie process. Any children of the killed process become orphaned and are adopted by init or systemd.
Q. What are volatile and synchronized in Java?
asked 1xmediumOperating systemsTechnical2014
Ans. volatile marks a field so reads and writes go directly through main memory with visibility guarantees between threads. synchronized protects a block or method with a monitor lock, allowing only one thread at a time and also providing visibility. volatile is not enough for compound actions like increment; synchronized can make them atomic.
Q. Write code for the Producer-Consumer problem.
asked 1xmediumOperating systemsTechnical2019
Ans. Use a bounded blocking queue protected by a mutex, with two condition variables or semaphores for not full and not empty. Producers wait when the buffer is full, lock, enqueue an item, unlock, and signal consumers. Consumers wait when empty, lock, dequeue, unlock, and signal producers. Each produce or consume operation is O(1).
Q. How would you implement an STL map internally?
asked 1xmediumData structuresTechnical2013
Ans. I would implement an STL map as a self-balancing binary search tree, typically a red-black tree, storing key-value pairs ordered by the key comparator. Insert, find and erase take O(log n) because the tree stays balanced using rotations and colour changes. In-order traversal gives sorted iteration.
Q. Explain how TCP ensures reliable data transfer.
asked 1xmediumNetworkingTechnical2017
Ans. TCP ensures reliable data transfer by numbering bytes, acknowledging received data, retransmitting lost segments, and delivering data to the application in order. The most important detail is that the sender keeps unacknowledged data and uses timeouts or duplicate acknowledgements to detect loss and resend only what is needed.
Q. Explain inter-process communication mechanisms.
asked 1xmediumOperating systemsTechnical2013
Ans. Inter-process communication lets separate processes exchange data and coordinate execution. Common mechanisms include pipes and FIFOs for byte streams, message queues for structured messages, shared memory for fastest data sharing, sockets for local or network communication, and signals for simple notifications. Shared memory usually needs synchronisation, such as semaphores or mutexes, to avoid races.
Q. Explain different process scheduling algorithms.
asked 1xmediumOperating systemsTechnical2020
Ans. Common process scheduling algorithms include First Come First Served, Shortest Job First, Priority Scheduling, Round Robin and Multilevel Queue scheduling. FCFS is simple but can cause long waits, SJF minimises average waiting time if burst times are known, Priority favours important jobs, and Round Robin gives each process a time slice for fairness.
Q. What are the types of inheritance in JavaScript?
asked 1xmediumJavaScriptTechnical2017
Ans. JavaScript mainly uses prototypal inheritance, where objects inherit from other objects through the prototype chain. In practice, this appears as prototype chain inheritance, constructor or class-based inheritance using extends, and mixin-style composition. JavaScript does not support true multiple class inheritance, but objects can share behaviour through prototypes or mixins.
Q. What is a trie data structure? Where is it used?
asked 1xmediumTreesManagerial2019
Ans. A trie is a tree-like data structure used to store strings by their prefixes, with each edge usually representing a character. It is used for fast prefix lookup, autocomplete, spell checking, dictionary search, IP routing and word games. Lookup, insert and delete typically take time proportional to the string length.
Q. Implement an LRU cache given function prototypes.
asked 1xmediumDesignOnline test2013
Ans. Use a hash map plus a doubly linked list. The map stores key to node, and the list stores usage order, with most recently used at the front and least recently used at the back. On get or put, move the node to the front. Evict the back node when capacity is exceeded. Operations are O(1).
Q. Technical aptitude questions involving C pointers.
asked 1xmediumOOPOnline test2019
Ans. A C pointer is a variable that stores the address of another object or function. Use & to take an address and * to dereference it. The key detail is that pointer type controls how dereferencing and pointer arithmetic work, so invalid, uninitialised, or freed pointers can cause undefined behaviour.
Q. Explain the complete working of the Unix ls command.
asked 1xmediumOperating systemsTechnical2019
Ans. ls parses options and path arguments, gets file metadata with stat or lstat, opens directories with opendir, reads entries with readdir, sorts them, then prints names and requested details. For long format it shows permissions, links, owner, group, size and time. Hidden files are skipped unless requested, and errors come from permission or missing paths.
Q. Explain the working of ping and traceroute commands.
asked 1xmediumNetworkingHR2019
Ans. Ping checks reachability by sending ICMP Echo Request packets to a host and measuring Echo Replies, showing round trip time and packet loss. Traceroute finds the path to a host by sending packets with increasing TTL values, causing each router to return ICMP Time Exceeded, revealing each hop and its latency.
Q. Explain segmentation and paging in operating systems.
asked 1xmediumOperating systemsTechnical2017
Ans. Segmentation divides a process’s memory into logical variable-sized parts such as code, stack and heap, while paging divides memory into fixed-size pages mapped to physical frames. Segmentation matches the programmer’s view but can cause external fragmentation. Paging simplifies allocation and avoids external fragmentation, but needs page tables and can cause internal fragmentation.
Q. Explain the concept of thrashing in operating systems.
asked 1xmediumOperating systemsTechnical2020
Ans. Thrashing is when an operating system spends most of its time swapping pages between memory and disk instead of executing processes. It happens when the working sets of active processes exceed physical memory, causing frequent page faults. Performance collapses, and it is usually fixed by reducing multiprogramming or adding memory.
Q. Answer questions related to Operating Systems concepts.
asked 1xmediumOperating systemsManagerial2019
Ans. An operating system manages hardware resources and provides services for programs. It handles processes, memory, files, devices, security and scheduling. The key idea is abstraction: applications use simple interfaces like files, virtual memory and system calls instead of controlling hardware directly. This makes programs safer, portable and easier to run concurrently.
Q. Check whether a given IP address is valid or not (IPv4)
asked 1xmediumStringsTechnical2021
Ans. Split the string by dots and check that it has exactly four parts. Each part must be non-empty, contain only digits, have value from 0 to 255, and should not have leading zeroes unless it is exactly "0". Use an array of parts after splitting. Time complexity is O(n).
Q. Explain AVL trees and Red-Black trees and compare them.
asked 1xmediumTreesTechnical2013
Ans. AVL trees and Red-Black trees are self-balancing binary search trees that keep operations at O(log n). AVL trees maintain stricter balance using height differences, so lookups are often faster but inserts and deletes may need more rotations. Red-Black trees use colour rules, giving looser balance and typically cheaper updates.
Q. Explain the Producer-Consumer problem and its solution.
asked 1xmediumOperating systemsTechnical2013
Ans. The Producer-Consumer problem is a synchronisation problem where producers add items to a shared buffer and consumers remove them without race conditions or buffer overflow/underflow. The usual solution uses a mutex for mutual exclusion and semaphores or condition variables to track empty and full slots, blocking threads when needed.
Q. What happens when you enter a website URL in a browser?
asked 1xmediumNetworkingTechnical2016
Ans. The browser resolves the URL to an IP address, connects to the server, requests the page, receives a response, and renders it. Typically it checks caches first, uses DNS if needed, opens a TCP connection with TLS for HTTPS, sends an HTTP request, then parses HTML, CSS, and JavaScript to display the page.
Q. What happens when you type www.google.com in a browser?
asked 1xmediumNetworkingTechnical2017
Ans. The browser resolves www.google.com to an IP address, connects to it, requests the page, receives a response, and renders it. The key detail is DNS lookup first, often using caches. Then the browser opens a TCP connection, negotiates TLS for HTTPS, sends an HTTP request, downloads resources, and builds the page.
Q. Explain Word2Vec and how words can be compared using it.
asked 1xmediumMachine learningTechnical2019
Ans. Word2Vec represents words as dense numeric vectors learned from their context in large text, so words used in similar contexts get similar vectors. It is usually trained with CBOW or skip-gram. Words are compared by measuring vector similarity, commonly cosine similarity, where closer directions mean more similar meanings.
Q. How does an Android application connect to a web server?
asked 1xmediumNetworkingTechnical2014
Ans. An Android application connects to a web server by making HTTP or HTTPS requests using a networking API or library such as Retrofit, OkHttp, or HttpURLConnection. The app must declare internet permission, run network work off the main thread, send requests to server endpoints, and handle responses, often as JSON.
Q. What is the size of an empty class object in C++ and why?
asked 1xmediumOOPTechnical2017
Ans. An empty class object in C++ has size at least 1 byte. This is required so that two distinct objects of the same type can have different addresses. The exact size is implementation dependent, but it is commonly 1 byte. As a base class, it may take no extra space due to empty base optimisation.
Q. Reverse words in a given string without using extra space.
asked 1xmediumStringsTechnical2020
Ans. Reverse the whole string in place, then scan it and reverse each word in place. For example, “the sky is blue” becomes “eulb si yks eht”, then each word is fixed to “blue is sky the”. Use the string’s character array if mutable. Time is O(n), extra space is O(1).
Q. Explain different types of joins and normalization in DBMS.
asked 1xmediumDBMSTechnical2020
Ans. Joins combine rows from related tables, while normalization structures tables to reduce redundancy and improve consistency. Common joins are inner join, left join, right join, full outer join, cross join and self join. Normalization uses forms such as 1NF, 2NF and 3NF to remove repeating groups, partial dependencies and transitive dependencies.
Q. Given a 2D array, find the maximum sum contiguous subarray.
asked 1xmediumArraysTechnical2016
Ans. Use a 2D extension of Kadane’s algorithm to find the maximum sum rectangle. Fix a pair of columns, collapse rows into a 1D array of sums between those columns, then run Kadane’s algorithm on it. Repeat for all column pairs. This takes O(cols² × rows) time and O(rows) extra space.
Q. Name different protocols at each layer in Computer Networks.
asked 1xmediumNetworkingTechnical2020
Ans. Application: HTTP, HTTPS, FTP, SMTP, DNS; Transport: TCP, UDP; Network: IP, ICMP, ARP; Data Link: Ethernet, PPP, Wi-Fi MAC; Physical: USB, Bluetooth, DSL, Ethernet physical standards. In the OSI model, Session and Presentation are often represented by TLS, SSL, NetBIOS, JPEG or ASCII, but in TCP/IP they are usually folded into Application.
Q. Find the maximum of all subarrays of size k in a given array.
asked 1xmediumArraysOnline test2020
Ans. Use a deque to store indices of useful elements in decreasing value order as you scan the array. Remove indices outside the current window from the front, remove smaller elements from the back, then add the current index. Once the first window is formed, the front gives each maximum. Time is O(n), space is O(k).
Q. Explain inheritance, the this pointer, and other OOP concepts.
asked 1xmediumOOPTechnical2019
Ans. Inheritance lets a class reuse and extend another class’s behaviour, while the this pointer refers to the current object instance. Core OOP concepts are encapsulation, which hides internal state, abstraction, which exposes essential behaviour, polymorphism, which allows different implementations through a common interface, and composition, which builds objects from other objects.
Q. Implement Depth First Search (DFS) with and without recursion.
asked 1xmediumGraphsTechnical2019
Ans. DFS recursively visits a node, marks it seen, then calls itself for each unseen neighbour; iteratively, use an explicit stack to do the same traversal. The key detail is maintaining a visited set to avoid cycles. With an adjacency list, time is O(V + E) and space is O(V).
Q. Explain collisions in hashing and how collisions can be avoided.
asked 1xmediumData structuresTechnical2019
Ans. A collision occurs when two different keys produce the same hash table index. Collisions cannot usually be avoided completely, but they can be reduced with a good hash function, a larger table, and resizing when the load factor grows. They are handled using chaining or open addressing.
Q. Solve the equation yx × 7 = zxx and find the digits x, y, and z.
asked 1xmediumLogical reasoningTechnical2014
Ans. The solution is x = 5, y = 6, z = 4. In the units column, 7 times x must end in x, so x is 0 or 5. x = 0 gives no valid two-digit yx. With x = 5, 7 × 5 = 35, carry 3. Then 7y + 3 = 45, so y = 6 and z = 4.
Q. Explain load balancing and how it is used in distributed systems.
asked 1xmediumScalabilityManagerial2019
Ans. Load balancing distributes incoming requests across multiple servers so no single server is overloaded and the system stays available and responsive. In distributed systems, a load balancer sits in front of service instances and routes traffic using methods such as round robin, least connections, or health-aware routing, avoiding unhealthy nodes.
Q. Difference between spinlock and semaphore and when to prefer each.
asked 1xmediumOperating systemsTechnical2017
Ans. A spinlock makes a waiting thread repeatedly poll until the lock is free, while a semaphore can block the thread and let the scheduler run something else. Prefer spinlocks only for very short critical sections where sleeping is too expensive or impossible, such as kernel interrupt contexts. Prefer semaphores for longer waits or resource counting.
Q. What is a context switch and where are processes stored during it?
asked 1xmediumOperating systemsTechnical2020
Ans. A context switch is when the CPU stops running one process or thread and starts running another. The operating system saves the current execution state, such as registers, program counter and stack pointer, in that process’s Process Control Block in kernel memory, then loads the saved state of the next scheduled process.
Q. What is the difference between multiprogramming and multithreading?
asked 1xmediumOperating systemsTechnical2020
Ans. Multiprogramming runs multiple programs on one system by switching the CPU between them, while multithreading runs multiple threads within the same process. The key difference is resource sharing: programs usually have separate memory spaces, but threads share the same process memory, making communication faster but requiring careful synchronisation.
Q. Measure exactly 6 liters of water using 4-liter and 9-liter buckets.
asked 1xmediumLogical reasoningTechnical2019
Ans. Fill the 9-litre bucket and pour into the 4-litre bucket twice, emptying the 4-litre bucket each time. This leaves 1 litre in the 9-litre bucket. Pour that 1 litre into the 4-litre bucket. Fill the 9-litre bucket again, then pour 3 litres into the 4-litre bucket, leaving exactly 6 litres.
Q. What are system calls? Explain fork() and exec() and how they differ.
asked 1xmediumOperating systemsTechnical2020
Ans. System calls are the controlled interface through which a user program asks the operating system kernel to perform privileged work, such as process creation, file I/O or networking. fork() creates a new child process as a copy of the calling process. exec() replaces the current process image with a new program. fork() duplicates; exec() transforms.
Q. Find the maximum contiguous subarray sum with an additional constraint.
asked 1xmediumArraysTechnical2020
Ans. Use Kadane’s algorithm extended with a length constraint, most commonly “at least k elements”. Keep the sum of each k-sized window, and add the best positive subarray sum ending just before it. Track the maximum seen. This uses prefix or rolling sums, runs in O(n), and can use O(1) extra space.
Q. How do client and server processes communicate in a distributed system?
asked 1xmediumNetworkingTechnical2020
Ans. Client and server processes communicate by exchanging messages over a network, usually through sockets using protocols such as TCP, UDP, HTTP, or RPC. The client sends a request to the server’s network address and port, and the server processes it and sends a response. Data must be serialised into a shared format.
Q. Prove that the number between two twin prime numbers is always divisible by 6.
asked 1xmediumNumber theoryTechnical2019
Ans. For any twin primes greater than 3, the middle number is divisible by 6. Every prime greater than 3 is odd, so the middle number is even. Also, among any three consecutive numbers, one is divisible by 3. The twin primes cannot be, so the middle one is. Hence it is divisible by 2 and 3.
Q. What would you do if you had a different opinion from that of your team leader?
asked 1xmediumConflict resolutionHR2019
Ans. Pick a situation where you challenged respectfully and helped the team decide better. Emphasise listening first, checking facts, sharing your view privately or calmly in the right forum, and accepting the final decision once made. Interviewers listen for judgement, humility, evidence-based thinking, and whether you can disagree without damaging trust.
Q. Describe past difficulties you faced while working in a team and how you handled them.
asked 1xmediumTeamworkHR2019
Ans. Choose a real team difficulty where your actions made a clear difference, such as conflict, unclear ownership, missed deadlines, or uneven contribution. Emphasise how you stayed professional, listened, clarified responsibilities, communicated early, and helped reach a practical outcome. Interviewers listen for self-awareness, accountability, collaboration, and learning rather than blame.
Q. Given n cores, allocate a random available port (from 65535 ports) to a core requesting a port.
asked 1xmediumResource allocationTechnical2021
Ans. Use a shared port allocator holding all free ports in an array, plus a map from port to its index. On request, lock it, pick a random index below the current free count, return that port, swap it with the last free entry, and decrement the count. Allocation and release are O(1).
Q. How would you convince a team member if you are confident that your idea is better than theirs?
asked 1xmediumLeadershipHR2019
Ans. Choose a real example where evidence, not ego, changed the outcome. Emphasise listening first, understanding their reasoning, then comparing options using data, customer impact, risk, and team goals. Show that you invited challenge and accepted the final decision. Interviewers listen for influence, humility, collaboration, and sound judgement under disagreement.
Q. How would you test an ATM machine from a technical perspective before putting it into production?
asked 1xmediumTestingHR2019
Ans. I would test the ATM end to end in a staging environment with simulated and real hardware, covering card reading, PIN validation, balance enquiry, withdrawal, deposit, receipt, reversals, timeouts and network loss. The most important detail is transaction correctness: cash dispensed, account debited and audit logs must always reconcile, even after failures.
Q. A race track has 2 equal laps. To win, a driver must average 80 km/h overall. If the first lap is driven at 40 km/h, what speed is required in the second lap?
asked 1xmediumProbabilityTechnical2019
Ans. An infinite speed is required, so it is impossible. For equal distances, work with time, not the simple average of speeds. Let each lap be distance d. To average 80 km/h over 2d, total time must be 2d/80, which is d/40. The first lap at 40 km/h already takes d/40.
Q. Given two nested loop snippets that both result in 10,000 iterations, which one is more efficient and why?
asked 1xeasyLogical reasoningTechnical2019
Ans. They are usually equally efficient in Big O terms because both execute the loop body 10,000 times. To solve these, multiply the loop counts to get total iterations, then compare any extra work such as initialisation, condition checks and increments. If the body is the same, any difference is only a small constant factor.
Showing 60 of 217 questions. Ranked by how often the same question came back across interviews.