We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Insert a node at the head of a linked list
Insert a node at the head of a linked list
Sort by
recency
|
982 Discussions
|
Please Login in order to post a comment
Just a warning to anyone writing this in C# c sharp: there is an error in the main function that makes solving this problem using C# impossible.
PrintSinglyLinkedList(llist->head, "\n", textWriter);
should be
PrintSinglyLinkedList(llist.head, "\n", textWriter);
Here is my c++ solution you watch vide explanation here : https://youtu.be/COnfpdhOlN8
here's my solution in C language:
SinglyLinkedListNode* insertNodeAtHead(SinglyLinkedListNode* llist, int data) { SinglyLinkedListNode* node = malloc(sizeof(SinglyLinkedListNode)); node->data = data; node->next = llist; llist = node; return llist; }
It must be something wrong with the task. The constrains says that the lsit is not null and data is not null. So I made a simple code:
They’re crucial for optimizing performance, especially when handling large volumes of data. ekbet11.com login