Technical practice questions
Computer Engineering Interview Questions
Real Computer Engineering interview questions with answers. Filter by sub-field and difficulty, then drill them in practice mode.
Showing 33 of 33 questions
Fundamentals and definitions every candidate should know
Applied reasoning, design tradeoffs, and calculations
Deeper scenarios, system design, and edge cases for stretch practice
What is Big-O notation and why does it matter?
Big-O describes how an algorithm's time or memory grows with input size n. You keep the dominant term and drop constants, like O(1), O(log n), O(n), O(n log n), and O(n^2). It tells you how well something scales. An O(n^2) approach that's fine on 100 items can be unusable on a million. Expect to state and justify the complexity of your own solution.
Companies known to ask: Google, Amazon, Meta, most SWE
Compare an array and a linked list.
Arrays give O(1) indexed access and cache-friendly contiguous memory but O(n) insert/delete in the middle and fixed/resizing cost. Linked lists give O(1) insert/delete given a node reference but O(n) access and poor cache locality with per-node pointer overhead. Choose by access pattern: random access favors arrays; frequent middle insertion favors lists.
Companies known to ask: general SWE screener
What's the difference between a stack and a queue?
A stack is LIFO (last-in-first-out), push/pop at one end; used for recursion, undo, expression parsing. A queue is FIFO (first-in-first-out), enqueue at back, dequeue at front; used for scheduling, BFS, buffering. Both are abstract data types implementable with arrays or linked lists.
Companies known to ask: general SWE
What is a hash table and what are its tradeoffs?
A hash table maps keys to values using a hash function to index buckets, giving average O(1) insert/lookup/delete. Tradeoffs: worst-case O(n) under many collisions, no inherent ordering, and it needs a good hash function and resize (load-factor) strategy. Collisions are handled by chaining or open addressing.
Companies known to ask: Google, Amazon, general SWE
What's the difference between a compiled and an interpreted language?
A compiled language (C, C++, Rust) is translated to machine code ahead of time, giving fast execution but a build step and platform-specific binaries. An interpreted language (Python, JavaScript) is executed line-by-line by a runtime, giving portability and fast iteration but slower execution. Many modern languages blend both (JIT, bytecode).
Companies known to ask: general SWE screener
Explain the difference between value and reference semantics.
With value semantics, a variable holds its own copy of the data, so assigning or passing it copies the value and changes don't propagate. With reference semantics, the variable holds a reference to shared data, so changes are visible everywhere that reference points. Misunderstanding this causes aliasing bugs, a very common source of interview follow-ups.
Companies known to ask: general SWE
What is recursion and when would you avoid it?
Recursion is when a function calls itself on a smaller subproblem until a base case. It's elegant for naturally recursive structures (trees, divide-and-conquer). Avoid it when depth can be large (risk of stack overflow) or when an iterative solution is clearer/faster; deep recursion may need tail-call optimization or conversion to an explicit stack.
Companies known to ask: general SWE
What is the difference between TCP and UDP?
TCP is connection-oriented and reliable: it guarantees ordered, error-checked delivery via handshakes, acknowledgments, and retransmission, used for web, email, file transfer. UDP is connectionless and best-effort: no delivery/ordering guarantees but low latency and overhead, used for streaming, gaming, DNS. Choose by whether reliability or speed matters more.
Companies known to ask: backend, systems roles
When would you use a hash map vs. a tree map?
A hash map gives average O(1) operations but no ordering; a balanced tree map (e.g., red-black tree) gives O(log n) operations with sorted key traversal and efficient range queries. Use a hash map for fast unordered lookups; use a tree map when you need ordering, range queries, or predictable worst-case behavior.
Companies known to ask: Google, Amazon, Meta
Explain BFS vs. DFS and when to use each.
BFS explores level by level using a queue, finds shortest paths in unweighted graphs and explores nearest nodes first, at higher memory cost. DFS explores as deep as possible using a stack or recursion, lower memory on wide graphs, good for topological sort, cycle detection, and path existence. Choose by whether you need shortest path (BFS) or full/deep exploration (DFS).
Companies known to ask: Google, Amazon, Meta
What's the difference between a process and a thread?
A process is an independent program with its own memory space; a thread is a lighter unit of execution within a process that shares the process's memory. Threads are cheaper to create and communicate (shared memory) but require synchronization to avoid races; processes are isolated (a crash in one doesn't corrupt another) but costlier to context-switch and communicate via IPC.
Companies known to ask: Amazon, Google, systems roles
What is a deadlock and how do you prevent it?
A deadlock is when threads/processes each hold a resource and wait on another, so none proceed. It requires four conditions (mutual exclusion, hold-and-wait, no preemption, circular wait). Prevent it by breaking one: acquire locks in a consistent global order, use timeouts/try-lock, avoid hold-and-wait, or allow preemption. Detection-and-recovery is the alternative to prevention.
Companies known to ask: systems, backend roles
What does the 'volatile' keyword do in embedded C?
volatile tells the compiler a variable may change outside normal program flow, so it must always read/write actual memory and not optimize accesses away. Required for memory-mapped hardware registers, ISR-shared variables, and flags set by other contexts. Omitting it can cause the compiler to cache a stale value and miss hardware/ISR updates. (See the full Embedded set on the Electrical tab.)
Companies known to ask: Google, Amazon, Nvidia embedded
Compare I2C, SPI, and UART.
UART is asynchronous, two wires (TX/RX), no clock, point-to-point, simple but limited speed/distance. SPI is synchronous, full-duplex, fast, uses 4 wires (MOSI/MISO/SCLK/CS) with one master and per-device chip selects. I2C is synchronous, two wires (SDA/SCL) shared by many addressable devices, slower but wiring-efficient. Choose by speed, pin count, and number of devices.
Companies known to ask: embedded/firmware roles
Given an array of integers, find two numbers that add up to a target. How do you optimize it?
The canonical hash-map problem. Brute force checks all pairs in O(n^2). Optimize to O(n): iterate once, and for each number check if (target - number) is already in a hash set/map; if so you found the pair, otherwise add the number and continue. Discuss edge cases: duplicates, negatives, and no valid pair. State the time/space tradeoff (O(n) time, O(n) space).
Companies known to ask: Google, Amazon, Meta, most SWE
How do you reverse a linked list, iteratively and recursively?
Iterative: use three pointers, prev (null), current (head), next; for each node save next, point current to prev, then advance prev and current. Recursive: recurse to the end, then re-point each node on the way back. Both are expected; prefer the iterative version in production since deep recursion risks stack overflow. Common follow-up: reverse only positions m to n.
Companies known to ask: Google, Amazon, Meta
How would you detect a cycle in a linked list?
Use Floyd's tortoise-and-hare: advance one pointer by one node and another by two each step. If they ever meet, there's a cycle; if the fast pointer reaches null, there isn't. It runs in O(n) time and O(1) space, beating the O(n)-space hash-set approach of storing visited nodes. A classic follow-up is finding the cycle's start node.
Companies known to ask: Google, Amazon, Meta
Explain binary search and its time complexity.
Binary search finds a target in a sorted array by repeatedly halving the search range: compare the middle element, then recurse/iterate into the left or right half. It runs in O(log n) time versus O(n) for linear search. Key requirement: the data must be sorted. Watch for off-by-one errors in the low/high/mid bounds, a common interview stumble.
Companies known to ask: general SWE
Explain the four pillars of object-oriented programming with an example.
Encapsulation means bundling data and methods in a class and limiting direct access. Think of a capsule you swallow without seeing the chemicals. Abstraction means hiding the complexity and exposing only what's needed, like a steering wheel that hides the engine. Inheritance lets a child class reuse a parent's properties (Dog inherits from Animal). Polymorphism lets the same method act differently by context, so speak() returns 'Woof' or 'Meow'. Almost every new-grad interview touches these.
Companies known to ask: general SWE, most companies
What's the difference between stack and heap memory?
The stack stores function call frames and local variables, is fast, LIFO-managed automatically, and limited in size (deep recursion overflows it). The heap is a larger pool for dynamically allocated memory (malloc/new) that you manage manually or via a garbage collector, is slower, and can fragment. Knowing where variables live explains lifetime, scope, and memory bugs.
Companies known to ask: systems, general SWE
What is a RESTful API and how does it differ from SOAP?
REST is an architectural style using standard HTTP methods (GET, POST, PUT, DELETE) on resources identified by URLs, typically exchanging JSON, and is stateless and lightweight. SOAP is a stricter protocol using XML envelopes with built-in standards for security and transactions, heavier but more rigid. REST dominates web/mobile APIs for its simplicity; SOAP persists in enterprise/legacy systems needing formal contracts.
Companies known to ask: backend, full-stack roles
What's the difference between HTTP GET and POST?
GET requests data and should be safe and idempotent, passing parameters in the URL/query string (visible, cacheable, length-limited). POST submits data to create or change state, carrying it in the request body (not cached, no length limit, better for sensitive data). Use GET to read, POST to create/modify. Misusing GET for state changes is a common bug and security issue.
Companies known to ask: web, backend roles
What is a database index and what's the tradeoff?
An index is a data structure, often a B-tree, that lets the database find rows by a column's value without scanning the whole table. It turns slow lookups into fast ones. The tradeoff is that indexes take storage and slow down writes, because every insert, update, and delete has to update the index too. Add them to columns you filter or join on a lot.
Companies known to ask: backend, data roles
Compare SQL and NoSQL databases.
SQL (relational) databases use structured tables with a fixed schema, strong ACID transactions, and powerful joins, good for complex queries and data integrity. NoSQL databases (document, key-value, columnar, graph) use flexible schemas and scale horizontally, trading some consistency for performance and scalability. Choose SQL for structured, transaction-heavy data; NoSQL for large-scale, evolving, or unstructured data.
Companies known to ask: backend, data roles
How do you use Git branching and merging in a team?
Work on feature branches off a main branch. Commit often with clear messages, then open a pull request for review before merging back. When you hit a conflict, understand both changes before you pick. Common models are the feature-branch workflow and Gitflow. The point is showing you can work with a team without overwriting other people's work.
Companies known to ask: any team SWE role
Explain polling vs. interrupt-driven I/O.
Polling repeatedly checks a device's status in a loop, which is simple but wastes CPU cycles and can miss fast events. Interrupt-driven I/O lets the device signal the CPU when it needs attention, so the CPU does other work and responds only when an event fires, which is more efficient and responsive but adds complexity (ISRs, priorities). Real-time systems favor interrupts for time-critical events.
Companies known to ask: embedded/firmware roles
How would you check if a string is a palindrome?
Use two pointers, one at the start and one at the end, moving inward and comparing characters; if any pair differs it's not a palindrome. It's O(n) time and O(1) space. Alternatively reverse the string and compare, but that uses O(n) extra space. Clarify edge cases first: case sensitivity, spaces, and non-alphanumeric characters (a common follow-up is ignoring them).
Companies known to ask: general SWE, most companies
What is a stack overflow and what commonly causes it?
A stack overflow happens when the call stack runs past its size limit. It usually comes from recursion that never stops or goes too deep, like a missing or wrong base case, or from very large local variables on the stack. To fix it, make sure the base case is right, turn deep recursion into a loop with your own stack, or use a structure that supports tail calls. It's a different problem from running out of heap memory.
Companies known to ask: general SWE
What's the difference between a breadth-first and depth-first tree traversal, and name the depth-first orders?
BFS visits nodes level by level using a queue. DFS goes as deep as possible before backtracking, using recursion or a stack. DFS has three orders for binary trees: pre-order (node, left, right), in-order (left, node, right, which yields sorted order for a BST), and post-order (left, right, node, useful for deleting/freeing). Choosing the order matters for the task.
Companies known to ask: general SWE
What is a race condition and how do you prevent it?
A race condition is when the correctness of a program depends on the unpredictable timing/interleaving of concurrent threads accessing shared state, producing intermittent, hard-to-reproduce bugs. Prevent it by protecting shared data with synchronization, mutexes/locks, atomic operations, or by avoiding shared mutable state altogether (immutability, message passing). The key insight is identifying the unguarded shared resource.
Companies known to ask: backend, systems roles
What happens when you type a URL into a browser and press enter?
This is a classic systems question. DNS turns the domain into an IP address. The browser opens a TCP connection, plus a TLS handshake for HTTPS, and sends an HTTP request. The server handles it and sends back a response. The browser parses the HTML, requests the CSS, JS, and images, builds the DOM, and draws the page. Walk through the layers in order and go deeper depending on the role.
Companies known to ask: general SWE, systems roles
What is caching and what problems does it introduce?
Caching stores frequently accessed data in faster storage (memory, CPU cache, CDN) to cut latency and load. The tradeoff is that cached data can become stale, so you need an invalidation/expiration strategy (TTL, write-through, write-back), and you face cache-coherence and eviction-policy (LRU) decisions. As the saying goes, cache invalidation is one of the hard problems, naming that shows maturity.
Companies known to ask: backend, systems roles
What is a watchdog timer and why is it used?
A watchdog timer is a hardware countdown timer that resets the system if it isn't periodically 'kicked' (refreshed) by the software. If firmware hangs or gets stuck in a bad state, it stops kicking the watchdog, which then forces a reset to recover, critical for unattended embedded systems that must be reliable. It's a safety net against software lockups.
Companies known to ask: embedded/firmware roles