Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 25th, 2006, 06:04 AM
Registered User
 
Join Date: Jan 2006
Location: mumbai, maharashtra, India.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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 prabakarank@india.com 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



All times are GMT -4. The time now is 04:09 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.