19,935 questions
3 votes
1 answer
101 views
Trying to populate a list from another sheet by a single reference number
I am working on a handy reference sheet for my DnD Games, that includes 10 pre-planned encounters of varying difficulty that I want to reference on an Initiative Sheet by referencing the Encounter ...
3 votes
2 answers
117 views
Code is returning "[C Kernel] Executable exited with code -11", don't know what's wrong with it?
I'm working on this piece of code as part of my coursework, ideally any advice I get for this would be educational in some way; I don't want an exact answer, just need someone who knows more than I do ...
Best practices
1 vote
7 replies
170 views
Memory allocation when using a linked list
So I'm making a linked list for one of my school assignments in C. I found this website that has some helpful code snippets, and I noticed that they use malloc() to allocate more memory every time ...
-3 votes
1 answer
132 views
Linkedlist create like below with shared_ptr is proper or wrong - [closed]
I am trying to create Linkedlist, where array is passed, and linkedlist is returned. However, there seems something wrong, and the linkedlist returned is circular. /** * Shared pointer, pass vector ...
0 votes
1 answer
169 views
Reversing a linked list returns only the head
I have been trying to create a method that can reverse a linked list. However, it only show the head of the original list without the rest of the parts showing up. I have tried making another, similar ...
1 vote
1 answer
53 views
Is circular linked list needed for "Circular" queue?/
I am learning about queue data structure in python. I learnt the implementation of a queue using list in python and the issue of memory wastage when we dequeue a few elements from the front. We use a ...
3 votes
2 answers
135 views
How to generalize a linked list node to store arbitrary data in C?
I’m trying to design a generic linked list in C where each node can store arbitrary data. Right now I have the following definitions: typedef struct { int clientID; char name[256]; } Client; ...
-1 votes
3 answers
273 views
LeetCode - 23. Merge k Sorted Lists algo issue
I was trying to solve this LeetCode Problem, and have been failing at it. The problem You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the ...
-6 votes
2 answers
168 views
Printing a linked list in C++ [closed]
I have simple question on C++ linked list. Say I am given a list, I just want to print for each node the value. I found this simple code on the net while (head!= NULL) { cout << head->...
-3 votes
2 answers
104 views
Error while assigning the next element pointer in a circular linked list in a vector of struct instances [closed]
I want to create a circular linked list in a vector of struct instances. The vector is used because the count of the list elements is identified during execution of the process. I have a problem while ...
1 vote
1 answer
96 views
Why does calling two functions in a single statement not affect the value? [duplicate]
In this code: // Stack using LinkedList // #include <stdio.h> #include <stdlib.h> struct Node { int data; struct Node* next; }; struct Node* top = NULL; short isEmpty(void) { ...
0 votes
1 answer
165 views
Java ArrayList and LinkedList performance [duplicate]
I know that it's a never-ending question that comes back every now and then, but I'm really confused about these two. This is what I understand about them. In theory: LinkedList is faster at adding ...
3 votes
3 answers
360 views
ArrayList vs LinkedList in terms of cache locality
How does cache locality impact the performance of ArrayList compared to LinkedList in Java? I've often heard that ArrayList has an advantage in terms of cache locality, but I don't fully understand ...
1 vote
1 answer
156 views
How can I use custom datatypes in my personal C libraries
I have implemented a linked list library in C. It has all the basic functions to quickly implement a linked list. I stored all that in a header file and an implementation file. Now I want my linked ...
0 votes
0 answers
111 views
Using Merge Sort to Sort a Linked List with Inline RISCV ASM
I'm writing a Merge Sort to sort a linked list with inline RISCV asm, everything work fine until I start writing the part of lists merging. Here is my function: typedef struct Node { int data; ...