Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8714669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:39:15+00:00 2026-06-13T05:39:15+00:00

The below is an excerpt from a file in a project creating Huffman Trees.

  • 0

The below is an excerpt from a file in a project creating Huffman Trees. When the
“public class HLinkedList” is initialized by itself, the separate file (also shown below) of HTreeNode ‘s methods such as .next, .left, .right have no problem working in HLinkedList’s file. Once the “extends java.util.Abstract~” is put in place, the HTreeNode methods cannot be referenced, and I resorted to copy-pasting HTreeNode into the same file, which is why the first lines of code show it as such. The thing with having both of these in the same file is that it’s causing collision(I think) between HLinkedList.HTreeNode and HTreeNode, as I kept the HTreeNode file just in case. This happens in a separate file Huffman_coder which originally used both HLinkedList and HTreeNode files very well (or at least without compile level error) until I decided to extend java.util.Abstract~

public class HLinkedList<HTreeNode> extends java.util.AbstractSequentialList<HTreeNode>
{

public class HTreeNode {


    public HTreeNode left;
    public HTreeNode right;
    public HTreeNode next;
    public int frequency;
    public char value;
    public String code;
    public HTreeNode(int freq, char val, HTreeNode l, HTreeNode r, HTreeNode n, String code) // code is the path taken to this node, how to explain it in code?
    {
        value = val;
        frequency = freq;
        left = l;
        right = r;
        next = n;
        code = ""; // just initialized ,but have to think through logic.
    }
}

 HTreeNode head;
static int nItem;

public HLinkedList() //constructor
{
    head = null; //inital value
    nItem = 0;//counter

}


public void insertIntoPosition(HTreeNode node, int position) //inserts into position
{
    //first, the case where it's already in the list.
        HTreeNode currNode = head;
        while(currNode.next != null)
        {
            if(currNode.value == node.value)
            {
                currNode.frequency++;
            }

            currNode = currNode.next;           
        }
        if(currNode.value == node.value)
        {
            currNode.frequency++;
        }

HTreeNode file:

public class HTreeNode {


    public static  HTreeNode left;
    public HTreeNode right;
    public HTreeNode next;
    public int frequency;
    public char value;
    public String code;
    public HTreeNode(int freq, char val, HTreeNode l, HTreeNode r, HTreeNode n, String code) // code is the path taken to this node, how to explain it in code?
    {
        value = val;
        frequency = freq;
        left = l;
        right = r;
        next = n;
        code = ""; // just initialized ,but have to think through logic.
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:39:16+00:00Added an answer on June 13, 2026 at 5:39 am

    If you want to extend then you should extend java.util.AbstractSequentialList<E>, the generic version instead of the raw one.

    Your compiler was complaining because either you didn’t import the class, or your methods were not public, or you are not invoking them the right way (may you made them non-static and tried to invoke on the class itself).

    Update


    I am not sure of what you are trying to achieve, but believe is something that doesn’t generate any compiler error (with some comments) –

    //E is a type parameter, meaning HLinkedList<E> is generic
    public class HLinkedList<E> extends java.util.AbstractSequentialList<E> {
    
        //I think you can keep this private here, this only helps you to implement your
        //version of AbstractSequentialList, for anyone who will be using HLinkedList
        //are not going to worry about it
        private static class HTreeNode {
            public HTreeNode left;
            public HTreeNode right;
            public HTreeNode next;
            public int frequency;
            public char value;
            public String code;
    
            public HTreeNode(int freq, char val, HTreeNode l, HTreeNode r, HTreeNode n, String code)  {
                value = val;
                frequency = freq;
                left = l;
                right = r;
                next = n;
                code = ""; 
            }
        }
    
        private HTreeNode head;
        private int nItem; //made this non-static, each instance will need it's own copy
    
        public HLinkedList()  {
            this.head = null;
            this.nItem = 0;
        }
    
        public void insertIntoPosition(E element, int position)  {
            // probably create a new node here for element
            // and fix it at the location specified
        }
    
        //This is an abstract method declared in AbstractSequentialList
        //You need provide an implementation of it
        @Override
        public ListIterator<E> listIterator(int index) {
    
            return null;
        }
    
        //This is an abstract method declared in AbstractSequentialList
        //You need provide an implementation of it    
        @Override
        public int size() {
    
            return 0;
        }
    }
    

    Now imagine, the following is how the clients will be using HLinkedList –

    HLinkedList<Integer> list = new HLinkedList<Integer>();
    //or
    HLinkedList<String> list = new HLinkedList<String>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is an excerpt from an .svg file (which is xml): <text xml:space=preserve style=font-size:14.19380379px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
See the excerpt below taken from a PL/SQL tutorial. The part I have an
Below is the code from internalRegister method of GCMRegistrar class static void internalRegister(Context context,
This is an excerpt from a source file of wxPython: Create the output window
HI I am trying to download file from FTPS using python 2.7. Below is
I read this question in stackoverflow. The excerpt answer provided by bbum is below:
From my jQuery file, I call a function from my controller which returns a
So I'm attempting to grab text from a file when it appears in double
using the below MVN pom file, I execute 'mvn eclipse:clean eclipse:eclipse'. I get an
I got the source below from a third-party site explaining how to download a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.