Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6988021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:00:57+00:00 2026-05-27T19:00:57+00:00

I coded a Huffman Algorithm. I read a file into a String and then

  • 0

I coded a Huffman Algorithm.

I read a file into a String and then built a Huffman Tree and codes with the
encoded data.

I put this in a new String and wrote it to new file, but it increases the size of file instead of decreasing it!!

I know what’s wrong:

When input string is like "abc" it is 3*8=24 bit

However, when it is coded to "000111" it is 6*8=68 bit

Does anyone have any ideas?

How should I write the "000111" string in the output file so that it only needs 6 bits?

I am using Java.

Please Help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:00:58+00:00Added an answer on May 27, 2026 at 7:00 pm

    you need to pick a way to pack bytes, LSB or MSB first, and implement it using bit-shift operators. and remember that Java has no concept of unsigned bytes, and that strings are not equivalent to byte arrays.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to understanding this code, which is about generating a Huffman tree .
i am trying to create a Huffman tree by reading in a file and
i coded a header file which includes some of tabs.this header file is include
I was using StringReader in a Data Structures assignment (Huffman codes), and was testing
I coded this function to retrieve JSON data from an API (which returns data
This question is coded in pseudo-PHP, but I really don't mind what language I
Im trying to implement my own Huffman Coding algorithm and the priority queue for
This is a question I ran into in school settings, but it keeps bugging
For a project, I have to convert a binary string into (an array of)
I'm doing a huffman encoding algorithm in C and got in a problem here.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.