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
5
votes
1answer
494 views

Hashtable implementation in C for generic values

I am trying to implement a hashtable that supports character keys and can return any type of value contained in a struct as long as it contains as long as it contains ...
1
vote
1answer
209 views

Merge k Sorted Lists

The task is taken from LeetCode Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: ...
2
votes
0answers
115 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, ...
5
votes
1answer
900 views

C++ Implementation of Linked List

I have been trying to teach myself C++ recently and would like to have some general feedback and comments on how to improve my code so far. Furthermore, since I am more experienced with other (garbage-...
3
votes
1answer
203 views

Double Linked List

Note: Not a native English speaker. I have attempted to make a class similar to vectors in c++ (Though, I now know that it's just a (doubly) linked list). Just wanna know, how good or efficient my ...
5
votes
2answers
129 views

Simple linked list with two iterators

As part of the practice, I created minimalist linked list named SimpleList which can be iterated in two different ways: one element after another or by every second ...
4
votes
0answers
101 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 ...
2
votes
1answer
53 views

Singly-linked queue in PHP 7 #2

I have improved this post to the code below. As always, any critique is much appreciated! ...
3
votes
1answer
37 views

Singly-linked queue in PHP 7

I am learning PHP 7 and decided to implement a simple FIFO singly-linked queue in it: ...
5
votes
2answers
398 views

Linked List In Rust

I am still learning Rust and I think I have a long way to go. This question is from exercism.io. I am posting here to get some more reviews and suggestions to improve my code. Linked list aren't a ...
1
vote
0answers
50 views

Linked list delete a node with a particular value [closed]

I am trying to search a single linked list with a particular value and delete it. Only the first occurrence of the value. ...
2
votes
2answers
163 views

Leetcode: Flatten binary tree to linked list C#

https://leetcode.com/problems/flatten-binary-tree-to-linked-list/ Please comment on performance Given a binary tree, flatten it to a linked list in-place. For example, given the following ...
3
votes
1answer
154 views

Adding two numbers represented as linked lists

I have some imminent interviews and want to sharpen my game before going into them. I'm running through some practice problems. This LeetCode challenge is to add two numbers represented as linked ...
5
votes
2answers
154 views

First C program: records keyboard/mouse and simulates the recording afterwards

This is my first program ever made in C. Before that I programmed just a little bit in C++ (didn't touch OOP so I did only structural programming). This is my second "project" ever made, the first "...
3
votes
1answer
89 views

(Ruby version) Rotate linked list to the right by k places

I saw this question (javascript - rotate linked list to the right by k places) the other day and I tried implementing it in Ruby in a totally different way. Here's the code (I also created a REPL if ...
3
votes
3answers
483 views

Rotate a linked list to the right by k places

The task Given a linked list and a positive integer k, rotate the list to the right by k places. For example, given the linked list 7 -> 7 -> 3 -> 5 and k = 2, it should become 3 -> 5 -> 7 ...
2
votes
1answer
122 views

Graph implementation using FIFO lists

I've made a little implementation of an undirected graph, using FIFO lists, for one of my homeworks. Never really knew how to write a proper FIFO data structure, so I would be glad to see some opinion ...
1
vote
0answers
57 views

TLE error: Remove element from LinkedList [closed]

I am working on an easy LinkedList basic operation problem on Remove Linked List Elements - LeetCode Remove Linked List Elements Remove all elements from a linked list of integers that ...
1
vote
0answers
898 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 ...
6
votes
1answer
146 views

Single-Linked List in C - beginner

I'm a python dev by day trying to learn C. This is a simple implementation of a singly linked list. As a noob I would like comments on style and C conventions as well as functional remarks on memory ...
2
votes
1answer
464 views

Linked list implementation along with unit test - Round 3

Here are the changes I've made thanks to suggestions made by @vnp, and @Henrik Hansen. Here is the link to the previous code review: Linked list implementation along with unit test - Round 2 I've ...
2
votes
1answer
1k views

Generic Macro Generated Linked List in C

Generate a linked list of any type using macros. The linked list contains functions for adding and removing elements to both ends and also at the middle. You can also add elements relatively to a list ...
4
votes
3answers
170 views

Linked list implementation C++

I hope this is the right way of doing things: I've previously posted a request for a code review and gotten feedback. Now I have new improved code that I would like a code review on again. Old: C++ ...
4
votes
2answers
203 views

Linked list implementation along with unit test - Round 2

Here is the link to the next round of code review: Linked list implementation along with unit test [Round 3] Here's the link to the previous code review: Linked list implementation along with unit ...
2
votes
1answer
78 views

Removing node from a linked list

I'm implementing the singly linked list data structure and functions to work with it. In particular I'm concerned about prepending and removing nodes. Currently I defined linked list as follows: <...
8
votes
1answer
2k views

Linked list implementation along with unit test

I've already made all the changes suggested here. Here is the link for round 2: Linked list implementation along with unit test [Round 2] I want to see how other people think of my code, so here it ...
5
votes
2answers
1k views

C++ linked list iterator implementation

I'm a first year computer engineering student and would appreciate feedback on some code. I've created a linked-list with an iterator to be able to range for loops like: ...
4
votes
1answer
75 views

LinkedList Implementation

I have created a LinkedList in Ruby and was wondering if anyone had any input on efficiencies that I could add or deficiencies I could remove. ...
2
votes
2answers
259 views

Generic Singly-Linked List implementation

I'm looking for some feedback regarding my implementation of a generic singly-linked list in C#. I'm also looking for some tips on how to implement other techniques such as using ...
1
vote
0answers
36 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 ...
3
votes
1answer
67 views

Implement LinkedList class in python

I am currently study the basic data structure and trying to implement everything as I go. can anyone give me some feedback about class LinkedList how to make the code more elegant. any review are ...
3
votes
3answers
138 views

Linked List Interview Code methods, runtime, and edge cases refactored

In my previous post I had a number of steps given to me from the accepted answer on how I can write more production ready code. In this post I want this code to be reviewed as near production code I'd ...
3
votes
1answer
802 views

(Codewars) Linked Lists - Remove Duplicates

Kata: https://www.codewars.com/kata/linked-lists-remove-duplicates/train/python Description Write a RemoveDuplicates() function which takes a list sorted in increasing order and deletes any ...
1
vote
1answer
365 views

Linked List Interview Code methods, runtime, and edge cases

Refactored code here I want to write a very simple Linked List with only 3 methods Append, Remove and Print. This is not for production and is to be treated as code that could be used in an interview ...
1
vote
0answers
62 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 ...
1
vote
1answer
33 views

(Codewars) Linked Lists-Sorted Insert (2)

Original Question. So I rewrote the code for the problem described in the original question, but someone had already answered that question, and my rewrite would have invalidated their answer, so I ...
6
votes
1answer
652 views

(Codewars) Linked Lists-Sorted Insert

Kata: https://www.codewars.com/kata/linked-lists-sorted-insert Description Write a SortedInsert() function which inserts a node into the correct location of a pre-sorted linked list which is ...
5
votes
2answers
95 views

Stack template using linked list

I'm working on a stack implementation using a linked list, but I have a strong feeling that I overcomplicated my solution. I would appreciate it if you review this code and give me any suggestions on ...
3
votes
0answers
180 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 ...
4
votes
3answers
539 views

LRU implementation in C++ using a LinkedList

Explanation : I am adding new elements in the list until the window runs out. Head will have the earliest element and tail will have the most recent element. Once the window is over, every addition ...
1
vote
2answers
87 views

A LinkedList implementation in Python

...
0
votes
2answers
226 views

Leetcode: Merging 2 sorted lists

https://leetcode.com/problems/merge-two-sorted-lists/ Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. ...
1
vote
1answer
57 views

Simple text-based inventory manipulator

I was bored so I crapped out a simple game that responds to commands and manipulates an inventory. I am interested in other possible ways to handle the inventory, and I think I went overboard with ...
4
votes
3answers
227 views

Linked List written in C

I have been learning data structures and dynamic memory allocation in C. As a learning experience, I have written this linked list implementation. I really appreciate the feedback I've received on the ...
9
votes
1answer
651 views

Simple LinkedList

I guess this has been made a couple of times by now, but i wanted to take my chance on creating a simple generic linked list in c#. What do you think ? This is the main class. ...
5
votes
2answers
308 views

Stack implementation in C++ using linked list

I am learning C++ and I made a simple stack class using a (reversed) linked-list to test my knowledge. Are there any problems with the following code, or any suggestions to improve it? I want to ...
0
votes
1answer
113 views

Linked list in Python

Below is my attempt at a doubly-linked list in Python (3): ...
3
votes
2answers
568 views

Singly Linked List Implementation in ES6

This is my Singly Linked List implementation in ES6. ...
2
votes
1answer
2k views

Implementation of linked list in C++ using class

I created a linked list in C++ using class with few methods to provide interface for it. Methods are pushFront(), traverse() ...
4
votes
0answers
520 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: ...

1 2 3
4
5
21