Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/default-filters.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/default-filters.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-theme.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-theme.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-styles.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-styles.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/block-supports/duotone.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/block-supports/duotone.php on line 1
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
{"id":128,"date":"2011-10-25T21:03:47","date_gmt":"2011-10-25T15:03:47","guid":{"rendered":"http:\/\/ujjalruet.wordpress.com\/?p=128"},"modified":"2011-10-25T21:03:47","modified_gmt":"2011-10-25T15:03:47","slug":"huffman-coding","status":"publish","type":"post","link":"https:\/\/blog.ujjal.net\/?p=128","title":{"rendered":"Huffman coding"},"content":{"rendered":"[code]
\n\/\/Originally FOUND in Internet
\n\/\/by RIT2009061 vikesh iiita<\/p>\n
\/\/Author: Ujjal Suttra DHar [CSE’08,RUET]<\/p>\n
#include <iostream>
\n#include <fstream>
\n#include <vector>
\n#include <string>
\n#include <queue>
\n#include <algorithm><\/p>\n
using namespace std;<\/p>\n
struct node {
\n\tint weight;
\n\tchar value;
\n\tconst node *child0;
\n\tconst node *child1;<\/p>\n
\tnode( int c, int i ) {
\n\t\tvalue = c;
\n\t\tweight = i;
\n\t\tchild0 = 0;
\n\t\tchild1 = 0;
\n\t}<\/p>\n
\tnode( const node* c0, const node* c1 ) {
\n\t\tvalue = 0;
\n\t\tweight = c0->weight + c1->weight;
\n\t\tchild0 = c0;
\n\t\tchild1 = c1;
\n\t}<\/p>\n
\tbool operator<( const node &a ) const {
\n\t\tif(weight ==a.weight)
\n\t\t return value>a.value;
\n else
\n\t\t return weight >a.weight;
\n\t}<\/p>\n
void traverse(string code="") const{<\/p>\n
\tif ( child0 ) {
\n\t\tchild0->traverse( code + ‘0’ );
\n\t\tchild1->traverse( code + ‘1’ );
\n\t} else {
\n\t\tcout <<" " <<value <<"\t ";
\n\t\tcout <<weight;
\n\t\tcout <<"\t " <<code <<endl;
\n\t}
\n}<\/p>\n
};<\/p>\n
\/*
\nvoid count_chars( int *counts )
\n{
\n\tfor ( int i = 0 ; i <256 ; i++ )
\n\t\tcounts[ i ] = 0;<\/p>\n
freopen("input.dat","r",stdin);<\/p>\n
char c;
\nwhile((c=getchar())!=EOF)
\n counts[c]++;
\n}<\/p>\n
*\/<\/p>\n
int main()
\n{<\/p>\n
freopen("input.dat","r",stdin);<\/p>\n
\tint counts[ 256 ];
\n\tchar a[1000];<\/p>\n
gets(a);<\/p>\n
for ( int i = 0 ; i <256 ; i++ )
\n\t\tcounts[ i ] = 0;<\/p>\n
for(int i=0;i<strlen(a);i++)
\n\tcounts[a[i]]++;<\/p>\n
\tpriority_queue < node > q;<\/p>\n
\tfor (int i = 0 ; i <256 ; i++ )
\n\t\tif ( counts[ i ] )
\n\t\t\tq.push( node( i, counts[ i ] ) );<\/p>\n
\/\/if you wanna show the queue
\n\/*while(!q.empty()){
\n cout<<q.top().value<<endl;
\n q.pop();
\n }
\n*\/<\/p>\n
\twhile ( q.size() >1 ) {
\n\t\tnode *child0 = new node( q.top() );
\n\t\tq.pop();
\n\t\tnode *child1 = new node( q.top() );
\n\t\tq.pop();
\n\t\tq.push( node( child0, child1 ) );
\n\t}<\/p>\n
\tcout <<"CHAR FREQUENCY HOFFMAN-CODE" <<endl;
\n\tq.top().traverse();
\n\treturn 0;
\n}<\/p>\n
[\/code]<\/p>\n","protected":false},"excerpt":{"rendered":"
[code] \/\/Originally FOUND in Internet \/\/by RIT2009061 vikesh iiita \/\/Author: Ujjal Suttra DHar [CSE’08,RUET] #include <iostream> #include <fstream> #include <vector> #include <string> #include <queue> #include <algorithm> using namespace std; struct node { int weight; char value; const node *child0; const node *child1; node( int c, int i ) { value = c; weight = i; … <\/p>\n
Continue reading “Huffman coding”<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0},"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=\/wp\/v2\/posts\/128"}],"collection":[{"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=128"}],"version-history":[{"count":0,"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=\/wp\/v2\/posts\/128\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}