1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
klio [65]
4 years ago
10

Please help me with my assigment

Computers and Technology
1 answer:
Art [367]4 years ago
8 0

Answer:

#include <iostream>

#include <queue>

using namespace std;

class HeapNode_Min  

{  

public:

char d;

unsigned f;

HeapNode_Min* l;

HeapNode_Min* r;

HeapNode_Min(char d, unsigned f)

{

 this->l = this->r = NULL;

 this->d = d;

 this->f = f;

}

};

class Analyze {  

public:

bool operator()(HeapNode_Min* l, HeapNode_Min* r)

{

 return (l->f > r->f);

}

};

void display_Codes(HeapNode_Min* root, string s)

{

if (!root)

 return;

if (root->d != '$')

 cout << root->d << "\t: " << s << "\n";

display_Codes(root->l, s + "0");

display_Codes(root->r, s + "1");

}

void HCodes(char data[], int freq[], int s) // builds a Huffman Tree

{

HeapNode_Min* t, *r, *l; // top, right, left

priority_queue<HeapNode_Min*, vector<HeapNode_Min*>, Analyze> H_min;

int a = 0;

while (a < s) {

 H_min.push(new HeapNode_Min(data[a], freq[a]));

 a++;

}

while (H_min.size() != 1)  

{

 l = H_min.top();  

 H_min.pop();

 r = H_min.top();  

 H_min.pop();

 t = new HeapNode_Min('$', r->f + l->f);

 t->r = r;  

 t->l = l;

 H_min.push(t);

}

display_Codes(H_min.top(), "");

}

int main()

{

int frequency[] = { 3, 6, 11, 14, 18, 25 };  

char alphabet[] = { 'A', 'L', 'O', 'R', 'T', 'Y' };

int size_of = sizeof(alphabet) / sizeof(char); //Complete this statement by passing data type to both sizeof operators

cout << "Alphabet" << ":" << "Huffman Code\n";

cout << "--------------------------------\n";

HCodes(alphabet, frequency, size_of);  

return 0;

}

Explanation:

The expected output is:

Alphabet:Huffman Code

--------------------------------

R       : 00

T       : 01

A       : 1000

L       : 1001

O       : 101

Y       : 11

You might be interested in
Where do you go to create a workbook?​
Over [174]

Answer:

The explaination of this question is given below in the explanation section

Explanation:

The following steps are used to create a workbook.

1- Go to start menu and search about EXCEL (application software) and then click on it to open.

If you already opened a EXCEL's workbook, and you want to create a new workbook, then you follow the following steps:

  1. Click the File tab.
  2. Click New.
  3. Under Available Templates, double-click Blank Workbook. Keyboard shortcut To quickly create a new, blank workbook, you can also press CTRL+N.

A new workbook will be created.

6 0
4 years ago
Modify the code below to do the following:
Kitty [74]

Answer:

The code is appropriately given below with comments for better understanding

Explanation:

#include <linux/init.h>

#include <linux/module.h>

#include <linux/kernel.h>

#include <linux/hash.h>

#include <linux/gcd.h>

#include <asm/param.h>

#include <linux/jiffies.h>

/* This function is called when the module is loaded. */

static int simple_init(void)

{

  printk(KERN_INFO "Loading Module\n");

  printk(KERN_INFO "These are the HZ: %d\n", HZ);

  printk(KERN_INFO "These are the jiffies: %lu\n", jiffies);

  printk(KERN_INFO "Golden Ratio is: %lu\n", GOLDEN_RATIO_PRIME);  

  return 0;

}

/* This function is called when the module is removed. */

static void simple_exit(void) {

  printk(KERN_INFO "Removing Module");

  unsigned long a = gcd(3300, 24);

  printk(KERN_INFO "Greatest Common Denominator between 3,300 and 24 is: %lu\n", a);

  printk(KERN_INFO "These are the jiffies: %lu\n", jiffies);

}

/* Macros for registering module entry and exit points. */

module_init( simple_init );

module_exit( simple_exit );

MODULE_LICENSE("GPL");

MODULE_DESCRIPTION("Simple Module");

MODULE_AUTHOR("SGG");

7 0
3 years ago
Suppose the m2 money supply is $13 trillion, including: $7 trillion in savings accounts $3 trillion in checking accounts $1 tril
tia_tia [17]

Answer:

M1 is equal to $ 4 trillion

Explanation:

M1 money supplies are liquid money supplies like cash, checkable deposits, traveler's check etc. It is equal to;

M1= coins and currency in circulation + checkable (demand) deposit + traveler's check.

M2 money supply are less liquid and is equated as;

M2 = M1 + savings deposit + money market fund + certificates of deposit + other time deposits.

Savings = $7 trillion

Checkable deposit = $3 trillion

Money market fund = $1 trillion

Currency = $1 trillion

Certificates of deposit = $1 trillion

M1 = currency + checkable deposit

= $1 + $ 3

= $4 trillion.

6 0
3 years ago
I’m so lost. which username do i do.
koban [17]

Answer:

the username you feel like using

5 0
3 years ago
Read 2 more answers
Vivian wants to increase the storage capacity of her computer. Which components should she upgrade?
Nikitich [7]

Answer:

Hard drive

Explanation:

The hard drive is where the operating system, programs and data reside on (unless the data is saved and backed up elsewhere). An older hard drive that uses platters for reading and writing data to it will be slower than a later model solid state device. Newer hard drives have very fast access speeds compared to older units.

4 0
4 years ago
Other questions:
  • The analog signals that carry analog or digital data comprise composites built from combinations of simple sine waves.
    12·1 answer
  • Hope wants to add a third use at the end of her
    14·1 answer
  • .in the array based list implementation of the ADT what is the worst case time efficiency of the getEntry method?
    14·1 answer
  • In a study on software license infringement, those from United States were significantly more permissive than those from the Net
    15·1 answer
  • Which of the following is a hardware component used to hold the BitLocker encryption key and ensures encrypted data is not acces
    5·1 answer
  • Suppose Host A wants to send a large file to Host B. The path from Host A to Host B has three links, of rates R1 = 500 kbps, R2
    14·1 answer
  • The list method reverse reverses the elements in the list. Define a function named reverse that reverses the elements in its lis
    10·1 answer
  • Which tab on the Ribbon contains the command to print a publication?
    10·1 answer
  • Compare the freedom available to the American media with the freedom available to media in other parts of the world. How does a
    8·1 answer
  • Im trying to do an animation only using simplegui in python and my objective is make the ball enters frame, be confused and jump
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!