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
1
vote
2answers
57 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 ...
3
votes
1answer
53 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 ...
3
votes
3answers
517 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
54 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 ...
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 ...
2
votes
2answers
42 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 ...
2
votes
4answers
98 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 ...
3
votes
4answers
179 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
68 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
84 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: ...
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 ...
6
votes
1answer
161 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-...
8
votes
2answers
137 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 ...
3
votes
3answers
125 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
56 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 ...
3
votes
2answers
84 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
72 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
82 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
608 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 ...
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. ...
5
votes
1answer
100 views
0
votes
1answer
71 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
2answers
77 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. ...
2
votes
1answer
102 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 ...
3
votes
1answer
79 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
161 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, ...
9
votes
1answer
274 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 ...
6
votes
1answer
67 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....
1
vote
1answer
52 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. ...
1
vote
3answers
100 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 ...
3
votes
1answer
71 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
131 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 ...
4
votes
1answer
162 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
66 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
93 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
765 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
78 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
93 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. ...
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
177 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
57 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
47 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 ...
0
votes
1answer
100 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 ...
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
87 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
105 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
491 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:...

1
2 3 4 5
19