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
90 views

Linked list: removing first element

Method 1: ...
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 ...
1
vote
1answer
40 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. ...
2
votes
1answer
52 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
72 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
52 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
53 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
73 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
81 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
247 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
93 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
97 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
119 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
62 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
64 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
125 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
136 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
57 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
84 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
752 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
54 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
89 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
50 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
165 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
91 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
44 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
74 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
86 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
478 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
123 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
190 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 ...
5
votes
3answers
502 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: '...
1
vote
1answer
52 views

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

This is my implementation ...
5
votes
2answers
190 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
103 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
78 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
60 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 ...
2
votes
2answers
74 views

Implementation of a Singularly LinkedList

I'm new to C++ and trying to learn by implementing data structures in it. Is the code below the most efficient way of implementing the data structure in C++? Does it conform to C++ standards, and how ...
4
votes
1answer
43 views

Doubly linked list in Cython

I am implementing a BVH (Bounding volume hierarchy) in Cython and thought of using a doubly linked list to hold reference of the volumes that still need to be split and push new volumes at one end ...
2
votes
1answer
51 views

C++ singly linked list with iterator

I have written a simple singly linked list in C++. I have previously had a data structure in an interview criticised for being too C-like (no iterators and using new/delete) instead of smart pointers. ...
1
vote
1answer
55 views

Insert new middleware at the “right” location

I need to have my logger middlewares (nodes of a linked-list) in the right order so that they complement each other and work as desired. Any known middleware can be inserted anytime but the first and ...
1
vote
1answer
50 views

Reverse a Linked List in place

I am solving some programming challenges for learning Javascript. The challenge I chose is: Given the head of a singly linked list, reverse it in-place. Here is my implementation in JS ...
4
votes
1answer
65 views

Implementing linked list from scratch - Follow up

A follow up for this question: Implementing Linked lists in Python from scratch Node: ...
8
votes
2answers
149 views

Implementing Linked lists in Python from scratch

After finishing my ds and algorithms course I wanted to implement what I've learned through the semester so here is my try for Linked lists, both regular (one way) and double one (two way). code: <...