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
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

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.

0
votes
0answers
30 views

Simple Linked List N Insertion [on hold]

Hey guys here is a pretty simple linked list insertion in C++ and I understand most of it, but I had a question. Why does changing markerPointer at the last line effect head which is returned by the ...
6
votes
1answer
123 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
46 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
40 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
96 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
59 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
62 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
118 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
96 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
57 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
74 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
22 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
56 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
115 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
333 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
73 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
33 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
279 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
68 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
50 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
323 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
90 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
36 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
86 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
454 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
128 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
77 views

Linked list in Python

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

Singly Linked List Implementation in ES6

This is my Singly Linked List implementation in ES6. ...
1
vote
1answer
153 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() ...
3
votes
0answers
118 views

Linked-list natural merge sort in Python

I implemented the linked-list natural merge sort in Python, and I refered to this awesome if not poetic gist and this implementation in Go. Here is my code: ...
1
vote
1answer
38 views
4
votes
1answer
105 views

Leetcode MaxStack in Python

My solution to Leetcode MaxStack in python in Python. I have two solution one is using linked-list and another one is using list. Design a max stack that supports push, pop, top, peekMax and popMax....
0
votes
2answers
82 views

Doubly linked list C++ [closed]

To become more familiar with templates I attempted a doubly linked list implementation in C++. Is this a valid use for a template? ...
1
vote
2answers
72 views

Pairwise swap elements of a given linked list by changing links

GeeksForGeeks challenge: Given a singly linked list, write a function to swap nodes pairwise. For example : if the linked list is 1->2->3->4->5->6->7 then the function should change it ...
3
votes
1answer
70 views

Rotate the sub-list of a linked list from position M to N to the right by K places

Given a linked list and two positions m and n. The task is to rotate the sub-list from position ...
2
votes
3answers
89 views

Stable-sorting all even numbers before odd numbers in a linked list

Given a Linked List of integers, write a function to modify the linked list such that all even numbers appear before all the odd numbers in the modified linked list. Also, keep the order of even ...
1
vote
1answer
73 views

Generic Linked List (header-only and non-intrusive)

Although I should know better, I wrote my own linked list implementation in C. My goal was to make it a true generic collection, with no need to modify the structure being listed. I only ...
5
votes
3answers
78 views

Closed linked-list which uses sentinels to avoid passing itself

This is a typical C implementation of a (doubly) linked-list. I want to avoid passing the element and the list itself to functions which operate on and possibly ...
1
vote
1answer
50 views

My own expandable list in Python

I have written my own expendable list in Java. LinkedList in Java Now I tried to write that thing in Python. Did I have used the elements of the python language properly? ...
2
votes
2answers
104 views

My own expandable list

I wondered how an expandable list could be implemented. My first thought: You could create a class that has an array and you can create a new array each time the user wants to append an element and ...
0
votes
2answers
47 views

Merging K Sorted Linked Lists

Specifically, how can I improve the time complexity of my algorithm (currently it is O(listLength * numberOfLists))? It only beats 5% of accepted LeetCode solutions,...
5
votes
3answers
137 views

Singly-linked list data structure implementation

This code seems to work correctly. I would appreciate any comments on how to improve the code, e.g. readability, algorithms, const-correctness, memory, anything else I am forgetting? Also, for the ...
-2
votes
1answer
55 views

Build up two linked list, then build up a 3rd link list with nodes of duplicate data from both [closed]

A friend of mines needed some help. He wanted to build up two linked list and then compared them to see if they had the same data values. Finally a 3rd link list would contain the nodes with ...
3
votes
2answers
66 views

Singly linked list class

I have created this program about using a singly linked list class that implements several functions: Add, Display and ...
0
votes
2answers
57 views

Singly Linked List Implementation (With Nodes)

This code was recommended to me by my dear friend Jon after I wrote an implementation using arrays. With his help, I managed to create a Singly linked List similar to std::vector using Nodes. ...
3
votes
0answers
72 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 ...
3
votes
2answers
111 views

Remove value from linked list if it is equal to a parameter

Problem: Given a singly linked list of integers l and an integer k, remove all elements from list l that have a value equal to k. My solution works, but I suspect it's not smart and optimized ...
1
vote
2answers
107 views

HashMap implementation, is this good enough for interviews?

After understanding HashMaps, I decided to implement my own using 3 classes HashMap, LinkedList, and Node. I knew how to implement LinkedList from before. Can you please give me feedback on this. ...