Questions tagged [linked-list]

A linked list is a data structure in which the elements contain references to the next (and optionally the previous) element.

Filter by
Sorted by
Tagged with
0
votes
2answers
54 views

Filter a Linked List in Place in C

I have created the following function which filters a linked list in place (here it removes all instances of the element k), but it could easily be modified to take a function pointer as an argument ...
0
votes
1answer
64 views

How to have a nested struct as linked list in C? [closed]

I am new in C and I have to do a project which reads data from a .txt file and created linked list of structures to different operation on that structures (CRUD). The file contains data of rooms in a ...
2
votes
2answers
40 views

Merge Sort for Linked List Criticism in C

I previously implemented a Merge Sort for arrays, so after fixing up my code for the array-based merge sort I have now implemented a merge sort for a basic singly-linked list data structure which only ...
1
vote
0answers
27 views

Integer Double Ended Queue GO

I'm currently learning Go and I have decided to implement a Circular Doubly Linked List (Deque) structure for the training. Go is not my first language. I program mainly in Python, therefore I would ...
1
vote
2answers
91 views

Delete last node in singly linked list

In a TED talk Linus Torvalds made a point about “good taste” at approximately 14:10 in the interview. I read through his examples of “bad taste” and “good taste” and wanted to implement the same ...
2
votes
1answer
62 views

Ncurses Snake Game using a Linked List in C

This is a lightweight text based version of the popular game Snake written entirely in C. In order to build it, ncurses needs to be installed on the system. Navigation is done using the vim-keys and ...
2
votes
1answer
39 views

Linked list that support modifications during iteration

Update: Fixed last item is not removed during iteration Fixed clear() during iteration does nothing Fixed addition of removed item is ignored The lasted code can ...
5
votes
1answer
88 views

singly linked list python code

I have recently tried converting a singly linked list from a C program into my own python program. I have tested the code myself but I am still unsure if the program has been converted properly. I ...
4
votes
1answer
99 views

Forward List Implementation

NB: There's a bug with my iterator, apparently. I can't use const_iterator because I get some compiler errors. I know using const...
2
votes
0answers
54 views

Hash table library implementation

I wrote my own implementation of generic hash table. I’m using linked list to resolve collision problem. I want to share my code with you and get your opinion about it, and if there are any advice or ...
7
votes
4answers
315 views

Linked list implementation, manipulation, and testing in C

This is a beginner's attempt at implementing a linked list in C. Please read the code and provide recommendations. I do not want to limit the reader's benevolence to only these questions, but my ...
1
vote
1answer
55 views

Binary Radix Sort implementation on linked list

I am trying to implement binary radix sort in C which sorts a linked list of integers stably. Although my algorithm has a time complexity of O(log2(k).n) (where k ...
1
vote
2answers
92 views

Splitting a list by predicate

I have written a function splitAtPredicate that splits the list at element x satisfying p, ...
2
votes
2answers
57 views

remove kth last element from singly-linked list - Follow up

This code is a revised version of implementation which asked for an improvement. Original question is asked here: remove kth last element from singly-linked list credits to: Toby, Andreas, Arkadiusz ...
5
votes
2answers
280 views

Removing C comments from Source

Challenge posted 5 Dec 2020 to comp.lang.c This program is essentially the same as my Version 8 posted to that thread, but with some further cosmetic improvements. This program reads from stdin (or a ...
7
votes
3answers
594 views

Double Linked List with smart pointers: problems with insert method

I'm trying to implement a Templated Double Linked List, following Stroustrup's book "Principles and Practice using C++", Chapter 20.4. Instead of raw pointers, I want to use unique pointers. ...
0
votes
2answers
88 views

remove kth last element from singly-linked list

I have implemented a code to solve following problem. I would like to improve the code efficiency. Pardon if I just printed out the result. Code has O(N) time and constant space complexity. Given a ...
4
votes
1answer
64 views

Bump Allocator in Linked List

Here is my code for implementing a linked list with custom allocators (the standard malloc/free and a simple bump allocator). I appreciate any comments or critiques about architecture, formatting, and ...
4
votes
3answers
149 views

Generic implementation of a hashtable with double-linked list

I implemented a hashtable that handles collisions by chaining entries using a double linked list. The idea is that it can store/lookup any kind of generic data structure, while maintaining an API that ...
0
votes
0answers
17 views

A simple linked list for C practice

After a long break I have to return to programming in C. As an exercise I wrote this simple linked list thing. Please just have a look, any comments are appreciated. Just shoot. ...
9
votes
2answers
822 views

Floyd's cycle-finding algorithm

I am writing a piece of code for some students and I came up with the following implementation of Floyd's algorithm for finding cycles in linked lists. I was wondering if there are ways I can improve ...
10
votes
4answers
1k views

C Linked List Code Style

Here is my beginner code for dealing with a linked list. I appreciate any comments on structure, logic, formatting, and anything small or large. I have run the code using gcc and tested the small <...
6
votes
2answers
108 views

XOR linked list implementation - Follow Up

This question is a follow up question to the XOR linked list implementation. I am posting a new code here with taking into consideration the suggestions of Toby Speight and Deduplicator. Please advise ...
7
votes
2answers
783 views

XOR linked list implementation

I am trying to resolve below question in order to prepare for an interview xD An XOR linked list is a more memory efficient doubly linked list. Instead of each node holding next and prev fields, it ...
8
votes
2answers
757 views

Implementation of Doubly-linked list in C++

So I have tried to implement a doubly-linked list in C++. My implementation includes some basic methods (although I know there could be many more), an iterator class and an overwritten ...
5
votes
1answer
149 views

Generic double linked list implementation with tests in C

Can you please give your feedback to my double linked list implementation below? It comes with some very basic functions as well as separate code to test the implementation. The tests are only '...
7
votes
2answers
345 views

Doubly Linked List Data Structure ADT in C++

I'm trying to implement a Doubly Linked List data structure in C++. Please give me suggestions on how this code can be improved. Try to remain in C++11 because that's what I know atm. ...
3
votes
2answers
201 views

Linked List Queue Implementation

I implemented a Queue using linked list data structure. This is also my first time using templates in C++. OVERVIEW Queue is a data-structure that supports only ...
9
votes
1answer
288 views

Radix Tree Implementation in c

I tried implementing a radix tree using C language in order to get the auto complete suggestions of a dictionary. What are the improvements that I can do here? Also, is there any better way of doing ...
7
votes
3answers
1k views

Implementation of Singly Linked List (C++)

I tried to implement a singly linked list myself, sorry it is not commented but I think it should be pretty self-explanatory, if not feel free to comment. I know that using namespace std; is not ...
2
votes
0answers
36 views

Grading script in SCALA

The prompt is as follows: This script will use a text menu to give the user options. The options will include the ability to add grades of different types as well as an option to print the current ...
2
votes
1answer
599 views

Generic Doubly Linked-list implementation in C++

I am just learning about C++ templates and generic types, I decided it would be nice to try to create a generic container class as a challenge and test my knowledge in the process. Here is what I have ...
3
votes
1answer
88 views

Java Singly-linked List: how to be efficient and clean

this is my first time on StackExchange. I am new to writing code. This is a singly-linked list I made in Java using generics with no sentinel nodes (i.e. no empty head and tail nodes). Looking for ...
5
votes
3answers
118 views

Doubly linked-list implementation

I come from a C++ background, and I recently got into C, and one of the first things I made was a double linked list since I though it would be good practice for me with pointers and memory allocation....
4
votes
1answer
110 views

Extreme use of pointers in adjacency list graph construction?

Playing around with pointers in C++, implemented an adjacency list graph. Am I going too far/extreme trying to place data onto the heap? graph.h ...
2
votes
1answer
53 views

Linked List implementation of FileSystem directories

I am writing wrapper classes in Java which override methods of an existing implementation, in order to handle an edge case. The full implementation is a bit more complex than needs to be posted here, ...
5
votes
1answer
55 views

Dynamic-sized Hash table with Linked List

Below is an implementation heavily based on climberig's implementation on Leetcode for LeetCode 706. Design HashMap. Just to preface, I am doing this in preparation for an exam. The one below is ...
5
votes
1answer
64 views

Double LinkedList Deep Copy in Kotlin with Generics and Thread Safety

Goal Return a deep copy of a double LinkedList. Each node also contains an additional random pointer, potentially to any node or null. Code to start ...
2
votes
0answers
59 views

Async linked list to and from async iterable

I'm working on some stuff that works better with (immutable async) linked lists such as this: ...
4
votes
1answer
318 views

Doubly-linked list with iterators

Writing a double-linked list seemed like a good practice for understanding it. I tried to fix all the errors that were pointed out to me in the last question, as well as add new functionality. In ...
2
votes
0answers
45 views

Linkedlist & hashmap _duplicates removal

I have implemented a LinkedList removal fo duplicates class by using HashMap. Looking forward to your reviews. Thanks. ...
2
votes
1answer
48 views

Proper way of deallocating memory in SLL?

So I'm making my own singly linked list class, with methods that you'd expect such as remove() and insert(). I don't use ...
6
votes
2answers
810 views

Reversing a doubly linked list in C

Looking for feedback on this code to reverse a double linked list. Things I am potentially looking for but missed -> redundant operations, extra / unnecessary arithmetic, improvement in code style. ...
2
votes
2answers
188 views

Deleting a node in a singly linked list?

Please critique the following code on removing a node from a singly linked list, at the moment it seems to me like the code is quite clunky. ...
2
votes
1answer
147 views

Double LinkedList Deep Copy in Kotlin

Goal Return a deep copy of a double LinkedList. Each node also contains an additional random pointer, potentially to any node or null. Code to start ...
7
votes
1answer
114 views

Summing digits of a singly linked list

I want to familiarize myself with more data structures. As such I implemented a Node, singly-linked-list, as well as an algorithm to sum the digits of two such lists where each node contains the ...
5
votes
1answer
79 views

How to merge two descending singly linkedlist into one ascending linkedlist using Recursion without any helper method?

Here is my solution: I want to know if my solution fits the requirement 100%? Or if there is any better solution? Constraint of the question: must be singly linkedlist must use recursion, and no ...
3
votes
2answers
235 views

Singly linked list implementation in c++ (Data Structure)

I just finished writing an implementation of the "singly linked list data structure",and i wanna know if there are some bugs or memory leaks or any bad code to make the code better! i'm so ...
1
vote
0answers
52 views

Delete a linked list using recursion in Python

Given a Singly Linked-List, write a function to delete the linked list recursively. Below is my attempt. I am confused if I should use del keyword to delete the nodes or below method is better. I don'...
4
votes
1answer
57 views

Double linked list API design in C

I have created the following few functions for handling the use of doubly linked lists. list.c: ...

1
2 3 4 5
20