Skip to main content
How are we doing? Please help us improve Stack Overflow. Take our short survey
-1 votes
1 answer
106 views

Why do I only update the head pointer when deleting the first node in a singly-linked list, and can't use prev->next = head? [closed]

I'm implementing node deletion in a singly-linked list and ran into a conceptual problem regarding deleting the head (first node) of the list. I don't know why prev->next = head is not allowed? Isn'...
jamesnewbie's user avatar
-3 votes
3 answers
46 views

What is the difference when assigning an object like a LinkedList to a variable versus an array?

I was working on this problem from HackerRank trying to insert an element at the tail of a linked list and I have to return the head of the node. def insertNodeAtTail(head, data): if head is None:...
gradstudent1995's user avatar
0 votes
2 answers
95 views

How to dynamically create multiple instances of struct in loop in C? [duplicate]

I have the following code to create one-way list of user-specified number of elements typedef struct Node{ int val; struct * Node next; } Node; int main(){ int num; Node * prev = NULL;...
user98967885655's user avatar
0 votes
3 answers
64 views

Why doesn’t setting a linked list node's next pointer to null also affect the node it was pointing to?

I’m attempting to reverse a singly linked list in Java, but I'm running into confusion about how references work during the reversal process. Specifically, I don’t understand why setting the next ...
Samrudh S's user avatar
-1 votes
1 answer
53 views

writing pop from end function in rust

This is my singly linked list code have to implement pop from end and pop from front functions still, but I'm having difficulty in writing pop from end function #![allow(warnings)] #[derive(Clone)] ...
qmzp's user avatar
  • 109
1 vote
3 answers
135 views

Deleting one node of single linked list use double pointers in C language

I have been reading something related to C language's double pointers, and I have some doubts about the following piece of code. The following piece of code is about the operation of deleting a node ...
user3034702's user avatar
5 votes
3 answers
150 views

Having trouble understanding Linked List in C

#define SIZE 100000 // 1. hash_function() is a function that return an int // 2. snowflake_node typedef struct snowflake_node { int snowflake[6]; struct snowflake_node *next; } snowflake_node; ...
arifnone's user avatar
1 vote
1 answer
54 views

Error in using call by reference with function to change the head of a singly linked list

I'm learning linked lists in C, and have come across an error when trying to add a value at beginning of a linked list using functions #include<stdio.h> #include<stdlib.h> struct node{ ...
Cap_Void's user avatar
-1 votes
1 answer
48 views

how to make a linked list with template

i have problems with distributing template. i tried with different syntax, but not a successful way with the error text: error C2512: 'node': no appropriate default constructor available for the code ...
Mohamed Elhaware's user avatar
1 vote
2 answers
79 views

Alternate linked list merge

I wanted to merge 2 linked list’s elements alternatively. I counted the length of these 2 linked lists manually, then created a dummy-headed node to use for the merge. I am getting the errors "...
RIN's user avatar
  • 11
0 votes
5 answers
85 views

a heap-use-after-free wrong in the question--Design MyLinkList (LeetCode No.707)

Below is my C code for LeetCode no. 707 "Design Linked List": typedef struct MyLinkedList{ int val; struct MyLinkedList *next; } MyLinkedList, *LinkList; MyLinkedList* ...
Clay_Han's user avatar
1 vote
1 answer
101 views

Linked List Replacement Function with Head, Tail, and Size Management

I'm working on a SinglyLinkedList class in C++, where I maintain pointers to both the head and tail of the list, as well as an integer size to track the number of nodes. My goal is to implement a ...
Math Student's user avatar
0 votes
1 answer
97 views

Why the structure pointer "p" in the following code is not updating with the "temp" value assigned to it? [duplicate]

#include <stdio.h> #include <stdlib.h> struct node { int data; struct node *link; }; int main(int argc, char *argv[]) { struct node *p; p = NULL; Append(&...
AVINASH BHARTI's user avatar
-2 votes
2 answers
43 views

Which of these implementations is canonical: storing the head and size variables, or storing the head, tail, and size? [closed]

For a singly linked list, should I store the head and size variables, or the head, tail, and size?
Vivyen's user avatar
  • 85
0 votes
2 answers
260 views

Is using free(p->next) acceptable in C?

I'm working on solving a simple algorithm problem, and here's the question. In a singly linked list L with a head node, delete all nodes with the value x and free their space. Assume that nodes with ...
CN.hitori's user avatar
  • 158

15 30 50 per page
1
2 3 4 5
178