FAQ: Linked Lists: Conceptual - Linked Lists Adding and Removing Nodes

This community-built FAQ covers the “Linked Lists Adding and Removing Nodes” exercise from the lesson “Linked Lists: Conceptual”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science

Linear Data Structures

FAQs on the exercise Linked Lists Adding and Removing Nodes

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Why is node b orphaned in one of these linked lists and not the other?

1 Like

In the example, node_a link was changed from node_b to node_c, which left node_b without reference (no other node is pointing to it), hence orphaned.

All the images in the exercise are the same linked list, not different.

1 Like

What happens if we link the tail node to the head node? Is there any significance in doing this?

1 Like

Wondering the same! I am thinking like real-life example, you are linking destination with origin but…now i am thinking maybe is problematic and more costly to computing if you wanna find end nodes, you would never find the end of a search giving a infinite bucle? or…well, also would be more costly if you wanna add a new node cuz you should look the one before, link to other and remove the unlinked one instead of simply adding up new one. It is the two things i am thinking now. They are 3 operations instead of 1?

How come the first node in the list is not also “orphaned” as it has no other node referencing it?
In our example we have A → C and B → C

“Since the nodes use links to denote the next node in the sequence, the nodes are not required to be sequentially located in memory.”
Can someone could give more details about that please? How does the memory process works?

I think it is because node_A has the “head node” status, so no need a pointer on it.

What I understood until now, maybe it will helps some people:
Linked lists are more memory efficient than arrays because each value of an array will be stock in an individual memory adress, so if your array has 50 values and you use only 25 of them, you will waste 25 memory locations.
Linked list wil use only the memory that is needed.

Hi, everybody,

I tried to create a function to remove all the nodes having the same value, but I’m having a hard time understanding the logic behind it.

Could you get a look at my code (I created a function called “remove_nodes()”) and tell me how to implement it (or rather, explain me how I can do it), please?

Thanx in advance for your help,
Fabio