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

learn more… | top users | synonyms

4
votes
3answers
14 views

C++ Stack using template

I'm learning C++, so I wrote a stack with the help of templates. I'm wondering if there is anything I can improve or if I did something vastly wrong. Stack.h ...
3
votes
1answer
45 views

Scissors: A fluent API for manipulating lists using the familiar copy-cut-and-paste

What I've hastily named the Scissors API brings the cut-copy-paste paradigm made popular by word processors to the realm of list processing. The Scissors API is fluent, provides methods to manipulate ...
4
votes
1answer
41 views

Sorting a linked list using mergesort

This sorts a linked list using mergegort. Can you please critique my code and provide your thoughts on where I should improve my code? ...
1
vote
0answers
33 views

Lock-free ordered singly linked-list behaves unpredictably [closed]

I wrote an algorithm for lock-free singly ordered list, that uses only one pointer mark to function - kind of novelty. However it behaves strangely, that is under more pressure > 20 threads it breaks, ...
3
votes
1answer
95 views

Templated Singly-Linked List

I'm really new to C++ (very surprised at the leap from Python and others to C++!). The code compiles and works well. This took all day to get to work, and I've the tendency to move on after I get ...
-1
votes
1answer
117 views

C++ linked list with too many pointers

Can someone tell me how I can improve this code? It works ok, but I feel that I'm using too many pointers. ...
4
votes
0answers
50 views

Swap items of a linked list in pairs - revision 5

Here is the source of the question. Given a singly linked list, swap the list items in pairs (reconnect the pointers, not simply swap the values). For example: Before: A->B->C->D ...
3
votes
1answer
70 views

Bottom up mergesort - singly linked list

I have written the following program in Go to mergesort a singly linked list. It does bottom up merge sort and hence does not have to find the mid of the linked list. Please review the algorithm and ...
2
votes
1answer
87 views

Lockable linked list

The existing design of class DList and DListNode is taken. The main criteria is to do successive updates in \$O(1)\$ time. Part ...
1
vote
1answer
58 views

Swap items of a linked list in pairs - revision 4

Here is the source of the question. The solution on GitHub. Revision 1. Revision 2. Revision 3. @200_success' suggestions from revision 3: The iterator's ...
3
votes
3answers
80 views

Linked list implementation - follow-up

Follow-up to this question as recommended. Can this code be improved from an OOP paradigm perspective? ...
1
vote
1answer
70 views

OOP paradigm implementation of a linked list

Can this code be improved from an OOP paradigm perspective? ...
3
votes
2answers
264 views

Finding the kth to last element of a singly linked list

I'm not sure if this code is industry-standard or not. Please review it and let me know if any improvement is required. ...
2
votes
1answer
31 views

Swap items of a linked list in pairs - revision 3

Here is the source of the question. Revision 1. Revision 2. When I started the second round of code review, I wanted to make sure that I had included all the possible input types. However, I ...
3
votes
1answer
65 views

Swap items of a linked list in pairs - revision 2

The first revision is available here and the code is available on GitHub. I modified the method reversePairs and added mSize to ...
2
votes
1answer
46 views

First Graph Adjacency List

First time implementing a adjacency list. Is the use of exceptions correct? If anyone could test/read the code and give some advice on improvments I would appreciate it. ...
2
votes
2answers
34 views

Linked list abstraction using python arrays

Building linked list abstraction using class 'list' data model. ...
5
votes
1answer
53 views

Stack implementation using linked list in C++

I'd like some feedback for the code I wrote. I haven't programmed in C++ for two years. ...
2
votes
2answers
45 views

ADT Stack with a doubly circular linked list

I have managed to implement an ADTStack with a circular doubly linked list. I would like to know whether there are things I could have done better or, I should ...
6
votes
2answers
197 views

Stack implementation with a linked list

Could anyone provide any constructive criticism? I'm trying to get a jump on data structures before classes start. One thing is that I should add a copy constructor and assignment operator. Changes ...
1
vote
1answer
23 views

ADTQueue with circular doubly linked list

I have written these codes and in trying out the code in my main method, it looks like I am on the right way, but which disturbs me is the fact, that whenever I say: ...
4
votes
2answers
44 views

ADT Stack with LinkedList

I am currently preparing for my exam and I am trying to implement some abstract data types with linked lists as preparation for the exam. I found an older exam from my prof. and he wants us to ...
2
votes
1answer
134 views

Swap items of a linked list in pairs

Here is the source of the question: GitHub Given a singly linked list, swap the list items in pairs (reconnect the pointers, not simply swap the values). For example: Before: A->B->C->D ...
0
votes
1answer
46 views

Implementing find middle element of singly linked list without using 2 pointers

There is a solution floating around about using 2 pointers. But I decide to keep the implementation much simpler by using basic constructs that works use to build basic methods of a singly list list ...
6
votes
2answers
91 views

Singly linked list with generics and comparable data - corrected code

I am currently reading about the thread-safe implementation of a linked list. I would like someone to point out some mistakes that will create issues if I try to make it thread-safe in the future. ...
5
votes
2answers
63 views

Given a linked list of line segments, remove collinear points in the middle

This code removes any middle point find in line. It works only in x and y axis. This problem is a Java implementation of this. ...
11
votes
2answers
68 views

Unit testing with a singly linked list

To hone my skills with C++11, I'm implementing a singly-linked list based on the requirements I found at this link. I've implemented code that supports the following subset of requirements from the ...
8
votes
3answers
253 views

Generic stack in C

I tried to implement a generic stack in C using void pointers and tried to keep it as simple as possible by delegating all responsibility to the caller of the ...
3
votes
1answer
207 views

Inserting a node at a specific position in a linked list

Given a node class like class Node { int data; Node next; } Provide an implementation to Insert a node at a specific position in a linked list ...
2
votes
1answer
72 views

LRU cache design using dict and doubly linked list

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the value (will always be positive) of the ...
3
votes
2answers
56 views

Linked list insertion

I have written the code below for inserting an element at the position specified by the user. I have seen the code in multiple books, and they have always used two pointers in the function that ...
5
votes
4answers
215 views

Implementation of C linked list (Queue) of C strings on mega AVR

I have been working on a mechanism to queue up strings coming into a system via a USART and have implemented it as a singly linked list. I have done my best to profile the code and its memory usage at ...
8
votes
1answer
50 views

Recursively pop the last node from a singly linked list

I am exploring different ways of implementing a linked list in Rust as a learning project. In one particular place, I've got some code that works properly, but it makes multiple calls to unwrap--I am ...
-1
votes
1answer
60 views

Singly linked list with generics and comparable data [closed]

I am currently reading about the thread-safe implementation of a linked list. Although I implemented this linked list while keeping in mind the issues from the first code review (Binary Tree). I would ...
4
votes
1answer
62 views

Creating a linked list of strings

Warning: I'm quite new to low-level programming and memory management so please don't mind it when I'm asking incredibly stupid things. I'm working on a project where I need to read all the lines ...
3
votes
1answer
41 views

Ordered doubly-linked lock-free list

I'm implementing a lock-free ordered doubly-linked list based on heavily modified paper entitled Split-Ordered Lists: Lock-Free Extensible Hash Tables by ORI SHALEV. My main concern is correctness of ...
7
votes
1answer
139 views

Searching in a lock-free ordered single-linked list

The code below represents a lock-free ordered single-linked list, and is a modification of the algorithm proposed in this doc. How can I improve speed of searching (lookingup) in the list maintaining ...
3
votes
2answers
79 views

Add two numbers represented by linked lists

I've just encountered this question and am trying to solve it using Java. Here is my solution to it, which may not be optimized or might not be right way to do it. Someone please review whether it is ...
3
votes
2answers
61 views

Find kth element from tail of singly linked list in one pass

I have tried the below program to find (Kth element from tail) of a singly linked list. I have tried to utilize the length field which I am incrementing whenever an item is added into the list or vice ...
8
votes
2answers
401 views

Sum two linked lists

Write code to sum two numbers represented by a linked list. The digits in this linked list are in reverse order. eg. (9->2->3) + (4->8->2) = (3->1->6) Any comments on my solution (especially ...
2
votes
1answer
83 views

Populate the list based on which datacenter code is running on

This is a follow on to : Efficiently detect datacenter based on server hostname and return the full path. I have a library which is running in different datacenters in production. I have three ...
3
votes
1answer
68 views

Making a copy constructor more flexible for ADT queue

I have constructed a copy constructor for an ADT queue. The copy constructor works fine. I would want to improve my code, but I don't really know how to shorten it to make it more flexible. ...
5
votes
1answer
85 views

Single LinkedList using smart pointers

In order to learn C++11, I propose to myself implement a simple single linked list using smart pointers. The idea was to cover the basic operations without leave any memory leak. I came up with a ...
2
votes
1answer
42 views

Linked List Operations in C Read Proof

I am trying to write up all the linked list basic operations (push, pop, add_at_end, pop_from_end, add_at_index, pop_from_index). This is not a school assignment, even though it may look like one. I ...
5
votes
2answers
624 views

Recursively insert a node in an ordered Linked List

I've written this and it works great. Is there any shorter or simpler way to achieve the same result without distinguish between cases? ...
2
votes
1answer
74 views

Doubly Linked List implementation

At university we shortly started using C. I thought it would be a good exercise for almost everything that has to do with basic C to do a doubly linked list implementation. I tried to do it from ...
2
votes
2answers
99 views

Better method structure for insertion in doubly linked list

Here is my insertion method for a doubly linked list. It works, but passing two parameters for the method seems cumbersome. Can anyone suggest a cleaner approach than this? ...
4
votes
2answers
189 views

Implementing a Singly Linked List

I am implementing, in my SinglyLinkedList class, an interface where I redefined linked list. I am trying to learn data structures. Please, let me know what I can ...
4
votes
1answer
128 views

Simple stack and linked list

I know that Python has a built-in list data structure, but I want to implement my own linked list and stack data structures for practice. I have three classes ...
2
votes
1answer
219 views

Priority Queue Linked List Implementation

I am new to Python and wanted to make sure my code answers the question for my assignment due. My Task: A priority queue is a queue in which each item is assigned a priority and items with a ...