Search⌘ K

Singly Linked List - Searching

Understand the structure of singly linked lists and master the process of searching by iterating from the head node until the desired element is found or the list ends. This lesson helps you grasp fundamental linked list operations essential for efficient algorithm implementation in competitive programming.

We'll cover the following...

Structure

Each node contains a value and a pointer to the next node.

C++
struct Node {
int val;
Node* next;
Node (int val) {
this->val = val;
this->next = NULL;
}
}

Searching

Searching in a linked list is pretty straightforward.

Start iterating from the head. Move to the next element ...