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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:03:56+00:00 2026-06-13T09:03:56+00:00

Here is the class header along with its fields below: public class SinglyLinkedList <E>

  • 0

Here is the class header along with its fields below:

public class SinglyLinkedList <E> implements MiniList <E> 
{
   protected Entry <E> head = null;

   private int size = 0; 

I need to implement this method for my lab and I’m clueless with LinkedLists:

   public boolean add(E element) 
   {

         //method should return true once element is added

         //EDIT: I THINK I SOLVED IT:
         head.element = element;
         return true;

         //Does everyone think the two lines above look correct?
   }

So very simply problem and I’m very new to non-random access data structures. Could someone solve the problem above for me? I need a base foundation so I can continue with the rest of the lab.

  • 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-13T09:03:57+00:00Added an answer on June 13, 2026 at 9:03 am

    Well, a Linked List works like this:

    You have the head node, this has a reference to the next node, which has a reference to the next, etc. Here’s a diagram I just drew:

    Linked List Diagram

    The head has a reference to the following nodes, but it also has the Data within. So if I create a Linked List of Strings.

    LinkedList<String> groceryList = new LinkedList<String>();
    groceryList.add("VEGGIES");
    groceryList.add("FRUITS");
    

    The head has the data VEGGIES, then also has a reference to the next object in the list, in other words the FRUITS term, which is also the tail.

    Let’s say our list is empty. No head, no tail, no data. This we assign our head as a new entry. It will be the first element in the list, and our doorway into accessing the list. If the list isn’t empty, in order to add to our list, we have to get access to the current last element in the list. To do that, we have to travel down the list.

    //Some Pseudo Code
    Entry current = head;
    Entry last = null;
    while(Not Done Looping)
    {
        Entry temp = current.getNext();
        if(temp is not null) //We have a reference to another element
        {
            //We have more list to see
            current = temp;
        }
        else
            last = current;
    }
    

    That will give us the last entry. Then in order to add another element, we simply set the reference of the last object to the Entry we’re trying to add.

    That’s the gist of how it works. Now you just have to implement that based upon what your “Entry” object is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few classes as shown here public class TrueFalseQuestion implements Question{ static{
Here's the problem html: <ul id="update-list"> <li class="update" onclick="window.location('some_url')"> <h2> some header </h2> <p>
Here is my class (product.cs) where is the method to insert the image: public
I have a template class defined in a header file like this. Here I
I found this code here class Usable; class Usable_lock { friend class Usable; private:
Given the code from here : class lazy_init { mutable std::once_flag flag; mutable std::unique_ptr<expensive_data>
What am I doing wrong here: class Helo { // main: generate some simple
I have such class (sorry about posible mistakes, i'm writing it right here.) Class
template <bool, class t, class u>// why is bool here,class booltype=bool. Are they equivalent?
I have a fairly straightforward Java class here which creates 2 thread pools.... Connects

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.