Bird
Raised Fist0
Signal Processingdata~20 mins

Sampling and reconstruction in communication in Signal Processing - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Sampling and Reconstruction Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Nyquist Rate and Sampling Frequency

What is the minimum sampling frequency required to perfectly reconstruct a signal with a maximum frequency of 5 kHz?

A10 kHz
B5 kHz
C2.5 kHz
D15 kHz
Attempts:
2 left
💡 Hint

Recall the Nyquist theorem which states the sampling frequency must be at least twice the maximum frequency.

❓ Predict Output
intermediate
2:00remaining
Output of Sampling a Sine Wave

What is the output array when sampling a 1 Hz sine wave at 4 Hz for 1 second?

Signal Processing
import numpy as np
fs = 4  # sampling frequency
f = 1   # signal frequency
t = np.arange(0, 1, 1/fs)
samples = np.sin(2 * np.pi * f * t)
print(np.round(samples, 2))
A[0. 0.71 1. 0.71]
B[0. 1. 0. -1. ]
C[0. 0.5 0. -0.5]
D[1. 0. -1. 0. ]
Attempts:
2 left
💡 Hint

Calculate sine values at 0, 0.25, 0.5, 0.75 seconds.

❓ data_output
advanced
2:30remaining
Reconstruction Filter Effect

Given a sampled signal with aliasing, which output array shows the effect of applying an ideal low-pass reconstruction filter?

Signal Processing
import numpy as np
import matplotlib.pyplot as plt
fs = 8
f_signal = 5
t = np.arange(0, 1, 1/fs)
sampled = np.sin(2 * np.pi * f_signal * t) + 0.5 * np.sin(2 * np.pi * 3 * t)
# Ideal low-pass filter removes frequencies above 4 Hz
reconstructed = 0.5 * np.sin(2 * np.pi * 3 * t)
print(np.round(reconstructed, 2))
A[0. 0.71 0. -0.71 0. 0.71 0. -0.71]
B[0. 1. 0. -1. 0. 1. 0. -1. ]
C[0. 0.5 0. -0.5 0. 0.5 0. -0.5 ]
D[0. 0. 0. 0. 0. 0. 0. 0. ]
Attempts:
2 left
💡 Hint

The low-pass filter removes frequency components above 4 Hz, keeping the 3 Hz component.

❓ visualization
advanced
3:00remaining
Visualizing Aliasing Effect

Which plot correctly shows aliasing when sampling a 7 Hz sine wave at 10 Hz?

Signal Processing
import numpy as np
import matplotlib.pyplot as plt
fs = 10
f = 7
t = np.linspace(0, 1, 1000)
signal = np.sin(2 * np.pi * f * t)
sampled_t = np.arange(0, 1, 1/fs)
sampled_signal = np.sin(2 * np.pi * f * sampled_t)
plt.figure(figsize=(8,4))
plt.plot(t, signal, label='Original Signal')
plt.stem(sampled_t, sampled_signal, linefmt='r-', markerfmt='ro', basefmt='k-', label='Samples')
plt.legend()
plt.title('Sampling 7 Hz signal at 10 Hz')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.grid(True)
plt.show()
APlot shows sampled points matching a 3 Hz sine wave pattern due to aliasing.
BPlot shows sampled points matching the original 7 Hz sine wave perfectly.
CPlot shows random scattered points with no pattern.
DPlot shows sampled points matching a 10 Hz sine wave.
Attempts:
2 left
💡 Hint

Sampling below twice the signal frequency causes aliasing, making the sampled points look like a lower frequency.

🔧 Debug
expert
3:00remaining
Identify the Error in Reconstruction Code

What error will occur when running this reconstruction code snippet?

Signal Processing
import numpy as np
fs = 8
f = 3
# Sampled signal
samples = np.sin(2 * np.pi * f * np.arange(0, 1, 1/fs))
# Reconstruction using sinc interpolation
def reconstruct(t, samples, fs):
    n = np.arange(len(samples))
    return np.sum(samples[n] * np.sinc(fs * (t - n / fs)))
reconstructed_signal = [reconstruct(ti, samples, fs) for ti in np.linspace(0, 1, 100)]
print(np.round(reconstructed_signal[:5], 2))
ANameError: name 'sinc' is not defined
BNo error, outputs reconstructed signal array
CValueError: operands could not be broadcast together
DTypeError: only integer scalar arrays can be converted to a scalar index
Attempts:
2 left
💡 Hint

Check how the sum function is used with arrays inside the reconstruct function.

Practice

(1/5)
1. What is the main purpose of sampling in communication systems?
easy
A. To convert a continuous signal into discrete values
B. To amplify the signal strength
C. To filter out noise from the signal
D. To encrypt the signal for security

Solution

  1. Step 1: Understand the role of sampling

    Sampling takes a continuous-time signal and measures its amplitude at discrete time intervals.
  2. Step 2: Identify the purpose in communication

    This process allows the signal to be represented digitally for processing and transmission.
  3. Final Answer:

    To convert a continuous signal into discrete values -> Option A
  4. Quick Check:

    Sampling = Continuous to discrete conversion [OK]
Hint: Sampling means turning smooth signals into numbers [OK]
Common Mistakes:
  • Confusing sampling with filtering
  • Thinking sampling increases signal strength
  • Mixing sampling with encryption
2. Which of the following is the correct Nyquist sampling rate formula for a signal with maximum frequency f_max?
easy
A. f_s > f_max / 2
B. f_s > 2 * f_max
C. f_s = f_max
D. f_s < f_max / 2

Solution

  1. Step 1: Recall Nyquist theorem

    The Nyquist rate states the sampling frequency must be greater than twice the highest frequency in the signal.
  2. Step 2: Apply to formula

    So, f_s > 2 * f_max ensures no loss of information during sampling.
  3. Final Answer:

    f_s > 2 * f_max -> Option B
  4. Quick Check:

    Nyquist rate = 2 * max frequency [OK]
Hint: Sample faster than twice the highest frequency [OK]
Common Mistakes:
  • Using sampling rate less than max frequency
  • Confusing less than and greater than signs
  • Ignoring the factor of 2 in Nyquist rate
3. Given a continuous signal with maximum frequency 3 kHz, what is the minimum sampling frequency to avoid aliasing? Choose the correct Python code output.
f_max = 3000
f_s = 2 * f_max
print(f_s)
medium
A. 6000
B. 1500
C. 3000
D. 9000

Solution

  1. Step 1: Calculate minimum sampling frequency

    Using Nyquist, minimum sampling frequency is twice the max frequency: 2 * 3000 = 6000 Hz.
  2. Step 2: Check Python code output

    The code multiplies 3000 by 2 and prints 6000, matching the calculation.
  3. Final Answer:

    6000 -> Option A
  4. Quick Check:

    2 * 3000 = 6000 [OK]
Hint: Double the max frequency to get sampling rate [OK]
Common Mistakes:
  • Printing max frequency instead of double
  • Dividing instead of multiplying
  • Confusing units (Hz vs kHz)
4. Identify the error in the following Python code snippet for reconstructing a signal using sinc interpolation:
import numpy as np

def reconstruct_signal(samples, t, T):
    x_recon = 0
    for n in range(len(samples)):
        x_recon += samples[n] * np.sinc((t - n*T))
    return x_recon

# samples = [1, 2, 3], t = 1.5, T = 1
print(reconstruct_signal([1, 2, 3], 1.5, 1))
medium
A. np.sinc argument should be normalized by pi
B. Loop should iterate over t values, not samples
C. x_recon should be initialized as an array, not zero
D. The function should return samples instead of x_recon

Solution

  1. Step 1: Understand np.sinc function

    In numpy, np.sinc(x) = sin(pi*x)/(pi*x), so input is already normalized by pi.
  2. Step 2: Check argument passed to np.sinc

    The code passes (t - n*T) directly, which is correct because np.sinc expects normalized input.
  3. Step 3: Identify error

    Actually, the argument is correct; the error is that x_recon is initialized as 0 (a scalar), but the function expects to handle array inputs for t for vectorized reconstruction.
  4. Step 4: Correct error

    x_recon should be initialized as np.zeros_like(t) if t is an array, but since t is scalar here, initialization is fine.
  5. Step 5: Reconsider options

    np.sinc argument should be normalized by pi says argument should be normalized by pi, but numpy's sinc already does that, so no need to normalize.
  6. Step 6: Final conclusion

    No error in normalization; the code is correct for scalar t. The main issue is if t is array, initialization fails.
  7. Final Answer:

    x_recon should be initialized as an array, not zero -> Option C
  8. Quick Check:

    Accumulator initialization must match output type [OK]
Hint: Remember numpy sinc is normalized by pi already [OK]
Common Mistakes:
  • Assuming np.sinc needs manual pi normalization
  • Initializing accumulator incorrectly for arrays
  • Confusing loop variable roles
5. You have a signal sampled at 8 kHz with maximum frequency 5 kHz. What problem will occur during reconstruction, and how can it be fixed?
hard
A. Signal will be noisy; fix by applying a low-pass filter after sampling
B. Signal will be delayed; fix by adjusting reconstruction timing
C. No problem; sampling rate is sufficient for reconstruction
D. Aliasing will occur; fix by increasing sampling rate above 10 kHz

Solution

  1. Step 1: Compare sampling rate and Nyquist rate

    Nyquist rate = 2 * max frequency = 2 * 5 kHz = 10 kHz. Sampling rate is 8 kHz, which is less than Nyquist rate.
  2. Step 2: Identify consequence of insufficient sampling

    Sampling below Nyquist rate causes aliasing, where higher frequencies appear as lower frequencies, distorting the signal.
  3. Step 3: Determine solution

    To avoid aliasing, increase sampling rate above 10 kHz.
  4. Final Answer:

    Aliasing will occur; fix by increasing sampling rate above 10 kHz -> Option D
  5. Quick Check:

    Sampling rate < Nyquist rate causes aliasing [OK]
Hint: Sample above twice max frequency to avoid aliasing [OK]
Common Mistakes:
  • Assuming 8 kHz is enough for 5 kHz max frequency
  • Confusing noise with aliasing
  • Ignoring Nyquist sampling theorem
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