Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
1answer
80 views

First attempt at making linkedlist in c

I started learning c and wanted to challenge myself by making a linked list. I am stil new to the concept of pointers and pointers to pointers, so there might be something in my code that I could have ...
1
vote
1answer
31 views

Adding elements of 2 linked list in reverse order

I solved a problem with JavaScript which has the following requirements: Two non-empty linked lists representing two non-negative integers. Digits stored in reverse order Each node contains a single ...
2
votes
0answers
8 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 ...
4
votes
1answer
75 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
0answers
34 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
41 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
158 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
72 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
72 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 ...
3
votes
0answers
56 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 ...
1
vote
1answer
38 views

Singly-linked queue in PHP 7 - follow-up

I have improved this post. Now I have this: ...
3
votes
1answer
28 views

Singly-linked queue in PHP 7

I am learning PHP 7 and decided to implement a simple FIFO singly-linked queue in it: ...
4
votes
1answer
68 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
46 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
65 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
44 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
130 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
47 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
78 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
96 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
34 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
37 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
132 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 ...
1
vote
0answers
50 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
81 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
107 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++ ...
3
votes
2answers
61 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
65 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: <...
7
votes
1answer
139 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
110 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
65 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
84 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
23 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
57 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
116 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
353 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
76 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
34 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
25 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
284 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
73 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
56 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
349 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
53 views
0
votes
2answers
101 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
39 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
94 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
461 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
129 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 ...
1
vote
1answer
79 views

Linked list in Python

Below is my attempt at a doubly-linked list in Python (3): ...