Skip to main content

All Questions

-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
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
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
1 vote
2 answers
109 views

How to get rows of a csv file into a linkedlist iteratively?

I am asked to extract rows of a csv file into a linkedlist, every node of the linkedlist will store one row of the data, where the "data" pointer inside the linkedlist points towards a ...
MZGhibli's user avatar
1 vote
2 answers
105 views

I don't understand how this function works, which is reverse() function in implementation of a linked list

Here is code for implementing a singly-linked list: class LinkedList { constructor(value) { this.head = { value: value, next: null, }; this.tail = this.head; this.length =...
AbdelrahmanMurad's user avatar
1 vote
1 answer
128 views

Mergesort for singly-linked lists gives correct results but leaks memory

I'm working on an assignment to implement mergesort for singly-linked lists in C++. The merge function needs to merge two sorted lists in-place without creating new nodes. The mergesort function ...
Milad Khazani's user avatar
2 votes
3 answers
72 views

Why does this Linked List C function not work properly if previousNode->next is not set to NULL?

Node* deleteAtTail(Node* head) { if (head == NULL) /* If List is empty... */ { return NULL; } else /* ...
BMAGS's user avatar
  • 29
0 votes
1 answer
54 views

I'm having a problem with insertion in a singly Linked List on python

So, I was coding a linked list in python using classes and after succesfullly defining and running all of the methods I setted up for the class, I decided to create an "insert" method, where ...
Pedddrym's user avatar
1 vote
2 answers
131 views

Why I'm hitting time limit!? LeetCode Linked List Cycle (Solved but explanation needed!)

I'm working on solving LeetCode problem 141. Linked List Cycle: Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is ...
Simone Anthony's user avatar
1 vote
1 answer
277 views

Can we reverse the elements in a Singly Circular Linked List using only two pointers? Is that possible, efficient and what is the time complexity?

I need to know about only one thing clearly, as I had tried the singly circular linked list reversal using the C language. In that I can't find the correct way and I have no idea regarding this one. ...
SRIRAM M's user avatar
1 vote
1 answer
129 views

What happens to the lost part of a singly Linked list when I am introducing a loop at the middle?

I have created a singly linked list, and this is how it looks after displaying it: 19-->85-->50-->20-->33-->9-->1-->7-->null I have created a method that can add a node to a ...
NV basnayaka's user avatar
0 votes
1 answer
108 views

Which is the correct approach to delete LinkedList Node?

I have created a Linked List in C. Now I want to delete node from any position for example the first node or last node or any nth node. I wrote a code that worked fine. But problem is that someone ...
below_heaven's user avatar
0 votes
1 answer
64 views

Linked-List nth insertion fails

I have wrote a code to insert data in LinkedList. But there is problem outputting the data. Here is the code. #include <stdio.h> #include <math.h> #include <string.h> #include <...
below_heaven's user avatar

15 30 50 per page
1
2 3 4 5
29