Question
translate the following algorithm into C language (context is coding/decoding) input: L1: listes separated(caractre, longueur) output: L2: listes separated(caractre, code) sorted by lenght L1=sorted_by_lenght(L1) //
translate the following algorithm into C language (context is coding/decoding)
input: L1: listes separated(caractre, longueur) output: L2: listes separated(caractre, code) sorted by lenght
L1=sorted_by_lenght(L1)
// If same lenght then sort by alphabetical order i don't know how to write it in algorithmic
L2[0]->code = 0 L2[0]->char = L1[0]->char control_lenght = 0 previous_lenght = 0 n= size L1
for i =1 to n-1 do L2[i]->char = L1[i]->char control_lenght = L1[i]--->lenght previous_lenght = L1[i-1]--->lenght L2[i]->code = (L2[i-1]->code+1) * 2^(previous_lenght-control_lenght) end for return L2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started