Construct the huffman code for the java keyword

Assignment Help Data Structure & Algorithms
Reference no: EM13811160

Part I: written exercises:

1. Begin with the following binary search tree, draw the BST that results after the operation or sequence of operations is performed. (All questions are independent and each question starts from the BST as following)

260_img1.png

a. Insert 7

b. Insert 7, 1, 55, 29, and 19

c. Delete 8

d. Delete 8, 37, and 62

e. Insert 7, delete 8, insert 59, delete 60, insert 92, delete 50.

f.  Display the output produced by an inorder traversal

g. Display the output produced by a preorder traversal

h. Display the output produced by a postorder traversal.

2. For the arithmetic expressions below, draw a binary tree that represents the expression, and then use tree traversals to find the equivalent prefix and postfix expressions.

a. (A-B)-C

b. A/ (B-(C-(D-(E-F))))

c. ((A*(B+C))/(D-(E+F)))*(G/(H/(I*J)))

3. Construct the Huffman code for the Java keyword and weights given in the following table.

Words

Weight

int

0.30

main

0.30

while

0.05

if

0.20

for

0.15

Part II: programming exercise

Start with the tree.java program (Listing 8.1) and modify it to create a binary tree from a string of letters (like A, B, and so on) entered by the user. Each letter will be displayed in its own node. Construct the tree so that all the nodes that contain letters are leaves. Parent nodes can contain some non-letter symbol like +. Make sure that every parent node has exactly two children.

Don't worry if the tree is unbalanced. Note that this will not be a search tree; there's no quick way to find a given node. You may end up with something like this:

519_img2.png

One way to begin is by making an array of trees. (A group of unconnected trees is called a forest.) Take each letter typed by the user and put it in a node. Take each of these nodes and put it in a tree, where it will be the root. Now put all these one-node trees in the array. Start by making a new tree with + at the root and two of the one-node trees as its children. Then keep adding one-node trees from the array to this larger tree. Don't worry if it's an unbalanced tree. You can actually store this intermediate tree in the array by writing over a cell whose contents have already been added to the tree.

The routines find(), insert(), and delete(), which apply only to search trees, can be deleted. Keep the displayTree() method and the traversals because they will work on any binary tree.

Reference no: EM13811160

Questions Cloud

Difference between persuasion and manipulation : What is the difference between persuasion and manipulation? How do arguments and language affect the way in which they differ?
Strategic management-environmental scan paper : Write a 1,050 word paper in which you complete the following: Research and describe the internal and external environments of 2 to 3 real-world companies using an environmental scan.
Statistics play an important role in understanding the const : Statistics play an important role in understanding the construct of personality. With SPSS, comparison of means analyses can be conducted to promote a greater understanding of personality. View the following: SPSS for Beginners 6a: One-sample t-tests..
Consider the following test of whether a coin is fair : Consider the following test of whether a coin is fair. Toss the coin five times.  If the coin lands either all heads or all tails, reject Ho: p= 1/2. (The p denotes the chance for the coin to land on heads.) Complete parts a and b. (a) What is the pr..
Construct the huffman code for the java keyword : Construct the Huffman code for the Java keyword and weights given in the following table
Introduction to anthropology : introduction to anthropology
Language- status and identity : Language- Status and Identity
Communicating across borders : Communicating across Borders
How are journalists captives of the personal values : How are journalists captives of the personal values and biases they bring to their work? Can you provide and example of this through a video clip or story

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Design a property database using microsoft access

Database window opens, then type the word Client as the name for this file where the cursor is blinking, then click the create bottom.

  Set the three elements of integer array counts to 0

Write statements that perform the following one-dimensional-array operations: Set the three elements of integer array counts to 0

  Design algorithm to solve spectral assembly problem

Design an algorithm to solve the Spectral Assembly problem under the above conditions. Does the problem have a unique solution?

  Finding time taken to send packet from source to destination

Think about sending a document of F bytes over a path of Q links. Each link transmits at R bps. The network is lightly loaded so that there are no queuing delays.

  Part 1 - report write a 2000-word report that describes a

part 1 - report write a 2000-word report that describes a suitable methodology from the literature for the purpose of

  Program development cycle for algorithm using pseudocode

Illustrate all your work. Use modular approach to solving this problem. Give the following submodule. Calculations - module to compute gross pay. Using the Program Development Cycle, develop an algorithm using pseudocode for the following task.

  Algorithm for finding smallest element in unsorted array

Consider the following algorithm for finding the smallest element in an unsorted array: RANDOMMIN(A[1 .. n]). What is the exact expected number of executions of line ( )?

  1 n vehicles occupy squares 1 1 through n 1 ie the bottom

1. n vehicles occupy squares 1 1 through n 1 i.e. the bottom row of an n times n grid. the vehicles must be moved to

  Describe algorithm that finds maximum feasible flow in graph

Describe an algorithm that finds a maximum feasible flow in G. Denote by MF(|V|, |E|) the worst-case running time of an ordinary maximum flow algorithm.

  Compare and contrast link-state and distance-vector routing

Examine the corresponding ping reply packet. What are the ICMP type and code numbers? What other fields does this ICMP packet have?

  A and b, both of which perform the same function

Assume you have two algorithms, A and B, both of which perform the same function,

  Methods of generated data experiments

Overview of the different methods of generated data experiments - Some of visualization techniques are provided in this research to show how well the predictive modelling is performing and show an interesting method in the data related to the proje..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd