Bird
Raised Fist0
Signal Processingdata~5 mins

ADC and DAC in signal chain in Signal Processing - Time & Space Complexity

Choose your learning style10 modes available
Time Complexity: ADC and DAC in signal chain
O(n)
Understanding Time Complexity

We want to understand how the time to convert signals changes as the signal size grows.

How does the processing time grow when using ADC and DAC in a signal chain?

Scenario Under Consideration

Analyze the time complexity of the following code snippet.


// Simulate ADC and DAC processing on a signal array
function processSignal(signal) {
  let digitalSignal = [];
  for (let i = 0; i < signal.length; i++) {
    digitalSignal[i] = ADC(signal[i]); // Analog to Digital Conversion
  }
  let outputSignal = [];
  for (let i = 0; i < digitalSignal.length; i++) {
    outputSignal[i] = DAC(digitalSignal[i]); // Digital to Analog Conversion
  }
  return outputSignal;
}

function ADC(value) {
  // Simulate conversion delay
  return Math.round(value * 1024) / 1024;
}

function DAC(value) {
  // Simulate conversion delay
  return value;
}
    

This code converts an analog signal array to digital and back to analog by processing each sample.

Identify Repeating Operations
  • Primary operation: Two separate loops each processing every element in the signal array.
  • How many times: Each loop runs once over all n elements, so 2 x n times total.
How Execution Grows With Input

As the signal length grows, the number of operations grows roughly twice as fast because of two loops.

Input Size (n)Approx. Operations
1020
100200
10002000

Pattern observation: The operations grow linearly with input size, doubling due to two passes.

Final Time Complexity

Time Complexity: O(n)

This means the processing time grows in direct proportion to the number of signal samples.

Common Mistake

[X] Wrong: "Because there are two loops, the time complexity is O(n²)."

[OK] Correct: The loops run one after another, not nested, so their times add up, not multiply.

Interview Connect

Understanding how signal processing steps scale helps you explain efficiency in real systems clearly and confidently.

Self-Check

"What if the ADC and DAC steps were combined into a single loop? How would the time complexity change?"

Practice

(1/5)
1. What is the main role of an ADC (Analog-to-Digital Converter) in a signal chain?
easy
A. Store digital data in memory
B. Convert digital data into analog signals
C. Amplify the analog signal before processing
D. Convert real-world analog signals into digital data

Solution

  1. Step 1: Understand ADC function

    An ADC takes continuous analog signals from the real world and changes them into digital numbers that computers can use.
  2. Step 2: Compare options to ADC role

    Only Convert real-world analog signals into digital data describes converting analog signals to digital data, which matches the ADC's main role.
  3. Final Answer:

    Convert real-world analog signals into digital data -> Option D
  4. Quick Check:

    ADC = Analog to Digital conversion [OK]
Hint: ADC always converts analog signals to digital data [OK]
Common Mistakes:
  • Confusing ADC with DAC
  • Thinking ADC amplifies signals
  • Assuming ADC stores data
2. Which of the following is the correct symbol for a DAC (Digital-to-Analog Converter) in a signal chain diagram?
easy
A. A triangle pointing right with 'DAC' label
B. A triangle pointing left with 'DAC' label
C. A triangle pointing right with 'ADC' label
D. A square with 'DAC' label

Solution

  1. Step 1: Recall DAC symbol conventions

    In signal diagrams, DAC is usually shown as a triangle pointing right with the label 'DAC'.
  2. Step 2: Match options to DAC symbol

    A triangle pointing right with 'DAC' label matches this description exactly, while others either have wrong direction or label.
  3. Final Answer:

    A triangle pointing right with 'DAC' label -> Option A
  4. Quick Check:

    DAC symbol = triangle right + 'DAC' label [OK]
Hint: DAC symbol is a right-pointing triangle labeled 'DAC' [OK]
Common Mistakes:
  • Confusing ADC and DAC symbols
  • Choosing left-pointing triangle for DAC
  • Selecting a square shape
3. Consider this Python code simulating a simple ADC conversion of an analog signal sampled at 3 points:
analog_signal = [0.1, 0.5, 0.9]
bit_depth = 2
max_level = 2**bit_depth - 1
adc_output = [int(x * max_level) for x in analog_signal]
print(adc_output)
What is the output printed?
medium
A. [0, 1, 2]
B. [0, 2, 3]
C. [0, 2, 4]
D. [1, 2, 3]

Solution

  1. Step 1: Calculate max_level from bit_depth

    bit_depth is 2, so max_level = 2^2 - 1 = 3.
  2. Step 2: Multiply each analog value by max_level and convert to int

    0.1*3=0.3 -> int=0, 0.5*3=1.5 -> int=1, 0.9*3=2.7 -> int=2.
  3. Final Answer:

    [0, 1, 2] -> Option A
  4. Quick Check:

    2-bit ADC max level 3, scaled values int = [0,1,2] [OK]
Hint: Multiply analog value by max level, then floor to int [OK]
Common Mistakes:
  • Confusing max_level calculation
  • Rounding instead of flooring
  • Misreading bit depth
4. The following code attempts to simulate a DAC converting digital values back to analog signals:
digital_values = [0, 1, 2, 3]
bit_depth = 2
max_level = 2**bit_depth - 1
analog_output = [x / max_level for x in digital_values]
print(analog_output)
However, the output is incorrect for a 3-bit DAC. What is the error?
medium
A. digital_values list is missing values
B. Division should be multiplied by max_level
C. bit_depth should be 3, not 2
D. max_level calculation is wrong

Solution

  1. Step 1: Identify bit_depth mismatch

    The code uses bit_depth=2 but digital_values go up to 3, which fits 2 bits. For 3-bit DAC, bit_depth should be 3.
  2. Step 2: Understand impact on max_level and output

    With bit_depth=3, max_level=7, so dividing digital values by 7 scales correctly. Using 3 causes wrong scaling.
  3. Final Answer:

    bit_depth should be 3, not 2 -> Option C
  4. Quick Check:

    bit_depth must match DAC bits [OK]
Hint: Match bit_depth to DAC bits for correct scaling [OK]
Common Mistakes:
  • Changing division to multiplication
  • Ignoring bit_depth mismatch
  • Assuming digital_values are wrong
5. You have a sensor outputting analog signals between 0 and 5 volts. You want to digitize this signal using a 4-bit ADC and then reconstruct it with a DAC. What is the smallest voltage step (resolution) that the ADC can detect?
medium
A. 5 volts divided by (2^4 - 1) = 0.357 volts
B. 5 volts divided by 2^4 = 0.3125 volts
C. 5 volts divided by (2^4 + 1) = 0.3125 volts
D. 5 volts divided by 2^4 - 1 = 0.3125 volts

Solution

  1. Step 1: Recall the standard resolution formula for an ADC

    The voltage resolution (LSB size) is the full-scale voltage divided by 2^n: V_fs / 2^n, where n is the number of bits.
  2. Step 2: Apply the formula

    Here, V_fs = 5 V, n = 4, so resolution = 5 / 2^4 = 5 / 16 = 0.3125 volts.
  3. Step 3: Match to options

    5 volts divided by 2^4 = 0.3125 volts exactly matches this formula and value. 5 volts divided by (2^4 - 1) = 0.357 volts incorrectly uses (2^4 - 1) and has a miscalculation (5/15 ≈ 0.333, not 0.357).
  4. Final Answer:

    5 volts divided by 2^4 = 0.3125 volts -> Option B
  5. Quick Check:

    Resolution = V_fs / 2^n [OK]
Hint: Resolution = voltage range / 2^bits [OK]
Common Mistakes:
  • Dividing by (2^bits - 1) instead of 2^bits
  • Miscalculating numerical values like 5/15 ≈ 0.333 as 0.357
  • Ambiguous formula parsing in options
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard