singly linked lists — .101

Michelle Juma
2 min readApr 27, 2022

kids, am I right?

To my friend,

We are going to have a quick read on singly linked lists.

follow the leader

You see this image , we can say its a singly linked list.

  • The teacher is the HEAD , the last one is …the last of the list.
  • Singly linked list(node) is like an array , but it has data and address of the next data, so now we can say : node{data, pointer}.
  • ps : IT IS NOT AN ARRAY. in any way.
  • The child is the data itself , and the child’s hand is the pointer of the next child(data).
  • We identify last of the list if the pointer part of a node is NULL (ref, last child hand not holding anything)

Accessing this list & other stuff

  • To get any child(node), we have to start from the Teacher(head).
  • suppose we need to add a new child(node) at the end of ‘our follow the leader.’
    We : get a new lastchild (data) , we set the pointer to null.(tell child not to hold anyone else’s hand)
    — -:then assign the previous last child to hold the hand(pointer) of this new lastchild.
    — -: then say the lastchild is the new lastchild.
  • Suppose we add the headteacher.
    - She will go to the teacher right? cause which headteacher will be the tail? Okay alot but anyways
    We : take the new headteacher(data) and let tell her to hold the hand (pointer) of the teacher.
    — -: we say new headteacher is the head now.

We can access other nodes by aceessing the one before it I believe. To delete and what not.
But this is a simplified version.

This was more of a crash course.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Michelle Juma
Michelle Juma

Written by Michelle Juma

My other github — but with more words.

No responses yet

Write a response