Skip to content
Programming101
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programmingoneonone

Learn everything about programming

Traversing in Linked List

YASH PAL, 11 May 202028 May 2024

We can traverse in a linked list using the links of every node. As we know the single linked list is made up of a node where each node has two parts. one is the info part and the other one is link part.

Traversing - Singly Linked list

Info part of the list

The info part contains the actual data to be stored on the list.

The linked part of the list

link is a reference to the next value of the list.

Traversing - Singly Linked list

In a single linked list, we maintain a reference point to the first value of the linked list and we named it to start variable.

it’s the identity of the list and with the only help of start variable, we can access the whole list following the links of each node. if a node contains no value or None. this means the linked list ended up there. in the above image. the linked part of the node that contains the value None is the last node of the list. and for an empty linked list, the start variable contains the value None.

Traversing into list

Traversing means we can visit each node in a list at a single time.

To traverse into a list we need to know how we can move forward using the link of the list. suppose we have a reference to the node as you see in the image.

Traversing - Singly Linked list

so we write

p = p.link

so this refers to the next node of the list as you see in the image.

Traversing - Singly Linked list

Now to traverse into the linked list we need to refer to the first node of the list as you see in the image.

Traversing - Singly Linked list

so we point the variable p to the first node of the list using the code.

self.start = None

now using this code we can traverse the whole list.

def display_list(self):
    if self.start is None:
        print("List is empty")
        return    else:
        print("List is :   ")
        p = self.start
        while p is not None:
            print(p.info, " ", end=' ')
            p = p.link
        print()
Computer Science Tutorials Data Structures Tutorials computer scienceData Structure

Post navigation

Previous post
Next post
  • Automating Image Format Conversion with Python: A Complete Guide
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
How to download udemy paid courses for free

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes