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
1
vote
1answer
50 views

Create a linked list from an array, and also free that list

I'm currently learning C/C++ and I saw this question on Reddit on how to create a linked from an array and decided that would make a good exercise for learning the absolute basics of C, so without ...
1
vote
1answer
62 views

Generic doubly linked list in C

I have implemented generic doubly linked list in C language in which you can store any data type you want. Just like in C++ and Java, where a list can store any data type, like - string, int, long, ...
2
votes
1answer
86 views

Finding better logic for addition and removal of Nodes in a Linked List

Consider the following piece of code I wrote (a templated Linked List): ...
2
votes
4answers
112 views

Single-linked-list in C++ with iterators

I'm implementing a single linked list as close as it could be to std::forward_list. I would welcome a review and also more suggestions on what to test additionally. ...
3
votes
2answers
51 views

Testing MRU-list vs. standard list

The task is to test the the benefits of a Move-To-Front Linked List vs. a standard Linked List. It was also meant to practice inheritance and pointers. The standard functionality is in ...
3
votes
2answers
257 views

Function to create single linked-list

Given the following data struct: typdef struct lista { int num1, num2; struct lista* sig; } nodoNum ; and a declared ...
0
votes
1answer
107 views

Linked List Implementation in C#

I wrote an implementation of the Linked list data structure. I mostly did this because it's the simplest collection data structure (at least the simplest to implement), and I wanted to practice ...
0
votes
1answer
37 views

Faster, indexed, heuristic doubly-linked list data structure in Java: unit tests

Here I have the unit tests for the indexed doubly-linked list. It goes like this: ...
2
votes
1answer
56 views

Faster, indexed, heuristic doubly-linked list data structure in Java: benchmark

I have this benchmark program for my indexed linked list. It looks like this: com.github.coderodde.util.benchmark.LinkedListBenchmarkRunner ...
2
votes
1answer
94 views

Faster, indexed, heuristic doubly-linked list data structure in Java: implementation

I have this doubly-linked list data structure that runs all the single-element operations in \$\Theta(\sqrt{n})\$ time (refer to this post and this repository). (See this for benchmarks.) (See this ...
2
votes
1answer
46 views

Linked list - append, insert, print

I am a beginner in C and am learning linked lists. I have made a program to implement a linked list, allowing certain operations on the linked list. There are 3 functions: ...
1
vote
2answers
141 views

SumList Cracking the coding Interview

Sum of 2 numbers, represented with linked lists, where digits are in backward order or forward order. Backward order Example INPUT:(7->1->6) + (5->9->2) = 617+295 OUTPUT: 2->1->9 = ...
3
votes
0answers
79 views

How can I filter and sort LinkedList faster and more effective?I have list of orders that should be processed

I have method that fetches all orders from Database and filtering, sorting that data(I know better to do It by specific query to Database but I dont know how). I have Order entity that has following <...
3
votes
2answers
44 views
1
vote
2answers
186 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
177 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
56 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
36 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
97 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
288 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
40 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
116 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 ...
3
votes
1answer
153 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
65 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 ...
6
votes
4answers
367 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
67 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
317 views

Splitting a list by predicate

I have written a function splitAtPredicate that splits the list at element x satisfying p, ...
2
votes
2answers
67 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
296 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 ...
6
votes
3answers
629 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
139 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
69 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
237 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
20 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. ...
8
votes
2answers
840 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
2k 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 <...
5
votes
2answers
109 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 ...
6
votes
2answers
821 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 ...
7
votes
2answers
1k 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 ...
4
votes
1answer
177 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 '...
6
votes
2answers
403 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. ...
2
votes
2answers
396 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 ...
8
votes
1answer
572 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 ...
6
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
736 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
143 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
129 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
123 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 ...
3
votes
2answers
88 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, ...

1
2 3 4 5
21