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

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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