Add to Favorites    Make Home Page 20056 Online  
 Language Categories  
 Our Services  

Home » C++ Home » Beginners / Lab Assignments Home » TEXT COMPRESSION USING HUFFMAN CODES.

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title TEXT COMPRESSION USING HUFFMAN CODES.
Author rajarathnam.l
Author Email rajara2004 [at] yahoo.co.in
Description The project provides the way of compressing the repeated text
size by using concept of huffman encoding technique.
Category C++ » Beginners / Lab Assignments
Hits 370157
Code Select and Copy the Code
/* TEXT COMPRESSION - HUFFMAN CODING */ #include<stdio.h> #include<string.h> #include<conio.h> #define MAXSUM 50 #define MAXNODES 100 #define MAXLEN 15 enum direction{left,right}; enum boolean{false,true}; typedef class node*nodeptr; typedef short int symbolindex; typedef short int listptr; nodeptr root; class symbol { public: char c; int count; nodeptr ptr; operator int() { return(count); } }; class node { public: int weight; nodeptr lc,rc; nodeptr parent; direction dir; boolean isleaf; symbolindex index; node() { lc=NULL; rc=NULL; parent=NULL; weight=0; isleaf=false; index=0; } node(symbolindex i,symbol &s) { index=i; weight=s.count; lc=NULL; rc=NULL; parent=NULL; isleaf=true; s.ptr=this; } int getindex() { if(isleaf) return(index); else return(0); } void insertright(nodeptr n) { n->parent=this; n->dir=right; rc=n; isleaf=false; } void insertleft(nodeptr n) { n->parent=this; n->dir=left; lc=n; isleaf=false; } }; class nodelist { private: listptr start,avail,prev; int cnt; nodeptr info[MAXNODES]; listptr link[MAXNODES]; public: nodelist(); void add(nodeptr n); nodeptr least(); boolean isempty() { return(cnt==0)?true:false; } }; nodelist::nodelist() { int i; start=1; link[start]=0; info[start]=NULL; avail=2; cnt=0; for(i=2;i<MAXNODES;i++) { link[i]=i+1; } } void nodelist::add(nodeptr n) { listptr ptr=link[start]; prev=start; listptr temp=avail; avail=link[avail]; info[temp]=n; while((ptr!=0 && (info[ptr]->weight<info[temp]->weight))) { prev=ptr; ptr=link[ptr]; } link[prev]=temp; link[temp]=ptr; cnt++; } nodeptr nodelist::least() { listptr temp=link[start]; cnt--; if(temp==0) return(NULL); link[start]=link[temp]; link[temp]=avail; avail=temp; return(info[temp]); } class symtab { private: symbol sym[MAXSUM]; public: int count; symtab() { count=0; } int find(char s); symbol & operator[](int index) { return(sym[index]); } void add(char c,int n); char*getcode(int index); }; int symtab::find(char s) { int i; for(i=0;i<count;i++) if(sym[i].c==s) return i; return(-1); } void symtab::add(char c,int n) { symbol s; s.count=n; s.c=c; sym[count++]=s; } char *symtab::getcode(int index) { int pos=MAXLEN; static char buffer[MAXLEN+1]; buffer[pos]='

Related Source Codes

Script Name Author
Moving ball screen saver karlmarx
The Classic Game of Snake & Ladder Lakshmi Narayana .A
Railway seat reservation question which comes in sapient VyomWorld
To calculate percentile Ravi Mathur
Send to folder ANIMESH SAHU
Analog clock and calendar Nazia & Rida
HIGH/LOW GAME MOLLY ARORA
Data structure (stack Implimentation) Swapnil B Adsure
Memory Game AnirudhSanyal
Easy Calc Anirudh Sanyal
GK Quiz Anirudh Sanyal
Hangman Game Manish Jain
Snakeman Manish Jain
Full month Calendar Nigi
Cursor shapes nigi

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=481


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review