A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

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
3
votes
3answers
100 views

Generic Singly Linked List in C++

I am currently working on implementing some data structures as a way to learn C++. I'm coming mostly from a Java background so I was hoping to get some feedback regarding this implementation of a ...
1
vote
1answer
45 views

Implement function in doubly linked list

The following is the entire function for implementing a doubly linked list. Can anyone show me if there is a better way to write these functions, especially the ...
1
vote
1answer
45 views

Ruby: Remove middle node from Linked List

Currently, I'm going over the CTCI, I'm working on the problem removing the middle node. I'm using Ruby to go over these problems. I have the following solution. ...
3
votes
2answers
50 views

Sorted insert on a doubly linked list (HackerRank)

I've decided to do a simple linked list question to brush up my Java & CS. This is the solution for Given a reference to the head of a doubly-linked list and an integer, \$data\$ , create a ...
3
votes
1answer
39 views

Linked list where user replace a chosen number in the list with a number chosen by user - how can it be improved?

I'm quite new to C programming so I'm trying to learn the basics. I've made a program that creates a linked list of numbers, then ask user for which number he/she wants to replace and then what number ...
5
votes
1answer
63 views

Pointers to polymorphic classes saved in vector that reference data in a list as source

I have a list called data with strings in it. I have a class String that derives from class Item. A class ...
4
votes
2answers
76 views

Generic circular doubly-linked list v2

I've improved, with help of the answers and comments, the linked list that I posted yesterday. It's been through a lot of changes, and is much more useful and safe now. I documented the linked list ...
6
votes
4answers
589 views

Generic circular doubly linked list

Edit: New version improved with the answers and comments received here: Generic circular doubly-linked list v2 I have written a linked list library that I can use whenever I need a linked list, so ...
5
votes
3answers
512 views

Organizational Tool GUI with Java Swing (and GridBagLayout)

My first 'large' project is to create an organizational tool. Right now, it's pretty basic, but nevertheless functional in terms of the intent of the current release (v0.3.0). My main question is: '...
5
votes
1answer
94 views
7
votes
2answers
2k views

Doubly Linked List in Python

I implemented a doubly linked list in Python. Please tell me what I can do to improve performance, what methods I should add, etc. I gave it the best Big O time perfomance/complexity I could. So, here ...
2
votes
1answer
61 views

Basic LinkedList implementation [closed]

Please bear in mind, I've only started learning c++ this week, and as such, would love topic suggestions for which I should master, to become better at C++. Below, is my code for a singly linkedlist. ...
3
votes
2answers
75 views

Link list working

I wrote this singly linked list and it worked fine,Now can anyone review my code. I want to do some more clean my delete and add function. And some abstraction. ...
0
votes
1answer
54 views

C++ linked list inheriting from node class

    Hello,     I am currently in between semesters at school and am using that time to improve on my knowledge of C++ classes by making a node class and a ...
3
votes
2answers
57 views

Barebones but Sequence compliant Singly Linked List

I haven't written a linked list from scratch in a couple years, so I decided to take a stab at it again. After working on it on and off for a little over a week, I'm finally happy with it. It ...
3
votes
1answer
78 views

Linked List implementation in python 3.x

I took this as a challenge and implemented linked list data structure in python ...
2
votes
1answer
89 views

Tic-Tac-Toe with changeable board size (Part 2)

Part 1: Tic-Tac-Toe with changeable board size (Part 1) I just revisited all my previous questions and saw that I hadn't updated my Tic-Tac-Toe code. So, I improvised my code as per @Austin Hastings ...
9
votes
1answer
253 views

Simplified Linked List Implementation in C++

I'm learning C++, data structures and algorithms and I have implemented a (Doubly) Linked List class for practice. Some STL functionalities are deliberately missing for now (e.g. some functions ...
2
votes
1answer
112 views

Multi-threaded LinkedList Implementation

I am learning to write a multi-threaded linked list class implementation with basic functionality such as push to front or back, ...
1
vote
3answers
98 views

Populating Lists with harcoded data

I have a class MassiveDTO that contains lists. At some point in the project, I need to generate an object of this class, that will contain some hardcoded data. I ...
5
votes
1answer
124 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 ...
6
votes
1answer
65 views

Doubly Linked List using Stack in c++

Just started learning/relearning data structures for the semester exams. Most of the examples found online are too cluttered or bloated. For myself, I implemented it from theory I learned. It works....
3
votes
1answer
68 views

A singly linked list implementation in C

How is this Implementation of a list in C? Please tell me whether it is good or please mention any problems. It is a singly linked List and I tried to do it recursively. ...
2
votes
2answers
127 views

Brute-force ID reversal search

EDIT The random number generator in this code is a blackbox for a similar algorithm that isn't publishable for privacy concern. The algorithm works in similar way, in that it takes in a seed value ...
5
votes
1answer
153 views

Singly linked list implementation in python 3

I have implemented a Singly linked list. It works well. But if you think something needs to be improved, say it. This code was tested in Python 3.7.4. ...
2
votes
1answer
59 views

A simple priority queue in Java via linked list sorted by priority keys

Now I have this very simple priority queue. add and changePriority both run in \$\mathcal{O}(n)\$ and ...
1
vote
1answer
85 views

Flatten binary tree to linked list

I'm trying to flatten a binary tree into a linked list. I have a working, correct solution: ...
10
votes
2answers
757 views

C - Learning Linked Lists, Pointer Manipulation - Store some ints, print and free memory

I'm learning C, and wrote this program outside of my assignments in order to practice pointer manipulation and data structures, step by step. I want to ensure that this program follows well known ...
2
votes
1answer
62 views

Remove duplicates from an unsorted Linked List in Ruby

Currently I'm going over the cracking the coding interview. I'm in the Linked List 2.1 question which is as follow: Remove Duplicates, write code to remove duplicates from an unsorted Linked List....
4
votes
1answer
90 views

LeetCode: Merge k sorted lists C#

https://leetcode.com/problems/merge-k-sorted-lists/ Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. ...
6
votes
2answers
2k views

Stack using a Linked List

I thought implementing a stack using a linked list was a good option since an array implementation involves reallocation of array size and so on. I have implemented basic ...
2
votes
1answer
51 views

Circular Doubly Linked List with generators

I didn't find an implementation on CR of the circular doubly linked list, using generators. Hence, I tried it myself. Description The class Deck represents a ...
8
votes
2answers
167 views

Doubly-linked-list implementation in C++

I am fairly new to C++ and have been trying to make a doubly-linked-list class that imitates std::list (though not all of it). I'd appreciate if someone can look at my code and let me know if I have ...
10
votes
2answers
1k views

IList<T> implementation

I was wondering about the possibility to create an implementation of IList<T> that is faster than List<T> using C#, ...
3
votes
1answer
55 views

Singular linked list check and assistance

I've been working on writing data structures and methods from scratch (with minimal reference) and I'm looking for assistance on my coding style/if there's any way to optimize the methods I've ...
0
votes
1answer
96 views

Create custom Queue class with O(1) Enqueue and O(1) Dequeue [closed]

I am implementing a Queue class in C# using a Node/LinkedList class that I also implemented, and I wonder if there is a way to implement the enqueue and the dequeue methods, both in algorithmic ...
0
votes
1answer
45 views

C++ Linked List Template Implementation, Howto Default Compare Function, and Split?

To better learn templates, I have dabbled with a simple linked list implementing the class with a private member compare function (cmp) that is used when adding ...
11
votes
5answers
2k views

Find most “academic” implementation of doubly linked list

Recently, a company has asked me to make an implementation of a doubly linked list with unity tests to test my skills. In the task description they specified that the solution should be as academic as ...
3
votes
1answer
81 views

Convert a Binary Tree to Doubly Linked List

Challenge Link on geeksforgeeks: Binary Tree to DLL Given a Binary Tree (BT), convert it to a Doubly Linked List(DLL) In-Place. The left and right pointers in nodes are to be used as previous ...
3
votes
2answers
88 views

LinkedList using Node Class in C++

I implemented Linked List data structure in C++ for practice purpose. The LinkedList.h uses Node.h as nodes. Creates and insert ...
7
votes
4answers
481 views

Rotate List by K places

I am trying to solve the question at :https://leetcode.com/problems/rotate-list/ Question: Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1:...
3
votes
1answer
160 views

LeetCode #37: Sudoku as Exact Cover Problem solved using Dancing Links

Introduction I provide a regular 9x9 Sudoku solver, reducing the puzzle to an Exact Cover Problem. The algorithm used is Knuth'...
3
votes
1answer
206 views

LinkedList Swift Implementation

Linked List Implementation in Swift Swift 5.0, Xcode 10.3 I have written an implementation for a doubly linked list in Swift. As well, I decided to make the node class private and thus hidden to the ...
1
vote
1answer
52 views

Remove Duplicates From Linked List In Place - Java [closed]

This is my implementation ...
5
votes
2answers
194 views

LeetCode: Linked List Cycle

Challenge https://leetcode.com/explore/interview/card/top-interview-questions-easy/93/linked-list/773/ Given a linked list, determine if it has a cycle in it. To represent a cycle in the ...
3
votes
0answers
105 views

Efficient way to fill 2D matrices by rows in a list using R

I have a list of 2D matrices. Each matrix is filled using the function “fillMatrices”. This function adds a number of individuals to each day 0 in a matrix and updates the columns “a_M”, “b_M” and “...
4
votes
1answer
1k views

Linked list implementation of binary heap insertion

Is this a correct linked list implementation of binary heap insertion? This is not a homework exercise. ...
4
votes
3answers
9k views

Circular Singly Linked List using Java

Please review my implementation of a Circular Singly Linked List. ...
2
votes
2answers
83 views

Logger adapter with a configurable chain of responsibility of middlewares

I use my own logger adapter that collects data into a dictionary: public class Log : Dictionary<string, object> { } This is really all I have. I then pass ...
3
votes
0answers
69 views

Circular doubly linked list implementation in Cython

This is a follow-up from my previous question. In summary, I am trying to implement a BVH module with Cython and need a way to keep track of the volumes during the construction of the hierarchy. I ...