Skip to main content
Filter by
Sorted by
Tagged with
-3 votes
2 answers
63 views

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
109 views

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
73 views

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
65 views

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
  • 129
1 vote
3 answers
235 views

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
166 views

#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
64 views

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
56 views

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
101 views

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
105 views

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
110 views

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
98 views

#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
49 views

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
270 views

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
-6 votes
1 answer
183 views

The merge sort code on Leetcode giving stack-overflow error. ListNode *findMiddle(ListNode *head){ if (!head) return nullptr; ListNode *slow=head; ListNode *fast=head; while (fast!=...
Amit Kumar's user avatar
1 vote
2 answers
137 views

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
121 views

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
0 votes
2 answers
70 views

I have this singly linked list: class Node{ constructor(val){ this.val = val; this.next = null; } } class SinglyLinkedList{ constructor(){ this.head = null; ...
fBpv's user avatar
  • 3
1 vote
1 answer
141 views

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
0 votes
2 answers
747 views

Please, what am I missing? I am trying to reverse a singly linked list (in-place), but all I get returned is the one node (pointer to the head of the list). I've tried using a void function (as a ...
AbuAminu's user avatar
-1 votes
1 answer
105 views

This is my code SLL Natural Merge Sort in C++: #include <stdio.h> #include <stdlib.h> typedef struct Node{ int data; Node* link; }NODE; typedef struct List{ NODE* first; ...
Huy Trần Ngọc's user avatar
2 votes
3 answers
83 views

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

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ...
Prakritish Ghosh's user avatar
-1 votes
1 answer
111 views

When using a singly-linked list, I've been suggested to use "if x != nullptr" but I don't understand why this works. In my example code, the first and second print statements work, but as ...
Tenacity's user avatar
0 votes
1 answer
59 views

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 votes
2 answers
42 views

I'm solving the leetcode question for adding two numbers in a linked list. The following is my code: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *...
Marut Kashyap's user avatar
1 vote
2 answers
184 views

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 votes
4 answers
113 views

list.h: In function ‘CreateNewLinks’: list.h:29:20: warning: assignment to ‘numbers *’ from incompatible pointer type ‘struct numbers *’ [-Wincompatible-pointer-types] 29 | linked = ...
Ahdm's user avatar
  • 1
1 vote
1 answer
316 views

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
0 votes
1 answer
81 views

Currently I'm doing a daily Leetcode streak and I have no idea why my code couldn't pass the case 3. (I have done modifying and tracing the code, but maybe I'm a bit dumb and couldn't spot the error.) ...
Kosumi's user avatar
  • 13
1 vote
1 answer
44 views

I have two functions for merging two linked lists assuming they have the same number of elements The first one: def shuffle_merge(self, l1,l2): node1 = l1.head node2 = l2.head ...
notsoanonperson's user avatar
1 vote
1 answer
152 views

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
-1 votes
1 answer
228 views

This is the solution i have given. class Solution { public boolean isPalindrome(ListNode head) { String s= ""; String p= ""; while(head != null){ ...
ARPAN NANDI's user avatar
0 votes
1 answer
67 views

Java linked list API not allowed. Is it possible to have a linked list inside a list node? If yes, how do I insert data into the linked list that is in the list node? List Node class (I tried to add a ...
Blueyu's user avatar
  • 99
1 vote
2 answers
93 views

This is my first post on StackOverFlow, I was writing the code for a linked list in C, when suddently stumble upon a situation i have no solution for (located in dupstring function). This is my ...
José Gomes's user avatar
0 votes
0 answers
21 views

First things first, I am not allowed to use the Java API for linked list, the Linked List and List Node codes are given by my teacher, so it may or may not be the same as the stuff you see in the API. ...
Blueyu's user avatar
  • 99
0 votes
1 answer
133 views

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
46 views

I have created a linkedlist class with deletion method. I have written the code to delete the node no matter what situation it is, like if deleting node is self.head if only one node present in ...
Mahesh's user avatar
  • 1
0 votes
1 answer
53 views

Given a Linked list, the task is to print a singly linked list in a spiral fashion. Starting from the first node then the last node followed by the second node and then the second last node, ...
techieadi4703's user avatar
0 votes
1 answer
68 views

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
0 votes
0 answers
49 views

Hi there. Thank you all for your comments. The problem solved and I also learn something new about editing and formatting. I want to thumb up every comment and close the post but I did not figure out ...
30yearsOldNewbie's user avatar
1 vote
2 answers
148 views

I am currently learning Java and data structures, and I am trying to use insertion to insert the values in a double array to a LinkedList by only inserting each element at the end of the list. I've ...
rzan1's user avatar
  • 37
0 votes
1 answer
63 views

Given the datastructure #define DATASTRUCTURE_H #define MAXINDEX 307 typedef enum {So, Mo, Di, Mi, Do, Fr, Sa} eDayofTheWeek; typedef struct{ int Day; int Month; int Year; ...
Angargedon's user avatar
0 votes
3 answers
137 views

What is the difference between struct LinkedList *current = malloc(sizeof(struct LinkedList)); and struct LinkedList *current; where struct LinkedList{ int data; struct LinkedList *next; } When I ...
Data Scientist to be's user avatar
1 vote
1 answer
93 views

I was solving the problem 20. Valid Parentheses in Leetcode using c and when they check this input s ="{[]}" the code returns false instead of true but I don't see any problem with the code:...
roger_hai's user avatar
0 votes
0 answers
130 views

You are given a linked list containing 'n' 'head' nodes, where every node in the linked list contains two pointers: (1) ‘next’ which points to the next node in the list (2) ‘child’ pointer to a linked ...
Great412's user avatar
0 votes
1 answer
51 views

I'm seeking clarification on how to properly understand a singly linked list once it has been reversed. Typically, the first element of the list should always be stored at the head of the linked list....
Sina Heidari's user avatar
0 votes
3 answers
109 views

I'm receiving these 4 errors: character expected errors character expected errors I'm doing a LinkedList java project that requires the implementation of the CompareTo method. I am rusty on Java and ...
mmccoy411's user avatar
0 votes
2 answers
115 views

I am trying to solve swap node in pairs (linked list). I have the correct code, but I am stucked while interpreting swapping step. here is the code: def swapPairs(head): pre = ListNode(0) pre....
Taelung's user avatar
0 votes
2 answers
59 views

struct n { int data; struct n* next; }; typedef struct n node; node* push(node* s, int x) { node* temp;// temporary element temp = (node*)malloc(sizeof(node)); if (temp == NULL) {...
trgtulas's user avatar

1
2 3 4 5
54