Question: C Code You should write a program that reads the book you have downloaded and finds the unique characters inside it. Your program should also

C Code

C Code You should write a program that reads the book you

You should write a program that reads the book you have downloaded and finds the unique characters inside it. Your program should also determine the occurrence of these unique characters inside the file and should find the probability of each unique character. Probability of each character can be defined by occurrence of the character inside the text file divided by the total number of characters in the text file. At the end, your program should calculate the entropy of this text file. Entropy is given as: n p(i)logz p(i), H = i=1 where p(i) is the probability of corresponding unique character. The last thing that your program should do is to write the information found into a new text file. The content of it should look like this: Total number of characters in file: 439599 Total number of unique characters in file: 93 The entropy found is: 4.411736 Character Y occurred 161 times and probability of it: 0.000366 Character o occurred 25051 times and probability of it: 0.056986 Character u occurred 10336 times and probability of it: 0.023512 Character occurred 73134 times and probability of it: 0.166365 Character w occurred 7357 times and probability of it: 0.016736 Character i occurred 21392 times and probability of it: 0.048663 Character l occurred 12582 times and probability of it: 0.028622 Character r occurred 20705 times and probability of it: 0.047100 You are not allowed to use string.h library. You should allocate memory dynamically. All operations should not be done in the main() function. You must use at least one more function besides main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!