Computer Architecture Interview Questions with Numericals
Last updated 2026-11-19
Computer architecture questions in campus and core-engineering interviews follow two patterns: concept comparisons (RISC versus CISC, Von Neumann versus Harvard, the types of pipeline hazard) and short calculations (pipeline speedup, CPU time from CPI, Amdahl's law, binary and floating-point representation). This page works each calculation with the formula and arithmetic shown, and gives the comparisons in the form interviewers expect.
Memory hierarchy and cache questions are covered in depth on computer organization and cache memory interview questions. Operating system links such as virtual memory are on paging and virtual memory. For wider preparation see how to crack a technical interview and how to crack a technical MCQ test.
| Formulas | CPU time = instructions x CPI / clock rate; speedup = old time / new time |
|---|---|
| Numericals | Pipeline speedup, CPU time, MIPS, Amdahl, branch penalty, two's complement, IEEE 754 |
| Questions | 17 |
The performance equation
- CPU time = instruction count x CPI x clock cycle time = instruction count x CPI / clock rate.
- Three levers: fewer instructions (compiler and ISA), lower CPI (microarchitecture), faster clock (technology). Improving one often hurts another.
- MIPS = clock rate in MHz / CPI, a poor comparison across different instruction sets.
Computer Architecture Interview Questions with Numericals: questions with worked answers
1 Compare Von Neumann and Harvard architectures.
easyIn the Von Neumann architecture instructions and data share one memory and one bus, so the CPU cannot fetch an instruction and read data at the same time (the Von Neumann bottleneck), but the design is simple and flexible, allowing self-modifying code. The Harvard architecture has separate memories and buses for instructions and data, so both can be accessed simultaneously, giving higher throughput; it is common in microcontrollers and DSPs. Modern CPUs are modified Harvard: unified main memory but separate L1 instruction and data caches.
2 Explain the instruction cycle.
easyThe CPU repeatedly fetches an instruction from the address in the program counter and increments the PC, decodes it to determine the operation and operands, fetches the operands (from registers or memory), executes it in the ALU, and writes the result back. Interrupts are checked at the end of each cycle. Pipelining overlaps these stages for different instructions.
3 Compare RISC and CISC.
mediumRISC (ARM, RISC-V, MIPS) uses a small set of simple, fixed-length instructions, mostly register-to-register with load and store as the only memory operations, many registers and easy pipelining; programs need more instructions but each is quick (CPI near 1). CISC (x86) has many complex variable-length instructions that can operate directly on memory, giving compact code and fewer instructions but harder decoding. Modern x86 processors translate CISC instructions into RISC-like micro-operations internally.
4 Numerical: A program has 10^9 instructions, the CPI is 1.5 and the clock is 2 GHz. Find the CPU time and the MIPS rating.
mediumCPU time = instructions x CPI / clock rate = 10^9 x 1.5 / (2 x 10^9) = 0.75 seconds. MIPS = clock rate / (CPI x 10^6) = 2000 MHz / 1.5 = 1333 MIPS, or equivalently 10^9 instructions / (0.75 s x 10^6) = 1333. If a compiler change cuts the instruction count by 20 percent but CPI rises to 1.7, time becomes 0.8 x 10^9 x 1.7 / (2 x 10^9) = 0.68 s, a net speedup of 0.75 / 0.68 = 1.10.
5 What is pipelining and what are the types of hazards?
mediumPipelining overlaps the execution of several instructions by splitting the work into stages (fetch, decode, execute, memory, write-back), so that ideally one instruction completes per cycle. Structural hazards occur when two instructions need the same hardware resource at once. Data hazards occur when an instruction needs a result that an earlier instruction has not yet produced (read after write is the common one). Control hazards occur at branches, when the next instruction to fetch is not yet known.
6 Numerical: A 5-stage pipeline has a 1 ns stage time. How long do 100 instructions take pipelined versus non-pipelined, and what is the speedup?
mediumNon-pipelined: each instruction takes 5 ns, so 100 x 5 = 500 ns. Pipelined: the first instruction needs 5 cycles to complete and each of the remaining 99 finishes one cycle later, so (5 + 99) x 1 = 104 ns. Speedup = 500 / 104 = 4.81. For n instructions and k stages the speedup is nk / (k + n - 1), approaching k as n grows, so the ideal speedup equals the number of stages.
7 How are data hazards handled?
mediumForwarding (bypassing) feeds the ALU result directly to the next instruction's input instead of waiting for the write-back, removing most stalls. A load-use hazard still needs one stall cycle because the loaded value is not available until after the memory stage. The compiler can reorder independent instructions to fill the gap (instruction scheduling). Otherwise the hardware inserts bubbles (stalls) until the value is ready.
8 Numerical: Ideal CPI of a pipeline is 1. 20 percent of instructions are branches and each causes a 3-cycle penalty. Find the effective CPI and the slowdown. What if a predictor is correct 90 percent of the time?
mediumWithout prediction: CPI = 1 + 0.20 x 3 = 1.6, so the pipeline is 1.6 times slower than ideal. With a predictor that is 90 percent right, only 10 percent of branches pay the penalty: CPI = 1 + 0.20 x 0.10 x 3 = 1.06. This is why branch prediction matters so much in deep pipelines, where the penalty can be 15 or more cycles.
9 How does a 2-bit branch predictor work and why is it better than 1-bit?
mediumIt uses a saturating counter per branch with four states: strongly taken, weakly taken, weakly not taken, strongly not taken. A branch must be mispredicted twice before the prediction flips. A 1-bit predictor flips after one miss, so a loop branch that is taken many times and then falls out makes two mispredictions per loop (at exit and on re-entry), while the 2-bit predictor makes only one.
10 Numerical: Amdahl's law. An enhancement speeds up 40 percent of a program's execution time by 10 times. What is the overall speedup and the limit?
mediumSpeedup = 1 / ((1 - f) + f / s) with f = 0.4, s = 10: 1 / (0.6 + 0.04) = 1 / 0.64 = 1.5625. Even with infinite speed-up of that part the limit is 1 / 0.6 = 1.67. The lesson is to optimise the common case: the part you do not improve limits the whole.
11 What is the difference between hardwired and microprogrammed control units?
mediumA hardwired control unit generates control signals with fixed logic circuits (gates and state machines): very fast but costly to design and inflexible, typical of RISC. A microprogrammed control unit stores control sequences as microinstructions in a control memory, so the instruction set is easy to change and complex instructions are easier to implement, but each step needs a control-store lookup, so it is slower. Many CISC processors use it.
12 Explain superscalar, VLIW and multi-core designs.
mediumA superscalar processor issues several instructions per cycle using multiple execution units and hardware that finds independent instructions (out-of-order execution), so CPI can fall below 1. VLIW moves that scheduling to the compiler, which packs independent operations into one long instruction word, simplifying hardware. Multi-core places several processors on one chip to run threads in parallel, which raises throughput when software has parallelism, but is limited by Amdahl's law and by cache coherence and memory bandwidth.
13 State Flynn's taxonomy.
mediumIt classifies machines by instruction and data streams. SISD is a single instruction on single data, the classic uniprocessor. SIMD applies one instruction to many data items, as in vector units and GPUs. MISD has several instructions on one data stream and is rare (some fault-tolerant systems). MIMD has multiple processors executing different instructions on different data, such as multi-core CPUs and clusters.
14 Numerical: Represent -5 in 8-bit two's complement. What is the range of 8-bit two's complement numbers?
easy5 is 00000101. Invert the bits to get 11111010, then add 1 to get 11111011, so -5 is 11111011 (0xFB). Check by adding: 00000101 + 11111011 = 1 00000000, the carry out is discarded, giving 0. The range for n bits is -2^(n-1) to 2^(n-1) - 1, so -128 to 127 for 8 bits. Two's complement has a single zero and lets the same adder do addition and subtraction.
15 Numerical: Show 5.75 in IEEE 754 single precision.
medium5.75 in binary is 101.11 = 1.0111 x 2^2. Sign bit = 0. Exponent = 2 + bias 127 = 129 = 10000001. The mantissa stores the bits after the leading 1: 0111 followed by zeros (23 bits). The 32 bits are 0 10000001 01110000000000000000000, which is 0100 0000 1011 1000 0000 0000 0000 0000 = 0x40B80000. 0.1 cannot be represented exactly in binary, which is why 0.1 + 0.2 is not exactly 0.3 in floating point.
16 What is endianness? How is 0x12345678 stored at address 0x100 on little-endian and big-endian machines?
mediumEndianness is the byte order used to store multi-byte values. Little-endian (x86, most ARM setups) stores the least significant byte first: 0x100 holds 78, 0x101 holds 56, 0x102 holds 34, 0x103 holds 12. Big-endian (network byte order) stores the most significant byte first: 12, 34, 56, 78. It matters when data is sent over a network or shared between systems, so functions like htonl convert between host and network order.
17 What are the common addressing modes, with an example of each?
hardImmediate: the operand is in the instruction (ADD R1, #5). Register: operand in a register (ADD R1, R2). Direct: instruction holds the memory address. Indirect: instruction points to a location that holds the address. Register indirect: a register holds the address (LOAD R1, (R2)). Indexed or base plus displacement: address = register + constant, used for arrays and stack frames (LOAD R1, 8(R2)). PC-relative: address = PC + offset, used for branches and position-independent code. Each trades instruction size, flexibility and the number of memory accesses.
Frequently asked questions
What is the difference between computer architecture and computer organization?
Architecture is what the programmer sees: the instruction set, addressing modes and data types. Organization is how it is implemented: control signals, memory technology, bus design, and pipeline structure. One architecture can have many organizations.
What are registers and why are they fast?
They are storage cells inside the CPU, holding operands and addresses. Being on-chip and few in number, they are accessed in a fraction of a clock cycle, far faster than cache or main memory.
What is the role of the ALU?
The arithmetic logic unit performs integer arithmetic (add, subtract), logic (AND, OR, XOR), shifts and comparisons, producing a result and status flags such as zero, carry and overflow.
What is Moore's law?
The observation that the number of transistors on a chip doubled roughly every two years. It has slowed, which is why performance gains now come more from parallelism and specialised hardware than from clock speed.
Related guides
- Cache Memory and Computer Organization Interview Questions with Numericals
- Operating Systems Interview Questions with Worked Answers
- Paging and Virtual Memory Interview Questions with Numericals
- Memory Management Interview Questions with Numericals
- Process and Thread Interview Questions with fork() Output Problems
- Computer Networks Interview Questions with Worked Answers and Numericals
More in CS Fundamentals Interview Questions
- Computer Networks Interview Questions with Worked Answers and Numericals
- CPU Scheduling Interview Questions with Gantt Chart Numericals
- Database Indexing Interview Questions
- DBMS Concurrency Control Interview Questions
- DBMS Interview Questions and Answers
- DBMS Keys Interview Questions
- Deadlock Interview Questions with Banker's Algorithm Worked Example
- Design Patterns Interview Questions with Code
- Distributed Systems Interview Questions
- DNS Interview Questions: Resolution, Record Types, Caching and Troubleshooting
- ER Model Interview Questions
- File System Interview Questions: Inodes, Allocation and Disk Scheduling