Write C Program Makes Binary Tree Generates Huffman Code Accept 26 Letters 10 Digits 0 9 Q37106201

Write a C++ program which makes a binary tree that generates theHuffman code that can accept 26 letters and 10 digits 0 – 9


Solution


//C++ program to make a binary tree that generates the Huffmancode

//importing headerfiles
#include<iostream>
#include<limits.h> //for INT_MAX (gives max value ofinteger)

using namespace std;

// Structure to store each node in the tree
struct node
{
   char value;          //stores the corresponding character
   char leaf_value;   //stores the charactercorresponding to the leaf
   int count;          //contains the count
   node *left;          //stores the left subtree
   node *right;       //storesthe right subtree

};

//smallest function.
//Arguments : List of pointers to nodes and its length
//Return : pointer

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.