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 8650325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:47:32+00:00 2026-06-12T13:47:32+00:00

private Node back isn’t used yet, and enqueue (which was push) and dequeue (which

  • 0

private Node back isn’t used yet, and enqueue (which was push) and dequeue (which was pop) haven’t really been modified except for renaming some things. Again, this was originally a stack but I’m trying to modify it into a queue. I’ve done non-linked list queues and stacks before with ints, but with objects and linked lists I’m sort of lost.

public class DogQueue 
{
    private Node front = null;
    private Node back = null;
    private Node element = null;
    private int counter = 0;

The above is just setting up variables.

  private class Node //This sets up the Linked List
                     //Data Structure with nodes.
  {
      private Dog doggy;
      private Node nextNode;
      private Node firstNode;

      Node(Dog newDog)
      {
          doggy = newDog;
      }    
  }

Node stuff which I don’t quite understand is above.

  public void enqueue(Dog aDog) //This should enqueue
                                //an object of type Dog.
  {       
      Node dogNode = new Node(aDog);
      dogNode.nextNode = front;
      counter++;
      front = dogNode;
  }

The above here is unmodified from the push method, just renamed.

  public Dog dequeue()      //This should output
                            //the first entry in the list.
  {
      Dog firstDog = front.doggy;
      element = front.firstNode;
      counter--;
      return firstDog;
  }

The above here is where I’m having the most trouble- currently it behaves like pop (getting and removing the last entered element in the list).

  public boolean isFull()   //Checks to see if List is Full.
  {
      return ( counter == 5 );
  }

I set up the counter to just go up to 5 so I can debug isFull.

  public boolean isEmpty()  //Checks to see if List is empty
  {
      if ( counter == 0 )
        {
            return true;
        } else {
            return false;
        }
  }

This just says if counter is zero, then isEmpty is true (otherwise false).

}
  • 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-12T13:47:34+00:00Added an answer on June 12, 2026 at 1:47 pm

    I suck at data structures but I believe your enqueue and dequeue are still behaving like pop and push.
    The front should point to the head of the queue and the tail one past the last valid object. So the tail should eventually point to null..
    I think it should be something like this:

      public void enqueue(Dog aDog)
         {
             Node dogNode = new Node(aDog);
    
             counter++;
             if (front == null)
                 front = back = dogNode;
             else
             {
                 back.nextNode = dogNode;
                 back = dogNode;
    
             }
         }
      public Node dequeue()      
      {
          if(front == null) return null;
          Dog firstDog = front ;
          front = front.nextNode;
          counter--;
          return firstDog;
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class Node { private Node nextNode; @Override public int hashCode() { //How to
private void BindCountry() { XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath(countries.xml)); foreach (XmlNode node in
I wrote the following code to count the node of an XML file: private
Well, I have the following class definitions: private ObservableCollection<Node> _Nodes; public ObservableCollection<Node> Nodes {
<mx:Script> <![CDATA[ private function openAllNodes():void { tree.openItems = dp..node; } private function closeAllNodes():void {
public class Graph { private Node node; public void createGraph() { } private class
Here is my code: class BinaryTree<T> { private node<T> Head; public class node<T> {
private final List<KeyListener> keyListeners= new CopyOnWriteArrayList<KeyListener>(); public void addKeyListener(KeyListener keyListener){ keyListeners.add(keyListener); } In the
private String setDate(int day) { Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.DATE, + day);
private int Index(String[] match,String keyword){ int m=0; keyword=keyword+1; match[m]=match[m]+1; System.out.println(match:+match[m]); System.out.println(keyword:+keyword); System.out.println(match[m].equals(keyword)); while(!(match[m].equals()) &&

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.