Question

In: Computer Science

In all algorithm, always explain how and why they work. ALWAYS, analyze the complexity of your...

In all algorithm, always explain how and why they work. ALWAYS, analyze the complexity of your algorithms. In all algorithms, always try to get the fastest possible. A correct algorithm with slow running time may not get full credit. In all data structures, try to minimize as much as possible the running time of any operation.

1.Show that if a binary tree has a vertex with a single child, then this can not be an optimal Huffman tree.

2. Question 2: Say that the input for an Huffman coding contains 256 letters. Each appearing the the same number of times. (a) If we choose to code all letters by codes of the same length, what is the number of bits required? (b) Is the Huffman code better than the code of the first item?

3. Question 3: Say that we code 256 different letters. Let num(X) be the number of times an arbitrary letter appears in the text . Assume that for every X and Y both num(Y ) > num(X)/2 and num(X) > num(Y)/2 hold. Is the ASCII (8 bits) code worse than the Huffman code in this case?

Solutions

Expert Solution

Answer;

Below is the recursive algorithm which performs the desired task. In this algorithm name "find(root,height,number_of_nodes, h)", root is the pointer to root of present subtree, variable height and number_of_nodes are passed by reference such that we are updating the value of vairable height and variable number_of_nodes as per the result returned in recursive call and this value change in recursive call will be reflected in original call.

Also in below algorithm, we are checking if height of a particular subtree is equal to h or not. If height is equal to h, then we are updating the vairable maximum_nodes accordingly.*********THE END********** Please vote


Related Solutions

DATA STRUCTURES: For each algorithm, always explain how and why they work. If not by a...
DATA STRUCTURES: For each algorithm, always explain how and why they work. If not by a proof, at least by a clear explanation. ALWAYS, analyze the running time complexity of your algorithms. Do not write a program. Write pseudo codes or explain in words Q1: We want to maintain both a Queue and a Priority Queue. When you do Enqueue you also add the item to the Priority Queue and when you do Dequeue you also remove the item from...
Is mixed methods research worth all of the extra work and complexity? Why, or why not?
Is mixed methods research worth all of the extra work and complexity? Why, or why not?
Give the asymptotic (“big-Oh”) running time complexity of the following algorithm, show all the work you...
Give the asymptotic (“big-Oh”) running time complexity of the following algorithm, show all the work you have done. Algorithm: ArrayMangle(A[ ], int n) Input: an array A, an integer n x = 0; for (i=0; i<=n-1; i++) { for (j=i; j<=n-1; j++) { x = x + A[j]; } for (k=0; k<= n-1; k++) { for (j=0; j< =n-1; j++) { x = x + A[j]*A[k]; } } }
1. Mathematically analyze the given Recurrence Relation and find out the time complexity of the algorithm....
1. Mathematically analyze the given Recurrence Relation and find out the time complexity of the algorithm. T(n) = T(n-1)+1 , if n> 0 1 if n = 0
Calculate the time complexity of each algorithm for best, worst and average cases. Give all steps...
Calculate the time complexity of each algorithm for best, worst and average cases. Give all steps of your calculation and results in Big-O notation. algorithm : Selection Sort Bubble Sort Insertion Sort
Implement 2-D peak finder and explain the asymptotic complexity of the algorithm For Design and Analysis...
Implement 2-D peak finder and explain the asymptotic complexity of the algorithm For Design and Analysis of the Algorithme lecture
Analyze the algorithm experimentally. a)Implement the algorithm b)Let p be the string length at which your...
Analyze the algorithm experimentally. a)Implement the algorithm b)Let p be the string length at which your program takes 2 seconds to run, collect running times for your algorithm using the following string lengths: p/4, 2p/4, 3p/4, p, 5p/4, 6p/4, 7p/4, 2p. c)Generate your strings by reading the attached file, only reading as many characters as you need. d)Plot your results (x-axis is string length, y-axis should be time) e)Draw conclusions based on your graph. You may also need to plot...
Explain how does Baker’s algorithm works? Explain all the types of pointers it has and their...
Explain how does Baker’s algorithm works? Explain all the types of pointers it has and their complete functions. [25 points]
Analyze the increased complexity of care among older adults. Your supervisor needs to make sure that...
Analyze the increased complexity of care among older adults. Your supervisor needs to make sure that each of the in-service topics will be covered by someone, so she is asking the staff to communicate their topic preference. Below is the list of problems your supervisor wants the nursing staff to be able to teach older adult clients (and/or their family members) about. In-service Topic Options: Hypertension Diabetes Coronary artery disease Depression Dementia Polypharmacy Increased risk of falls Vison/hearing impairment Nutrition...
Analyze the increased complexity of care among older adults. Your supervisor needs to make sure that...
Analyze the increased complexity of care among older adults. Your supervisor needs to make sure that each of the in-service topics will be covered by someone, so she is asking the staff to communicate their topic preference. Below is the list of problems your supervisor wants the nursing staff to be able to teach older adult clients (and/or their family members) about. In-service Topic Options: Hypertension Diabetes Coronary artery disease Depression Dementia Polypharmacy Increased risk of falls Vison/hearing impairment Nutrition...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT