I have a task to write a program in pseudocode that prints the frequency of occurrence of characters in the entered text. I found an example code in c language but I can’t seem to write it in pseudocode. I need to comment every line of code. If someone has a solution, I would be extremely grateful.
A friend sent me a code in Java, but I can’t solve it either because I don’t know how to define the length of the entered text.
const analyzedText =
'Some input text that is being analyzed that has special characters "!!!!", "?" or whatever else is considered to be special character..';
// set empty map to store frequency in
const frequencyMap = {};
// loop over every leather in the
for (let i = 0; i < analyzedText.length; i++) {
const character = analyzedText[i].toLocaleLowerCase().trim();
// skip empty spaces
if (character.length === 0) {
continue;
}
if (frequencyMap.hasOwnProperty(character)) {
frequencyMap[character] = frequencyMap[character] + 1;
} else {
frequencyMap[character] = 1;
}
}
console.log('frequencyMap :>> ', JSON.stringify(frequencyMap, undefined, 4));