#linkedqueue without rear pointer?

9 messages · Page 1 of 1 (latest)

bright thunder
#

hi all! i'm currently working through a data structures practice problem about implementing a linkedqueue without using a rear pointer... and in my understanding i need something (a node?) to enqueue things after the front, but i'm honestly pretty lost on how to create it.

dawn coralBOT
#

This post has been reserved for your question.

Hey @bright thunder! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

willow anchor
#

Canyou show what you have so far?

bright thunder
#

nevermind, i just solved it (i think)

regal valleyBOT
#
        LinearNode<T> node = new LinearNode<T>(element);
        if(count == 0){
            front = node;  
        }else{
            LinearNode<T> current = front;
            while(current.getNext() != null){
                current = current.getNext();
            }
            current.setNext(node);
        }
        count++;
    } ```

This message has been formatted automatically. You can disable this using /preferences.

willow anchor
#

looks good

bright thunder
#

thank you! sometimes i get overwhelemed when doing problems and forget that i know how to do them haha

dawn coralBOT