Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C CODE (NOT C++) You should write a program that reads the book you have downloaded and finds the unique characters inside it. Your program

C CODE (NOT C++)

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

4. Does cultural aptitude impact ones emotional intelligence?

Answered: 1 week ago