The arrow operator (->) in the algorithm is used to access a member of a struct using a pointer to that struct. It is equivalent to using the dot operator (.) to access a member of a struct, but with the added step of dereferencing the pointer to the struct. For example, if p is a pointer to a struct node, then p->DATA is equivalent to (*p).DATA.

In your code, you are using the node_t typedef to define the struct node type. This means that you can use node_t * to refer to a pointer to a struct node, and you can use node_t->DATA to access the DATA member of a struct node pointed to by node_t.

It looks like you are trying to implement the first step of the algorithm, which is to allocate memory for the new node and store the ITEM value in the DATA member of the node. You are using malloc to allocate memory for the new node, but you need to initialize the DATA member and the LINK member of the node. You can do this by using the arrow operator to access the members of the node:

node_t *create(int head, int item){
    node_t* new =  NULL;
    new = (node_t *)malloc(sizeof(node_t));
    if(new == NULL){
        printf("Memory not available");
        return -1;
    }

    new->DATA = item;  // Set the DATA member of the new node
    new->LINK = NULL;  // Set the LINK member of the new node to NULL
}

You also need to return the new node from the create function so that you can use it later in the algorithm.

node_t *create(int head, int item){
    node_t* new =  NULL;
    new = (node_t *)malloc(sizeof(node_t));
    if(new == NULL){
        printf("Memory not available");
        return -1;
    }

    new->DATA = item;  // Set the DATA member of the new node
    new->LINK = NULL;  // Set the LINK member of the new node to NULL

    return new;  // Return the new node
}

You can then use the create function to create a new node and store it in a local variable in your main program. This will allow you to continue implementing the rest of the algorithm.

int main() {
    int head = 0;  // The head of the linked list
    int item = 5;  // The data to store in the new node

    node_t *new_node = create(head, item);  // Create a new node

    // Continue implementing the rest of the algorithm...

    return 0;
}

Answer from Bhaskar13 on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › singly-linked-list-tutorial
Singly Linked List Tutorial - GeeksforGeeks
January 13, 2026 - In this example, the Node class contains an integer data field (data) to store the information and a pointer to another Node (next) to establish the link to the next node in the list. ... Allocate memory for the first node and Store data in it. Mark this node as head. ... Allocate memory for the second node and Store data in it. Link the first node’s next to this new node. ... Allocate memory for the third node and Store data in it. Link the second node’s next to this node. Set its next to NULL to ensure that the next of the last is NULL. ... #include<iostream> using namespace std; // sing
Top answer
1 of 1
2

The arrow operator (->) in the algorithm is used to access a member of a struct using a pointer to that struct. It is equivalent to using the dot operator (.) to access a member of a struct, but with the added step of dereferencing the pointer to the struct. For example, if p is a pointer to a struct node, then p->DATA is equivalent to (*p).DATA.

In your code, you are using the node_t typedef to define the struct node type. This means that you can use node_t * to refer to a pointer to a struct node, and you can use node_t->DATA to access the DATA member of a struct node pointed to by node_t.

It looks like you are trying to implement the first step of the algorithm, which is to allocate memory for the new node and store the ITEM value in the DATA member of the node. You are using malloc to allocate memory for the new node, but you need to initialize the DATA member and the LINK member of the node. You can do this by using the arrow operator to access the members of the node:

node_t *create(int head, int item){
    node_t* new =  NULL;
    new = (node_t *)malloc(sizeof(node_t));
    if(new == NULL){
        printf("Memory not available");
        return -1;
    }

    new->DATA = item;  // Set the DATA member of the new node
    new->LINK = NULL;  // Set the LINK member of the new node to NULL
}

You also need to return the new node from the create function so that you can use it later in the algorithm.

node_t *create(int head, int item){
    node_t* new =  NULL;
    new = (node_t *)malloc(sizeof(node_t));
    if(new == NULL){
        printf("Memory not available");
        return -1;
    }

    new->DATA = item;  // Set the DATA member of the new node
    new->LINK = NULL;  // Set the LINK member of the new node to NULL

    return new;  // Return the new node
}

You can then use the create function to create a new node and store it in a local variable in your main program. This will allow you to continue implementing the rest of the algorithm.

int main() {
    int head = 0;  // The head of the linked list
    int item = 5;  // The data to store in the new node

    node_t *new_node = create(head, item);  // Create a new node

    // Continue implementing the rest of the algorithm...

    return 0;
}

The arrow operator (->) in the algorithm is used to access a member of a struct using a pointer to that struct. It is equivalent to using the dot operator (.) to access a member of a struct, but with the added step of dereferencing the pointer to the struct. For example, if p is a pointer to a struct node, then p->DATA is equivalent to (*p).DATA.

In your code, you are using the node_t typedef to define the struct node type. This means that you can use node_t * to refer to a pointer to a struct node, and you can use node_t->DATA to access the DATA member of a struct node pointed to by node_t.

It looks like you are trying to implement the first step of the algorithm, which is to allocate memory for the new node and store the ITEM value in the DATA member of the node. You are using malloc to allocate memory for the new node, but you need to initialize the DATA member and the LINK member of the node. You can do this by using the arrow operator to access the members of the node:

node_t *create(int head, int item){
    node_t* new =  NULL;
    new = (node_t *)malloc(sizeof(node_t));
    if(new == NULL){
        printf("Memory not available");
        return -1;
    }

    new->DATA = item;  // Set the DATA member of the new node
    new->LINK = NULL;  // Set the LINK member of the new node to NULL
}

You also need to return the new node from the create function so that you can use it later in the algorithm.

node_t *create(int head, int item){
    node_t* new =  NULL;
    new = (node_t *)malloc(sizeof(node_t));
    if(new == NULL){
        printf("Memory not available");
        return -1;
    }

    new->DATA = item;  // Set the DATA member of the new node
    new->LINK = NULL;  // Set the LINK member of the new node to NULL

    return new;  // Return the new node
}

You can then use the create function to create a new node and store it in a local variable in your main program. This will allow you to continue implementing the rest of the algorithm.

int main() {
    int head = 0;  // The head of the linked list
    int item = 5;  // The data to store in the new node

    node_t *new_node = create(head, item);  // Create a new node

    // Continue implementing the rest of the algorithm...

    return 0;
}

Answer from Bhaskar13 on Stack Overflow
People also ask

How do you reverse a singly linked list?
Reversing a singly linked list involves changing the direction of the pointers. You would typically iterate through the list, changing the next pointer of each node to point to the previous node instead. This requires careful handling to avoid losing references to nodes during the process.
🌐
wscubetech.com
wscubetech.com › resources › dsa › singly-linked-list-data-structure
Singly Linked List in Data Structure (With Examples )
What is the difference between singly linked list and doubly linked list?
In a singly linked list, each node has a single link that points only to the next node in the sequence. Conversely, in a doubly linked list, each node has two links: one pointing to the next node and another pointing to the previous node, allowing bidirectional traversal.
🌐
wscubetech.com
wscubetech.com › resources › dsa › singly-linked-list-data-structure
Singly Linked List in Data Structure (With Examples )
Can a singly linked list be implemented without a head pointer?
While theoretically possible, implementing a singly linked list without a head pointer is impractical because it complicates the insertion and deletion operations at the beginning of the list, which would require finding the starting point of the list through other means each time.
🌐
wscubetech.com
wscubetech.com › resources › dsa › singly-linked-list-data-structure
Singly Linked List in Data Structure (With Examples )
🌐
Wikipedia
en.wikipedia.org › wiki › Linked_list
Linked list - Wikipedia
5 days ago - In fact, in the context of such algorithms, the word "list" often means "list handle". In some situations, however, it may be convenient to refer to a list by a handle that consists of two links, pointing to its first and last nodes. The alternatives listed above may be arbitrarily combined in almost every way, so one may have circular doubly linked lists without sentinels, circular singly ...
🌐
TutorialsPoint
tutorialspoint.com › data_structures_algorithms › linked_list_algorithms.htm
Linked List Data Structure
The basic operations in the linked lists are insertion, deletion, searching, display, and deleting an element at a given key. These operations are performed on Singly Linked Lists as given below −
🌐
codeintuition
codeintuition.io › home › data structures learning path › singly linked list
Singly Linked List | Data Structures Learning Path | Codeintuition
May 26, 2026 - The fundamentals close with Floyd's tortoise and hare algorithm. You walk through why two pointers moving at different speeds detect a cycle in O(N) time and O(1) space, then extend the same idea to find the cycle's entry node. This sets up a recurring theme of the rest of the course: most non-trivial singly linked list problems are solved by running two references over the list at the same time, in different ways.
🌐
Study Glance
studyglance.in › ds › display.php
Single Linked List - Data Structures Tutorial | Study Glance
Here are the basic operations that can be performed on a singly linked list: Algorithm · 1. Allocate memory for the new node. 2. Assign the data to the new node. 3. Make the 'next' of the new node point to the current head node. 4. Update the head node to be the new node.
Find elsewhere
🌐
Medium
medium.com › @18bhavyasharma › python-data-structures-crafting-a-singly-linked-list-with-essential-operations-25b3d40029d4
Python Data Structures: Crafting a Singly Linked List with Essential Operations | by bhavya sharma | Medium
November 2, 2024 - we implemented a basic singly linked list in Python, covering the essential operations such as insertion, deletion, reversing, and displaying the list. Linked lists provide a flexible way to manage data dynamically, making them an important structure in many algorithms and applications.
🌐
Wordpress
allcprogrammingandalgorithm.wordpress.com › singly-linked-lists
Singly Linked Lists – All c programming & algorithm
July 3, 2019 - In C, the structure of a Singly linked list can be given as, struct node { int data; struct node *next; }; ... Traversing a linked list means accessing the nodes of the list in order to perform some processing on them.
🌐
BtechSmartClass
btechsmartclass.com › data_structures › single-linked-list.html
Data Structures Tutorials - Single Linked List with an example
Step 5 - Keep moving the temp to its next node until it reaches to the last node in the list (until temp → next is equal to NULL). Step 6 - Set temp → next = newNode. We can use the following steps to insert a new node after a node in the single linked list...
🌐
WsCube Tech
wscubetech.com › resources › dsa › singly-linked-list-data-structure
Singly Linked List in Data Structure (With Examples )
July 25, 2026 - Learn about Singly Linked Lists in Data Structure, its examples, operations, and programs. Explore essential concepts and implementation techniques.
🌐
DEV Community
dev.to › bradisrad83 › data-structures-and-algorithms-singly-linked-list-53de
Data Structures and Algorithms - Singly Linked List - DEV Community
May 21, 2022 - Singly linked lists are similar ... that if you need to access the 3rd item in the array you would be able to have direct access where in the linked list you would have to traverse each node until you reached the 3rd node...
🌐
Javatpoint
javatpoint.com › singly-linked-list
Singly Linked List - Javatpoint
Before knowing about the types of a linked list, we should know what is linked list. So, to know about the linked list, click on the link given below: Types of Linked list The following are the types of linked list: Singly Linked list Doubly Linked list Circular Linked list Doubly Circular...
🌐
Scribd
scribd.com › doc › 76648586 › Algorithm-for-Linked-List
Singly Linked List Algorithms Guide | PDF | Pointer (Computer Programming) | Computer Programming
The document provides algorithms ... linked lists. These include creating a linked list, adding nodes, deleting nodes, sorting nodes, merging two linked lists, and reversing a linked list....
🌐
W3Schools
w3schools.com › dsa › dsa_algo_linkedlists_operations.php
DSA Linked Lists Operations
The simulation below shows the node we want to delete, and how the list must be traversed first to connect the list properly before deleting the node without breaking the linked list. ... Also, it is a good idea to first connect next pointer to the node after the node we want to delete, before we delete it. This is to avoid a 'dangling' pointer, a pointer that points to nothing, even if it is just for a brief moment. In the code below, the algorithm to delete a node is moved into a function called deleteSpecificNode. Deleting a specific node in a singly linked list in Python:
🌐
Takeuforward
takeuforward.org › blogs › data-structure-and-algorithm › singly-linked-list
Singly Linked List: Structure and Basic Operations | takeUforward
June 23, 2026 - Space Complexity: O(1) auxiliary space because no extra data structure is used apart from the new node being inserted. Given the head of a singly linked list and a value X, insert a new node containing X at the end of the linked list.
🌐
Filo
askfilo.com › higher education › smart solutions › write and explain algorithms for singly-linked list: a) traver
Write and explain algorithms for singly-linked list: a) traversing the li..
November 1, 2025 - Explanation: Traversal means visiting each node in the list exactly once. Starting from the head, we follow the next pointers until we reach the end. ... function traverseList(head): current = head while current != null: print(current.data) current = current.next ... Create a new node with the given data. Set the new node's next pointer to the current head. Update the head to point to the new node. Explanation: Inserting at the beginning means the new node becomes the first node. We link the new node to the old first node and update the head pointer.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › c-program-to-implement-singly-linked-list
C Program to Implement Singly Linked List - GeeksforGeeks
1 month ago - Algorithm: Set a temporary pointer to head. Traverse the linked list while the temporary pointer is not NULL. Print the data stored in the current node. Move the temporary pointer to the next node. Stop when the temporary pointer becomes NULL. Example: Program to Implement Singly Linked List ·
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › traversal-of-singly-linked-list
Traversal of Singly Linked List - GeeksforGeeks
August 17, 2026 - The process of traversing a singly linked list involves printing the value of each node and then going on to the next node and print that node's value also and so on, till we reach the last node in the singly linked list, whose next node is null.
🌐
Medium
medium.com › @noransaber685 › understanding-singly-linked-lists-a-comprehensive-overview-8104d1d94cbb
Understanding Singly Linked Lists: A Comprehensive Overview | by Noran Saber Abdelfattah | Medium
June 10, 2023 - The Floyd’s cycle-finding technique, ... in a linked list. This algorithm navigates the linked list using two pointers, one going slower (tortoise) and the other travelling quicker (hare)....
🌐
W3Schools
w3schools.com › dsa › dsa_data_linkedlists_types.php
DSA Linked Lists Types
DSA Euclidean Algorithm DSA Huffman Coding DSA The Traveling Salesman DSA 0/1 Knapsack DSA Memoization DSA Tabulation DSA Dynamic Programming DSA Greedy Algorithms · DSA Examples DSA Exercises DSA Quiz DSA Syllabus DSA Study Plan ... A singly linked list is the simplest kind of linked lists.