Wrox Programmer Forums
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2006, 06:04 AM
Registered User
 
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default java program

hello, i m a beginner in java.please help me in making this program


First count the number of times each word appears in the input file and find out frequency of occurrence of each word. Output the words and counts. Hint: Use StringTokenizer for extracting words from the file. Add all the words and frequencies to a HashMap.

B. Then compress the file using Huffman coding, as described below. Huffman coding has the following properties:

    * Codes for more frequently occurring words are shorter than ones for less frequent words.
    * Each code can be uniquely decoded.

Huffman codes are generated as follows:
A binary tree where the leaf nodes represent the words and internal nodes contain frequencies is constructed. Bit '0' represents following the left child and bit '1' represents following the right child.

    * Use a priority queue (which contains frequencies) and remove two words with lowest frequencies from it.
    * Create a new internal node, with the two just-removed frequency words as children and sum of their freqs as the new freq.
    * Add the two frequencies and insert sum into priority queue.
    * Repeat this procedure until the last word in priority queue.

(1) Output the Huffman code for each word stored in the HashMap, in text format, and
(2) Dump the Huffman code of the whole input file to a binary file.

Optional part:
Get the text back from given Huffman Coding by traversing the binary tree(decompression). The binary file created in the previous part can be read using FileInputStream, DataInputStream and calling appropriate method
(DataInputStream.readInt if you have written code as ints or DataInputStream.readChar in case of characters).

hi





Similar Threads
Thread Thread Starter Forum Replies Last Post
java program with package sushant2002 Java Basics 5 September 19th, 2008 09:15 PM
java program help chris1012 Java Basics 3 November 8th, 2007 09:35 AM
java program todeepak_g JSP Basics 0 January 25th, 2006 06:01 AM
How use two different database in one java program [email protected] Java Databases 2 October 3rd, 2005 01:07 PM
My Java program won't compile emilaghayev JSP Basics 0 October 21st, 2003 06:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.