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.

44 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
88 views

Optimally splitting a text into strings from a set

I am trying to write an algorithm that starts with a corpus of texts (e.g., a Wikipedia dump). It first builds an array of individual characters (e.g., "a", ...
user avatar
  • 151
4 votes
0 answers
238 views

Circular doubly linked list implementation in Cython

This is a follow-up from my previous question. In summary, I am trying to implement a BVH module with Cython and need a way to keep track of the volumes during the construction of the hierarchy. I ...
user avatar
  • 125
4 votes
0 answers
107 views

Sorted LinkedList

A linked list is a data structure that has a beginning, and an end. The only way through the structure is to go to the "next step", like stepping stones. This linked list works the same way, but in ...
user avatar
  • 161
4 votes
0 answers
645 views

Linked-list natural merge sort in Python

I implemented the linked-list natural merge sort in Python, and I referred to this awesome if not poetic gist and this implementation in Go. Here is my code: ...
user avatar
4 votes
0 answers
444 views

Persistent List with constexpr and pointers

I am trying to implement a linked list in C++, functional and persistent. Before looking into sample implementations, I tried to come up with my own as an exercise. I came up with two versions: One ...
user avatar
  • 215
3 votes
0 answers
136 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 <...
user avatar
3 votes
0 answers
113 views

Efficient way to fill 2D matrices by rows in a list using R

I have a list of 2D matrices. Each matrix is filled using the function “fillMatrices”. This function adds a number of individuals to each day 0 in a matrix and updates the columns “a_M”, “b_M” and “...
user avatar
  • 163
3 votes
0 answers
202 views

Doubly linked list in Rust using raw pointers

I am practicing Rust by writing doubly linked list using raw pointers, Box<node> to allocate data on heap, Box::from_raw ...
user avatar
  • 131
3 votes
0 answers
866 views

Linked list with hand-over-hand locking

Follow-up to this question: after reading the comments, I decided to redesign my linked list to have a cursor that only contains one node and implement the interface similar to the one of forward_list ...
user avatar
  • 183
3 votes
0 answers
210 views

Creating a TSP level with a linked list

I am trying to solve the Travelling Salesman Problem. This function creates the first level in the form of a linked list. This is what the levels look like: This is the code that creates it: ...
user avatar
3 votes
0 answers
376 views

Merge two sorted linked lists in C++

Should I be using std::move or copy when passing LNode in the LinkedList constructor instead ...
user avatar
2 votes
0 answers
41 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 ...
user avatar
2 votes
0 answers
147 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: ...
user avatar
  • 645
2 votes
0 answers
49 views

Linkedlist & hashmap _duplicates removal

I have implemented a LinkedList removal fo duplicates class by using HashMap. Looking forward to your reviews. Thanks. ...
user avatar
2 votes
0 answers
23 views

Thread safe Shareable and Splittable Buffer with Safe Memory (Project)

Backstory This is a buffer I wrote for use in multiple personal projects. It is designed to handle pretty much any data in pretty much any way. In particular I intend to use it in such instances as ...
user avatar
2 votes
0 answers
123 views

Faster k-shortest path algorithm in Java

In the \$k\$-shortest path problem, we are searching for (at most) \$k\$ distinct, shortest paths connecting two given terminal nodes. You can see the previous version here. This implementation, ...
user avatar
  • 26k
2 votes
0 answers
111 views

Yet Another Linked List

I've been populating my git with some old code, and I came across this linked list I wrote about 10-12 months ago. I'm wondering just how thread safe it is and if there are any improvements I can make ...
user avatar
  • 129
2 votes
0 answers
42 views

Generalizing work orders

I am working on designing tables for work orders. The problem: There is different work order models (from now on called WOM) The WOMs share some attributes (Num, Date, Description, ... etc) The WOMs ...
user avatar
  • 21
2 votes
0 answers
187 views

Generic Unrolled Linked List with IList<T> interface implementation

I was inspired by the Phillip Trelford "Beyond Lists" presentation published on InfoQ. So, I decided to make it simple, yet still capable to act as IList<T>. ...
user avatar
1 vote
1 answer
31 views

Queue Linked List based implementation in C++

I wrote my implementation to Queue Linked List based. And I need a review for it to improve it and improve my coding skill. I also will put this implementation on my GitHub account. ...
user avatar
1 vote
0 answers
113 views

Implementing a LinkedList in Rust

I have this LinkedList implementation for rust and it isn't quite what I am looking for. Ideally, it would be more like scala's implementation of List and be entirely immutable. This implementation ...
user avatar
1 vote
0 answers
43 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 ...
user avatar
1 vote
0 answers
127 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'...
user avatar
  • 11
1 vote
0 answers
45 views

Implementing Doubly Linked List in Python

My take on Doubly Linked List in Python. Is there a more efficient and compact way to do this? Are there any bugs in my program if so how can i fix it? PS: I'm a beginner in Object Oriented ...
user avatar
  • 1,180
1 vote
0 answers
953 views

Prompting the user to input a data value into an element in a linked list

I'm working through a practice problem that is having me build and modify a linked list over a series of steps. I am particularly interested in knowing if there's a more elegant way of prompting the ...
user avatar
1 vote
0 answers
38 views

The code duplication reducing in the linked list implementation

I am writing the linked list data structure, using this question's requirements (the method set). I have written two working methods, which do the similar thing and differs by only few lines. So, I ...
user avatar
  • 872
1 vote
0 answers
72 views

(Codewars) Linked Lists - Insert Sort

Kata: https://www.codewars.com/kata/linked-lists-insert-sort/train/python Description Write an InsertSort() function which rearranges nodes in a linked list so they are sorted in increasing ...
user avatar
  • 1,796
1 vote
0 answers
161 views

C Generic Sorted Doubly-Linked List

I just finished this big project. Its is called SortedList and it is implemented using a Doubly-Linked List. It data is of type ...
user avatar
  • 347
1 vote
0 answers
121 views

Speeding up a linked list by using fingers in Java

The idea here is to keep a small number of "fingers" that point to linked list nodes. Now, when, say, the client programmer asks for a node in the list, a closest finger is chosen and is shifted to ...
user avatar
  • 26k
1 vote
0 answers
82 views

selecting 5 best players out of 2 team

Let us assume that we need to develop an application which can select best 11 players to score maximum points. The application will select the best players after completion of a match. The rules are ...
user avatar
  • 19
1 vote
0 answers
981 views

Iterator for custom List class

I have extended a custom list class I have been working on with a Iterator class. I have not used std::iterator as a base class as it will be deprecated in C++17. ...
user avatar
  • 405
1 vote
0 answers
198 views

Transfer values from one LinkedList to another

Write a method transferFrom that accepts a second LinkedIntList as a parameter and that moves values from the second list to this list. You are to attach the ...
user avatar
  • 1,935
1 vote
0 answers
211 views

Singly linked list data structure design, implementation and unit testing

Design a singly linked list data structure that supports following operations: size, is_empty, ...
user avatar
  • 19
1 vote
0 answers
763 views

Direct address hash table

Note: I do know that Python libraries provide better solutions. This implementation has been done to practice python, data structures and Algorithms. This is a implementation of Direct-address hash ...
user avatar
  • 293
1 vote
0 answers
588 views

A doubly linked list in C++

I'm a Java developer who's learned Cpp ~5 years ago. I'd appreciate any critique on how to make my code more "C++" like. Essentially what I mean by that is I have no idea how to handle memory properly....
user avatar
  • 205
1 vote
0 answers
141 views

Clone linked structure with random pointer

I've just finished implementing a doubly-linked structure with random pointer and I am trying to see can we do better and would also like to address some lingering questions that I have. Assignment ...
user avatar
  • 121
1 vote
0 answers
2k views

Breadth-First Search in C: Maze-like use of 2D arrays, linked list

Problem: In a grid of nodes pick a starting node(has mode2), and using Breadth-First search, find one with a ending node (has mode1). You can make walls so it's harder for the search. And that ...
user avatar
1 vote
0 answers
317 views

Generic natural merge sort a linked-list in C

I have a .h file that implements my "generic" by defining LINK_* beforehand. This is an implementation of natural merge sort on doubly-linked lists using log n ...
user avatar
  • 1,015
0 votes
0 answers
40 views

JMH benchmark for IndexedLinkedList

I have this data structure, which I benchmarked (link here): ...
user avatar
  • 26k
0 votes
0 answers
20 views

IndexedLinkedList.java - Part 4/4: Other inner classes

I have this indexed, heuristic, succint list data structure that runs all single-element operations in worst-case \$\mathcal{O}(\sqrt{n})\$ time. You can read about it here. Table of Contents: Part 1/...
user avatar
  • 26k
0 votes
0 answers
22 views

IndexedLinkedList.java - Part 3/4: Private methods

I have this indexed, heuristic, succint list data structure that runs all single-element operations in worst-case \$\mathcal{O}(\sqrt{n})\$ time. You can read about it here. Table of Contents: Part 1/...
user avatar
  • 26k
0 votes
0 answers
27 views

IndexedLinkedList.java - Part 2/4: Public methods

I have this indexed, heuristic, succint list data structure that runs all single-element operations in worst-case \$\mathcal{O}(\sqrt{n})\$ time. You can read about it here. Table of Contents: Part 1/...
user avatar
  • 26k
0 votes
0 answers
71 views

IndexedLinkedList.java - Part 1/4: Finger management class

I have this indexed, heuristic, succint list data structure that runs all single-element operations in worst-case \$\mathcal{O}(\sqrt{n})\$ time. You can read about it here. ToC: Part 1/4: this post. ...
user avatar
  • 26k
0 votes
0 answers
80 views

A doubly-linked list supporting full reversals in O(1) time (Java): Part I/II: the list

I have this Java data structure implementing only the very basic methods of the java.util.Deque and java.util.List interfaces. ...
user avatar
  • 26k