Answer:
Explanation:
/* General Code for achieving perfect error for any level and any
digit of codewords*/
#include<iostream>
using namespace std;
int main(){
int level;
//Input memory levels.
cout <<" Enter number of Flash Memory levels : ";
cin>>level;
//construct array store levels.
int lvl[level];
for(int i = 0; i < level; i++){
//assign levels name
lvl[i] = i;
}
int digit;
cout << "Enter number of digit codewords :";
//Taking input of codeword digits
cin >> digit;
for(int i = 0; i < level;){
//output Codeword
cout << lvl[i];
//Skipping for n number digit codeword in level
i+=(digit+1);
}
}
/*
a) i from 0 to (i = i+(2+1))<levels
b) for length (1) -> 3 codewords
codewords -> {0,2,4}
for length (2) -> 2 codewords
codewords -> {0,3}
*/