Exercise

Padding Changes the Measured Input Length

Relate a language to a padded version without confusing value and length.

Assignment sources

Noy 2025 high-quality exam preparation and community solutionsCommunity solutionפתרון מטלה 2 - סיבוכיות.pdfAssignment 2High-quality preparation and community solution — not official

Problem

Let LL be decidable in time 2nk2^{n^k} for a fixed k≥1k\ge1. Over an alphabet containing a separator #\#, define

Lpad={x#0 2∣x∣k:x∈L}.L_{\mathrm{pad}}=\{x\#0^{\,2^{|x|^k}}:x\in L\}.

Show that Lpad∈PL_{\mathrm{pad}}\in\mathrm P. Clearly state how malformed padded strings are handled.

Hint 1

If the full padded input has length NN, compare 2∣x∣k2^{|x|^k} with NN.

Hint 2

Parsing and checking the exact number of zeros can be done by scanning the input while maintaining counters of O(log⁡N)O(\log N) bits.

Full solution

On input ww of length NN, require exactly one delimiter #\#, obtaining a candidate prefix xx and suffix of zeros. Reject if the form is wrong. Compute ∣x∣k|x|^k and verify that the suffix length is exactly 2∣x∣k2^{|x|^k}; this can be done in time polynomial in NN by scanning and binary counting.

If well formed, simulate the decider for LL on xx. Its runtime is

2∣x∣k≤N,2^{|x|^k}\le N,

because that many padding zeros occur in ww. Parsing plus simulation is polynomial in NN, so Lpad∈PL_{\mathrm{pad}}\in\mathrm P.

Checkpoint

Padding does not make the original computation intrinsically faster; it enlarges the length against which runtime is measured.

Provenance note

Original exercise based on the standard padding technique; no student submission is an authority.

Common mistakes

  • Skipping a direction of correctness or an input-format edge case.
  • Measuring resources against a numeric value rather than encoded input length.
  • Treating an informal intuition as a proof of the stated bound.

Sources and verification

  • Merged summary, pp. 124-130
  • 2026 transcript 6
  • Arora-Barak draft, padding discussion
  • Catalog mapping: data/exercises.json; statements and solutions are independently written; personal submissions are non-authoritative.
Guided construction

Padding argument

Step 1 of 6
source xx = 101
101
n = |x| = 3
Meaningful instance xPadding suffix