Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python function that takes a filename and creates a single letter frequency distribution for all the chars (i.e. bytes) occuring in the file.

Write a Python function that takes a filename and creates a single letter frequency distribution for all the chars (i.e. bytes) occuring in the file.

Such a function in C might look roughly like the following:

void mkdist(float* D,char* filename)

{ FILE *fp = fopen(filename,"r");

/*write some code here to initialize some things*/

while((c=fgetc(fp))!=EOF) {

/*write some code here to process the char c*/

}

/*write some more code here to finish things up*/ fclose(fp);

}

Remember that at the end of the method D[i] should be the number of occurrences of i in the le, divided by the total number of bytes (chars) in the le.

Incorporate what the actual code is to build the probability distribution.

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_2

Step: 3

blur-text-image_3

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions