• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

1

Formal Definition

Index-to-character conversion is the inverse of character-to-index mapping. Given an integer index i (0–25 for lowercase English), adding the base character’s ASCII value produces the corresponding character: ch = i + 'a'.

char(i)=ASCII1(ASCII(a)+i)\text{char}(i) = \text{ASCII}^{-1}(\text{ASCII}('a') + i)

Explanation

After building a frequency array, the stored data is indexed numerically (0–25). To produce human-readable output (printing “a = 3” not “0 = 3”), you must convert each index back to its character. This is the reverse of the ch - 'a' mapping and uses i + 'a'.

How It Works

  1. During traversal of the frequency array, you have an index i (0 to 25)
  2. Compute char ch = i + 'a'
  3. Use ch for output or further processing
  4. For i=0 → ‘a’, i=1 → ‘b’, …, i=25 → ‘z’

Mathematical Formulation

char(i)=i+97=i+ASCII(a)\text{char}(i) = i + 97 = i + \text{ASCII}('a')

char(0)=a,char(1)=b,,char(25)=z\text{char}(0) = 'a', \quad \text{char}(1) = 'b', \quad \dots, \quad \text{char}(25) = 'z'

Visual Explanation

index_to_char FREQ Frequency Array i=0: 3 i=1: 1 i=13: 2 LOOP Loop i=0..25 FREQ->LOOP CHECK freq[i] > 0? LOOP->CHECK CONV ch = i + 'a' CHECK->CONV yes SKIP Skip (zero freq) CHECK->SKIP no PRINT Print: ch = freq[i] CONV->PRINT PRINT->LOOP next i SKIP->LOOP next i

Semantic Network

semantic_index_to_char THIS Index-to-Char Conversion PRE1 Character-to-Index Mapping THIS--PRE1 built from OUT1 Frequency Array Traversal THIS--OUT1 builds into OUT2 Most Frequent Character THIS--OUT2 builds into CON1 Hash Map Traversal THIS--CON1 contrasts with REL1 ASCII Encoding THIS--REL1 related REL2 Frequency Array THIS--REL2 related

Key Properties

  • O(1) computation — simple integer addition
  • Must match the base used in the forward mapping ('a' for ch - 'a')
  • Produces only lowercase letters when used with 0–25 indices
  • No bounds checking — caller must ensure index is in valid range

Connections

Edge Cases & Gotchas

  • Using 'A' as base when the mapping used 'a' produces wrong letters
  • Indices outside 0–25 produce non-alphabetic characters (e.g., i=26 → ’{’)
  • Forgetting this step and printing raw indices is a common beginner mistake
  • When using uppercase mapping (ch - 'A'), the reverse must use i + 'A'