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.
1,071
questions
3
votes
1
answer
93
views
std::list reimplementation for practice
I used cppreference list to implement this simplified std::list.
The CXX_STANDARD is 11.
My questions are the usual:
Is the ...
0
votes
2
answers
119
views
Printing the elements of a linked list [closed]
An absolute beginner here who is practising linked list problems in hackerrank. Stumbled upon this question which is categorised as easy.
Given a pointer to the head node of the linked list, print ...
6
votes
3
answers
186
views
Unit testing a Linked List implementation in C++
Recently I wanted to use the gtest library to unit test my program but for some reason, it's incredibly hard to make it work and configure (at least for me it was), ...
1
vote
1
answer
55
views
Revised C Doubly-Linked List
I have revised the implementation I originally posted here. Thank you all who responded; I took your comments to heart. Please let me know if you have any additional feedback.
Here are some notes to ...
5
votes
4
answers
1k
views
Simple C Doubly-Linked List
Here is some code I've written. I am welcoming any critiques, whether it is style/formatting, correctness (I believe it is correct) -- I would appreciate any advice on formatting unit tests, and any ...
3
votes
1
answer
113
views
Doubly-linked list functions
This is my first time implementing a doubly-linked list. I would like some feedback on my code. Any comment would be appreciated regarding the quality of the code, bad implementation, memory ...
3
votes
2
answers
463
views
Generic Doubly-Linked-Lists C implementation
I'm trying to build step by step a C library that will include some of the major Data Structures such as Linked Lists, Stacks, Binary Trees etc., mostly in order to practice my C programming skills ...
5
votes
3
answers
797
views
Dynamic C Linked List Implementation
I've started to experiment with (void *) in C, in order to work with Dynamic Data Types, that is, to surpass the need to pass specific type of data.
I have implemented this doubly linked list in C and ...
3
votes
2
answers
2k
views
Detecting Intersections of a Collection of Singly-Linked Lists
I was recently presented with the following problem...
You are given a collection of singly-linked lists (SLLs).
Return true if any of them share a common node (or “intersect”), or false otherwise.
...
0
votes
1
answer
61
views
Doubly Linked List of integers
I wrote a working linked list program in C. What can I improve in my code in your opinion? The first thing I think about is doing unit tests. I want to learn TDD. I'm not sure if it is a good idea to ...
2
votes
1
answer
97
views
A singly linked list implementation
Here's yet another implementation of a singly linked list. You may base your review on the following questions:
Review goals:
Is the API well thought of?
Does this design include undefined behavior, ...
2
votes
2
answers
126
views
Reversing in between a linked list
I have written code for this leetcode problem :-
Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to ...
1
vote
4
answers
335
views
Queue using doubly linked list
I have implemented my queue based on doubly linked list. The codes is tested and works, however, I am interested in some improvement ideas, thanks
Based on some review remarks on my previous ...
0
votes
4
answers
341
views
Stack using doubly linked list
I have implemented my stack based on a doubly linked list. The code is tested and works; however, I am interested in any improvement ideas.
...
4
votes
4
answers
1k
views
Doubly linked list optimally defined over 17 operations in C [4]?
Previous versions of this question
First Version
Second Version
Third Version
Fourth Version
Changes
I built upon the previous singly linked list and implemented a doubly linked one.
You are not ...
0
votes
0
answers
48
views
singly linked list optimally defined over 17 operations in C [3]?
Previous versions of this question
First Version
Second Version
Third Version
Changes
I took into consideration previous remarks, I will leave the design remarks for later.
You are not allowed to <...
2
votes
2
answers
225
views
singly linked list optimally defined over 17 operations in C [2]?
Previous versions of this question
First Version
Second Version
Changes
I added these operations:
Pop_back
Pop_front
You are not allowed to insert_sll at the ...
3
votes
2
answers
364
views
singly linked list optimally defined over operations in C?
I have implemented my singly linked list in C and I tried to do it with the most efficient code as possible. Is there any place for improvement?
This post is the second version.
First version of this ...
3
votes
1
answer
167
views
Singly linked list optimized for search & insert in O(1)
I have tried to implement my singly linked list to be optimal in the sense that when inserting I don't have to search for the tail and then chain the new node to it, I just keep track of the tail and ...
0
votes
0
answers
105
views
An extended simple, funny, easy linked stack of lists in Java
This post is the continuation of A simple, funny, easy linked stack of lists in Java.
What's new:
Now I have varargs for pushing/linking multiple values per call.
Provided the unit tests.
...
0
votes
0
answers
57
views
A simple, funny, easy linked stack of lists in Java
(See also the next iteration.)
(This data structure can be implemented as Deque<List<T>>, yet I decided to have some better time with it. :-))
...
6
votes
1
answer
221
views
Doubly linked list first fit free list malloc/free in Python
As an exercise I've implemented malloc and free in Python as a first fit free list as described here. This tracks which blocks are free in a doubly linked list that is sorted by the address of the ...
8
votes
1
answer
549
views
C void* Generic Linked List
I once tried to make a generic linked list in pure C (no external libraries, only the C standard library) here using C macros. With the same restrictions as in the previous attempt, this time I'm ...
4
votes
2
answers
127
views
Max Stack implementation in C++ involving iterators
The tricky thing was keeping copies of list iterators in a tree map and managing both together. I'm not handling invalid input cases (like popping an empty stack) in this code. I am following Google C+...
5
votes
2
answers
217
views
C Macro Generic Linked List
For a recent project of mine I had to create various data structures in pure C with no external libraries (in other words, code I've written by myself), which lacks the templating and OOP capabilities ...
1
vote
2
answers
98
views
Circular list vs. doubly-linked list: which is faster?
In this post, I will compare performance of a circular list and a conventional list with head/tail -references:
...
2
votes
1
answer
88
views
Linked list in rust, Needed optimization
I've implemented constructor, push , pop, drop and some macro.
I need to know if the drop implementation is correct and is drop is really necessary?
Meanwhile I still didn't check about ...
2
votes
2
answers
317
views
Inserting into a Sorted Doubly Linked List
Edited: incorporated some feedback and added a lot of features
I've written a basic Doubly Linked List Class where every insertion into the class should be sorted into ascending order. The project ...
2
votes
1
answer
154
views
Middle of the Linked List in Rust
Yesterday, inspired by some great questions here, I decided to give myself some practice with Rust, by solving all the introductory questions over on LeetCode. It was a great learning exercise, and ...
1
vote
2
answers
124
views
Insert node at beginning of LinkedList
My professor required we make a LinkedList class with a bool add(in newEntry) method.
Two things I'm questioning my choices on ...
10
votes
7
answers
2k
views
Unidirectional linked list in C
I'm learning algorithms and I wrote the single-directional linked list implementation in C. I need a code review of what can I improve in my code and I want to make sure there are no possible memory ...
2
votes
1
answer
108
views
Linked List implemented in C++
I have a linked list code in C++:
...
9
votes
1
answer
741
views
Intrusive linked list in C
I've been working on an intrusive linked list for the past few days for a personal project and I would like to have some feedback on it. :)
Personally, I would have preferred to make ...
4
votes
1
answer
360
views
Simple slab allocator in C
Here is the plan:
a slab takes up 1 page and it has PGSIZE / blocksize amount of blocks
the minimum blocksize is 8 bytes, otherwise the pointer to the next block ...
2
votes
3
answers
1k
views
Check if parentheses are balanced using a stack implemented with a linked list
Problem: Stacks can be used to check whether the given expression has balanced symbols. This algorithm is very useful in compilers. Each time the parser reads one character at a time. If the character ...
3
votes
1
answer
106
views
Queue using circular linked list
I'm reading through Algorithms Fourth Edition by Sedgewick and doing some of the practice exercises in C++11 instead of Java. Exercise 1.3.29 is to write a Queue that uses a circular linked list, ...
5
votes
1
answer
135
views
basic singly-linked list in rust
I'm new to rust and tried to implement a singly-linked list as exercise.
Is this code so far suitable to solve the problem? What elements of the language should I consider to make the code more ...
2
votes
1
answer
121
views
Advice for optimization of a custom doubly Linked List class
This is my custom implementation of a double Linked list. Code is apparently working fine. Need advices on improvement and/or optimization. This is a tiny academic side-project. I am still pretty ...
5
votes
2
answers
100
views
Basic Linked List C implementation
I've written a singly-linked list of characters. This is my 3rd C program and I'd like some feedback on what I can improve on in any aspect whatsoever.
If you'd prefer to look at the repo directly it'...
6
votes
2
answers
165
views
(Rev. 2) Type-generic queue implementation using singly linked lists
Thanks to the extremely helpful comments and answers from the original post, I've improved the interface and implementation of this general-purpose queue library.
Improvements include:
Fixed memory ...
11
votes
4
answers
1k
views
Type-generic queue implementation using singly linked lists
Simple lightweight queue implementation using data size registration and singly linked lists as the underlying type
Update #2
...
6
votes
2
answers
1k
views
Linked List implementation in c++ with all functions
I wrote my implementation to Linked List. And I tried to implement all the functions in the standard library list in CPP! I need a review for it to improve it and improve my coding skill. I also will ...
2
votes
1
answer
67
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.
...
0
votes
1
answer
103
views
LeetCode - LRU Cache by rodde
I have solved this LeetCode problem. Depending (perhaps) on the server load, I once scored the following performance figures:
My code follows:
...
4
votes
1
answer
166
views
Doubly Linked List with forward and reverse iterators (javascript)
A doubly linked list contains elements that include pointers to the previous and next element along with a value. Being able to search and iterate through the list in both directions is an important ...
5
votes
1
answer
384
views
Doubly Linked List Javascript
A doubly linked list contains elements that include pointers to the previous and next element along with a value. This data structure is implemented with methods similar to what you would find in an ...
1
vote
2
answers
210
views
0
votes
1
answer
111
views
Singleton generic implementation of simple LinkedList
I would like to ask if the implementation is ok, and what I can improve.
Although I'm not sure if the Singleton is working properly.
...
0
votes
0
answers
74
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.
...
2
votes
1
answer
102
views
C++ Doubly linked list, including benchmark vs std::list
I wrote a rudimentary implementation of doubly linked list.
Feel free to comment anything!
...