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
1answer
52 views

Java Singly-linked List: how to be efficient and clean

this is my first time on StackExchange. I am new to writing code. This is a singly-linked list I made in Java using generics with no sentinel nodes (i.e. no empty head and tail nodes). Looking for ...
2
votes
1answer
41 views

Linked List implementation of FileSystem directories

I am writing wrapper classes in Java which override methods of an existing implementation, in order to handle an edge case. The full implementation is a bit more complex than needs to be posted here, ...
5
votes
3answers
97 views

Doubly linked-list implementation

I come from a C++ background, and I recently got into C, and one of the first things I made was a double linked list since I though it would be good practice for me with pointers and memory allocation....
4
votes
1answer
102 views

Extreme use of pointers in adjacency list graph construction?

Playing around with pointers in C++, implemented an adjacency list graph. Am I going too far/extreme trying to place data onto the heap? graph.h ...
5
votes
1answer
34 views

Double LinkedList Deep Copy in Kotlin with Generics and Thread Safety

Goal Return a deep copy of a double LinkedList. Each node also contains an additional random pointer, potentially to any node or null. Code to start ...
5
votes
1answer
47 views

Dynamic-sized Hash table with Linked List

Below is an implementation heavily based on climberig's implementation on Leetcode for LeetCode 706. Design HashMap. Just to preface, I am doing this in preparation for an exam. The one below is ...
2
votes
0answers
31 views

Async linked list to and from async iterable

I'm working on some stuff that works better with (immutable async) linked lists such as this: ...
4
votes
1answer
120 views

Doubly-linked list with iterators

Writing a double-linked list seemed like a good practice for understanding it. I tried to fix all the errors that were pointed out to me in the last question, as well as add new functionality. In ...
10
votes
1answer
3k views

My first implementation of a linked list in C++

This is my very first implementation of a full-fledged ADT, which could potentially be use-ready. Now, I'm still learning, therefore I would like to ask you what I can do to further improve the ...
4
votes
0answers
391 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: ...
2
votes
0answers
29 views

Linkedlist & hashmap _duplicates removal

I have implemented a LinkedList removal fo duplicates class by using HashMap. Looking forward to your reviews. Thanks. ...
0
votes
1answer
142 views

C++ linked list inheriting from node class

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 linked list class that inherits from the node class. There ...
2
votes
1answer
43 views

Proper way of deallocating memory in SLL?

So I'm making my own singly linked list class, with methods that you'd expect such as remove() and insert(). I don't use ...
6
votes
2answers
686 views

Reversing a doubly linked list in C

Looking for feedback on this code to reverse a double linked list. Things I am potentially looking for but missed -> redundant operations, extra / unnecessary arithmetic, improvement in code style. ...
2
votes
2answers
168 views

Deleting a node in a singly linked list?

Please critique the following code on removing a node from a singly linked list, at the moment it seems to me like the code is quite clunky. ...
2
votes
1answer
130 views

Double LinkedList Deep Copy in Kotlin

Goal Return a deep copy of a double LinkedList. Each node also contains an additional random pointer, potentially to any node or null. Code to start ...
3
votes
2answers
80 views

Singly linked list implementation in c++ (Data Structure)

I just finished writing an implementation of the "singly linked list data structure",and i wanna know if there are some bugs or memory leaks or any bad code to make the code better! i'm so ...
5
votes
1answer
72 views

How to merge two descending singly linkedlist into one ascending linkedlist using Recursion without any helper method?

Here is my solution: I want to know if my solution fits the requirement 100%? Or if there is any better solution? Constraint of the question: must be singly linkedlist must use recursion, and no ...
7
votes
1answer
107 views

Summing digits of a singly linked list

I want to familiarize myself with more data structures. As such I implemented a Node, singly-linked-list, as well as an algorithm to sum the digits of two such lists where each node contains the ...
8
votes
2answers
255 views

C program that reads the description of a deterministic finite automaton and builds it

I just got done coding this C program: Read the description of a deterministic finite automaton from standard input. The first line of input is the number of states in the automaton, n n lines follow,...
2
votes
1answer
35 views

Linked List implementation in Ruby

I was working on Leet code design a Linked List problem. My solution with a @tail pointer, althought it added complexity it made adding to tail O(1), also having a ...
1
vote
0answers
27 views

Delete a linked list using recursion in Python

Given a Singly Linked-List, write a function to delete the linked list recursively. Below is my attempt. I am confused if I should use del keyword to delete the nodes or below method is better. I don'...
9
votes
2answers
920 views

Immutable Linked List in VBA

I made an immutable list class using the head-tail idiom. If I did this correctly, it implements persistent data structures. Unfortunately it doesn't scale well ...
4
votes
0answers
40 views

Binary Search Tree (BST) Implementation

This is the first Time implementing a Binary Search Tree, based on how it works from the visualgo website. I made this algorithm purely based on what I saw, and the remove method was quite challenging....
4
votes
1answer
53 views

Double linked list API design in C

I have created the following few functions for handling the use of doubly linked lists. list.c: ...
1
vote
1answer
35 views

Stack Implementation Using Linked Lists

I have tried Implementing Stacks Using Linked Lists, and would like some tips and tricks regarding optimizations or ways to simplify/compact processes. It has 3 functions, Push, Pop, and Peek (For ...
6
votes
5answers
1k views

Double linked list implementation in C

Please review this doubly linked list in C. It has the basic linked list functions as you would expect plus some algorithms to perform on the list. list.h header file: ...
4
votes
2answers
70 views

C Singly Linked List Implementation

I'm a C Beginner and I am looking for feedback on my implementation of a singly linked list. The code is split between list.c and ...
1
vote
0answers
31 views

Implementing Doubly Linked List in Python

My take on Doubly Linked List in Python. Is there a more efficient and compact way to do this? Are there any bugs in my program if so how can i fix it? PS: I'm a beginner in Object Oriented ...
1
vote
1answer
45 views

Python LinkedList implementation and tests

I'm implementing some basic data structures in Python. How does my LinkedList look like? My experience in testing is quite low and I would really appreciate a review. Implementation: ...
6
votes
1answer
488 views

Recursive LinkedList. Which implementation is better and why?

class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None <...
3
votes
1answer
79 views

Implementing Linked Lists in Python as a beginner

I have been learning linked lists for the past three days. I feel I have implemented a complete linked list. Are there any more things a linked list should do? Please can you review any or all of my ...
2
votes
1answer
142 views

Modern C++ Linked List

I have been using this quarantine time to learn "Modern C++" (constructs, move semantics, smart pointers, etc, etc) via implementing basic data structures from scratch. As a first step, I've put ...
1
vote
2answers
72 views

Find an Element in a Linked List

The find function is designed to start at the given node and return the index of the node with the value valueInput (indices start at 0). Return -1 if valueInput does not exist. How can this code be ...
5
votes
3answers
2k views

Implementation of Stack using Linked List

Please review my code and help me to improve it. I have written this code using template. Can I use more C++11? Is using top in this code is necessary? ...
3
votes
3answers
524 views

Stack implementation using linked-list

typedef struct Stack { char v; int x; int y; struct Stack* next; } Stack; Above is my stack struct. ...
2
votes
0answers
149 views

Implementation of Doubly Linked List with sentinel in C++ trying to replicate the stl std::list [closed]

I am currently trying to replicate the STL std::list interface with my own list implementation (doubly linked list with sentinel) to learn about all the advanced ...
2
votes
1answer
223 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 ...
7
votes
5answers
2k views

Generic linked list implemented in pure C

Recently i added such generic list in github and i would like to get some feedback. Here is a link to the code in github: https://github.com/MartinChekurov/Generic-Linked-List GenericList.c ...
1
vote
1answer
149 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
4answers
104 views

Removing nodes with a given value from a linked list

Is this a good way of removing all the nodes that contains a value x? This function takes as input the head of a list and has to delete all the nodes that contain a given value taken. If there is ...
2
votes
2answers
46 views

Removing nodes from a linked list

This is my second iteration of a function to remove all nodes containing value 'x'. The previous iteration is here. This function takes as input the head of a list and has to delete all the nodes ...
3
votes
4answers
184 views

A general case of Adding numbers represented by Linked List

I'm looking for some feedback on this code I wrote tackling a general solution to the age old "Add 2 numbers represented by Linked Lists". This specific one aims to be able to sum any given number of ...
2
votes
1answer
102 views

Get word frequency of a txt file and save it to linked list

I'm a novice in C++. I want to do three things: Get the number of lines in the file Get the number of total words in the file Get each frequency of each "unique ...
5
votes
2answers
86 views

Converting a 1D list to a 2D table

A few days ago someone asked this question. But they quickly deleted the post offering no solution. Given: ...
5
votes
2answers
155 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 ...
6
votes
1answer
190 views

C++ Linked list implementation using smart pointers. Advice on move semantics

As an exercise to familiarise myself with smart pointers, I implemented a template linked list class in C++, closely following the very good tutorial at: https://solarianprogrammer.com/2019/02/22/cpp-...
10
votes
2answers
1k views

Graph coloring project in C++

I recently had to submit my 12th grade final project in C++, so I decided to make a game engine! That panned out just as you would expect (I am not touching OpenGL until they touch OOP), so I switched ...
3
votes
3answers
197 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
58 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
2 3 4 5
20