Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to add to the end of a linked list

typedef struct node{
    int value; //this is the value the node stores
    struct node *next; //this is the node the current node points to. this is how the nodes link
}node;

node *append(node *head, int val){
    node *tmp = head;
    node *createdNode = createNode(val);

    while(tmp->next != NULL){
        tmp = tmp->next;
    } 

    tmp->next = createdNode;
    return head;
}
Source by gitlab.com #
 
PREVIOUS NEXT
Tagged: #add #linked #list
ADD COMMENT
Topic
Name
7+8 =