*code is provided and the error is in the picture, please help with how to fix the error*

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

import java.util.*;
import java.io.*;

public class HuffmanCode {
     private Queue<HuffmanNode> queue;
        private HuffmanNode overallRoot;
        

        public HuffmanCode(int[] frequencies) {
                queue = new PriorityQueue<HuffmanNode>();
                
                for (int i = 0; i < frequencies.length; i++) {
                        if (frequencies[i] > 0) {
                                HuffmanNode node = new HuffmanNode(frequencies[i]);
                                node.ascii = i;
                                queue.add(node);
                        }
                }
                overallRoot = buildTree();      
        }
        

        public HuffmanCode(Scanner input) {
                overallRoot = new HuffmanNode(-1);
                while (input.hasNext()) {
                        int asciiValue = Integer.parseInt(input.nextLine());
                        String code = input.nextLine();
                        overallRoot = reconstructTree(overallRoot, code, asciiValue);
                }
        }
        

        private HuffmanNode buildTree() {
                if (queue.size() == 1) {
                        return queue.remove();
                } else {
                        HuffmanNode nodeLeft = queue.remove();
                        HuffmanNode nodeRight = queue.remove();
                        HuffmanNode nodeNew = new HuffmanNode(nodeLeft.frequency + nodeRight.frequency);
                        nodeNew.left = nodeLeft;
                        nodeNew.right = nodeRight;
                        queue.add(nodeNew);
                        return buildTree();
                }
        }
        

        private HuffmanNode reconstructTree(HuffmanNode root, String code, int asciiValue) {
                if (code.isEmpty()) {
                        root.ascii = asciiValue;
                        return root;
                } else {
                        char next = code.charAt(0);
                        if (next == '0') {
                                if (root.left == null) {
                                        root.left = new HuffmanNode(-1);
                                }
                                root.left = reconstructTree(root.left, code.substring(1), asciiValue);
                        } else if (next == '1') {
                                if (root.right == null) {
                                        root.right = new HuffmanNode(-1);
                                }
                               root.right = reconstructTree(root.right, code.substring(1), asciiValue);
                        }
                }
                return root;
        }
        

        public void save(PrintStream output) {
                save(output, overallRoot, "");
        }

        private void save(PrintStream output, HuffmanNode root, String code) {
                if (root != null) {
                        if (root.ascii != -1) {
                                output.println(root.ascii);
                                output.println(code);
                        }
                        save(output, root.left, code + "0");
                        save(output, root.right, code + "1");
                }
        }
        

        public void translate(BitInputStream input, PrintStream output) {
                while (input.hasNextBit()) {
                        translate(overallRoot, input, output);
                }
        }
        

        private void translate(HuffmanNode curr, BitInputStream input, PrintStream output) {
                if (curr.left == null && curr.right == null) {
                        output.write(curr.ascii);
                } else {
                        int token = input.nextBit();
                        if (token == 0) {
                                translate(curr.left, input, output);
                        } else {
                                translate(curr.right, input, output);
                        }
                }
        }
        
  
        private static class HuffmanNode implements Comparable<HuffmanNode> { 
                public int frequency;
                public int ascii;
                public HuffmanNode left;
                public HuffmanNode right;
                        
               
                public HuffmanNode(int frequency) {
                        this.frequency = frequency;
                        this.ascii = -1;
                }

  
                public int compareTo(HuffmanNode other) {
                        return this.frequency - other.frequency;
                }
        }
}

 

 

*code is provided and the error is in the picture, please help with how to fix the error* 

Failed:
You did not upload your secretmessage.short and/or
secretmessage.code properly
Hide stacktrace
org.opentest4j.AssertionFailedError:
You did not upload your secretmessage.short and/or secretmessage.code
at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:39)
at org.junit.jupiter.api. Assertions.fail(Assertions.java:109)
at HuffmanCodeTest.failFormatted(HuffmanCodeTest.java:54)
at HuffmanCodeTest.testFilesExistence (HuffmanCodeTest.java:270)
Transcribed Image Text:Failed: You did not upload your secretmessage.short and/or secretmessage.code properly Hide stacktrace org.opentest4j.AssertionFailedError: You did not upload your secretmessage.short and/or secretmessage.code at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:39) at org.junit.jupiter.api. Assertions.fail(Assertions.java:109) at HuffmanCodeTest.failFormatted(HuffmanCodeTest.java:54) at HuffmanCodeTest.testFilesExistence (HuffmanCodeTest.java:270)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Keywords
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education