Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please do all the questions, btw no coding please 7. AVL Tree (20 pts, 8+8+4) You have been asked to write a program to count

image text in transcribedimage text in transcribedimage text in transcribed

please do all the questions, btw no coding please

7. AVL Tree (20 pts, 8+8+4) You have been asked to write a program to count the number of times each word occurs in a text file, and print them grouped according to word length. Below is a sample text file on the left, and the expected output of your program on the right: This is the first line and this line is the ultimate line. is: 2 the: 2 and: 1 this: 2 line: 3 first: 1 ultimate: 1 Note that words are counted ignoring case, and are printed in order of word length. In any group of words of the same length, the printout can be in any order (e.g. the and and are both printed before words of greater length, but they need not be in any specific relative sequence.) You choose to store the words in an AVL tree. Each node in the AVL tree has a word (with its count), and words (alphabetical) are the basis of the AVL ordering a) If there are k distinct words, and n words in all (in the sample input file, k - 7 and n - 12), how much time will it take in the worst case (big O) to store all the words with counts? Show your derivation. Assume that all word-to-word comparisons take constant time, and ignore the time taken to read a word from input. 7. AVL Tree (20 pts, 8+8+4) You have been asked to write a program to count the number of times each word occurs in a text file, and print them grouped according to word length. Below is a sample text file on the left, and the expected output of your program on the right: This is the first line and this line is the ultimate line. is: 2 the: 2 and: 1 this: 2 line: 3 first: 1 ultimate: 1 Note that words are counted ignoring case, and are printed in order of word length. In any group of words of the same length, the printout can be in any order (e.g. the and and are both printed before words of greater length, but they need not be in any specific relative sequence.) You choose to store the words in an AVL tree. Each node in the AVL tree has a word (with its count), and words (alphabetical) are the basis of the AVL ordering a) If there are k distinct words, and n words in all (in the sample input file, k - 7 and n - 12), how much time will it take in the worst case (big O) to store all the words with counts? Show your derivation. Assume that all word-to-word comparisons take constant time, and ignore the time taken to read a word from input

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

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

=+3. What types of job are best recruited internally? Externally?

Answered: 1 week ago

Question

What is American Polity and Governance ?

Answered: 1 week ago