Skip to main content

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
2 votes
1 answer
59 views

Simple Stack and Deque implementation (v2)

My previous post: Simple Stack and Deque implementation I have implemented 2 classes for my project similar to stack and deque. This is my second attempt to get advice and evaluation of my code. Maybe ...
vansergh's user avatar
  • 161
1 vote
1 answer
104 views

Simple Stack and Deque implementation

I implemented a single-linked and double-linked lists (like stack and deque). I would like to receive your feedback on improving the code or maybe some comments. I'm learning C++ for the third month. ...
vansergh's user avatar
  • 161
4 votes
3 answers
648 views

Error handling for singly linked list in C

I have seen many list implementations in C in this site; I know its been asked many times. I need some advice regarding: Quality of my code, especially my list library. How to handle errors in main (...
Sai_krishna's user avatar
9 votes
2 answers
1k views

C# Linked List implementation

I am trying to learn C# and created this project to improve. I will be using C# professionally so a harsh critique is welcome. ...
Doruk's user avatar
  • 333
1 vote
1 answer
54 views

Advent of Code 2022 Day 13 Solution in C: Sorting and parsing nested list

Link to Original Problem: Advent of Code 2022 Day 13 Question Summary: The task involves sorting and parsing nested lists, with two parts: Determine pairs in the correct order and calculate the sum ...
fish_brain's user avatar
2 votes
4 answers
699 views

Adding Node to Linked List

I've been programming for 3 months now, and I've just come across Linked List, and I'm not gonna lie, I've been struggling a little. I wrote this code to practice on Linked Lists. The purpose is to ...
fraber's user avatar
  • 179
4 votes
2 answers
374 views

Count the frequencies of each word in a file

I have tried to implement a code that does the following: store words in an array (unordered) use function order_array() to place repetitions for the same word ...
Arsenio's user avatar
  • 43
4 votes
3 answers
485 views

Templated linked list

I have created a templated linked list to take different objects. I was told to put this up for code review as it could use some improvements. To be honest, I am not completely sure when to use the '...
Peazypound1212's user avatar
2 votes
1 answer
297 views

Printing the elements of a forward linked list

I'm a sophomore in computer science who's working on a linked list class for his DSA class. I believe this code can be improved, but I'm not sure how because everything got really messy really fast. ...
ozan's user avatar
  • 43
4 votes
2 answers
2k views

Linked list and array list performance comparison in C

After watching Stroustrup's presentation on performance comparison between vectors and linked lists (https://youtu.be/YQs6IC-vgmo?si=9r5wXqnwkmN29xqn), I've decided it would be a good problem to get a ...
low-altitude's user avatar
0 votes
1 answer
198 views

Calling the base method from overriden method to add some functionality

I have a small Linked list program which I created for just brushing up the concepts. Following is my Node class ...
Jyothish Bhaskaran's user avatar
3 votes
1 answer
126 views

std::list reimplementation for practice

I used cppreference list to implement this simplified std::list. The CXX_STANDARD is 11. My questions are the usual: Is the ...
Abner's user avatar
  • 39
0 votes
2 answers
491 views

Printing the elements of a linked list [closed]

An absolute beginner here who is practising linked list problems in hackerrank. Stumbled upon this question which is categorised as easy. Given a pointer to the head node of the linked list, print ...
brucey's user avatar
  • 19
6 votes
3 answers
446 views

Unit testing a Linked List implementation in C++

Recently I wanted to use the gtest library to unit test my program but for some reason, it's incredibly hard to make it work and configure (at least for me it was), ...
I_throw_but_dont_catch's user avatar
1 vote
1 answer
58 views

Revised C Doubly-Linked List

I have revised the implementation I originally posted here. Thank you all who responded; I took your comments to heart. Please let me know if you have any additional feedback. Here are some notes to ...
user129393192's user avatar
5 votes
4 answers
2k views

Simple C Doubly-Linked List

Here is some code I've written. I am welcoming any critiques, whether it is style/formatting, correctness (I believe it is correct) -- I would appreciate any advice on formatting unit tests, and any ...
user129393192's user avatar
3 votes
1 answer
115 views

Doubly-linked list functions

This is my first time implementing a doubly-linked list. I would like some feedback on my code. Any comment would be appreciated regarding the quality of the code, bad implementation, memory ...
Toideki's user avatar
  • 31
3 votes
2 answers
491 views

Generic Doubly-Linked-Lists C implementation

I'm trying to build step by step a C library that will include some of the major Data Structures such as Linked Lists, Stacks, Binary Trees etc., mostly in order to practice my C programming skills ...
BarAmber's user avatar
  • 105
5 votes
3 answers
935 views

Dynamic C Linked List Implementation

I've started to experiment with (void *) in C, in order to work with Dynamic Data Types, that is, to surpass the need to pass specific type of data. I have implemented this doubly linked list in C and ...
BarAmber's user avatar
  • 105
3 votes
2 answers
6k views

Detecting Intersections of a Collection of Singly-Linked Lists

I was recently presented with the following problem... You are given a collection of singly-linked lists (SLLs). Return true if any of them share a common node (or “intersect”), or false otherwise. ...
James Law's user avatar
  • 497
0 votes
1 answer
65 views

Doubly Linked List of integers

I wrote a working linked list program in C. What can I improve in my code in your opinion? The first thing I think about is doing unit tests. I want to learn TDD. I'm not sure if it is a good idea to ...
whiteman808's user avatar
3 votes
1 answer
106 views

A singly linked list implementation

Here's yet another implementation of a singly linked list. You may base your review on the following questions: Review goals: Is the API well thought of? Does this design include undefined behavior, ...
Harith's user avatar
  • 9,687
2 votes
2 answers
194 views

Reversing in between a linked list

I have written code for this leetcode problem :- Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to ...
Strange Alchemist's user avatar
1 vote
4 answers
878 views

Queue using doubly linked list

I have implemented my queue based on doubly linked list. The codes is tested and works, however, I am interested in some improvement ideas, thanks Based on some review remarks on my previous ...
V_head's user avatar
  • 525
0 votes
4 answers
805 views

Stack using doubly linked list

I have implemented my stack based on a doubly linked list. The code is tested and works; however, I am interested in any improvement ideas. ...
V_head's user avatar
  • 525
4 votes
4 answers
1k views

Doubly linked list optimally defined over 17 operations in C [4]?

Previous versions of this question First Version Second Version Third Version Fourth Version Changes I built upon the previous singly linked list and implemented a doubly linked one. You are not ...
V_head's user avatar
  • 525
2 votes
2 answers
229 views

singly linked list optimally defined over 17 operations in C [2]?

Previous versions of this question First Version Second Version Changes I added these operations: Pop_back Pop_front You are not allowed to insert_sll at the ...
V_head's user avatar
  • 525
3 votes
2 answers
368 views

singly linked list optimally defined over operations in C?

I have implemented my singly linked list in C and I tried to do it with the most efficient code as possible. Is there any place for improvement? This post is the second version. First version of this ...
V_head's user avatar
  • 525
3 votes
1 answer
235 views

Singly linked list optimized for search & insert in O(1)

I have tried to implement my singly linked list to be optimal in the sense that when inserting I don't have to search for the tail and then chain the new node to it, I just keep track of the tail and ...
V_head's user avatar
  • 525
6 votes
1 answer
473 views

Doubly linked list first fit free list malloc/free in Python

As an exercise I've implemented malloc and free in Python as a first fit free list as described here. This tracks which blocks are free in a doubly linked list that is sorted by the address of the ...
Xander Dunn's user avatar
8 votes
1 answer
681 views

C void* Generic Linked List

I once tried to make a generic linked list in pure C (no external libraries, only the C standard library) here using C macros. With the same restrictions as in the previous attempt, this time I'm ...
404 Name Not Found's user avatar
4 votes
2 answers
153 views

Max Stack implementation in C++ involving iterators

The tricky thing was keeping copies of list iterators in a tree map and managing both together. I'm not handling invalid input cases (like popping an empty stack) in this code. I am following Google C+...
user267704's user avatar
5 votes
2 answers
388 views

C Macro Generic Linked List

For a recent project of mine I had to create various data structures in pure C with no external libraries (in other words, code I've written by myself), which lacks the templating and OOP capabilities ...
404 Name Not Found's user avatar
1 vote
2 answers
115 views

Circular list vs. doubly-linked list: which is faster?

In this post, I will compare performance of a circular list and a conventional list with head/tail -references: ...
coderodde's user avatar
  • 29.1k
2 votes
1 answer
114 views

Linked list in rust, Needed optimization

I've implemented constructor, push , pop, drop and some macro. I need to know if the drop implementation is correct and is drop is really necessary? Meanwhile I still didn't check about ...
Nithin Gowda's user avatar
2 votes
2 answers
449 views

Inserting into a Sorted Doubly Linked List

Edited: incorporated some feedback and added a lot of features I've written a basic Doubly Linked List Class where every insertion into the class should be sorted into ascending order. The project ...
Hofbr's user avatar
  • 331
2 votes
1 answer
247 views

Middle of the Linked List in Rust

Yesterday, inspired by some great questions here, I decided to give myself some practice with Rust, by solving all the introductory questions over on LeetCode. It was a great learning exercise, and ...
Davislor's user avatar
  • 8,099
1 vote
2 answers
165 views

Insert node at beginning of LinkedList

My professor required we make a LinkedList class with a bool add(in newEntry) method. Two things I'm questioning my choices on ...
Hofbr's user avatar
  • 331
10 votes
7 answers
2k views

Unidirectional linked list in C

I'm learning algorithms and I wrote the single-directional linked list implementation in C. I need a code review of what can I improve in my code and I want to make sure there are no possible memory ...
zxqp's user avatar
  • 101
2 votes
1 answer
114 views

Linked List implemented in C++

I have a linked list code in C++: ...
narocac's user avatar
  • 65
9 votes
1 answer
1k views

Intrusive linked list in C

I've been working on an intrusive linked list for the past few days for a personal project and I would like to have some feedback on it. :) Personally, I would have preferred to make ...
Nicholas Sudsgaard's user avatar
4 votes
1 answer
482 views

Simple slab allocator in C

Here is the plan: a slab takes up 1 page and it has PGSIZE / blocksize amount of blocks the minimum blocksize is 8 bytes, otherwise the pointer to the next block ...
runningupthatroad's user avatar
2 votes
3 answers
1k views

Check if parentheses are balanced using a stack implemented with a linked list

Problem: Stacks can be used to check whether the given expression has balanced symbols. This algorithm is very useful in compilers. Each time the parser reads one character at a time. If the character ...
Sol's user avatar
  • 29
3 votes
1 answer
127 views

Queue using circular linked list

I'm reading through Algorithms Fourth Edition by Sedgewick and doing some of the practice exercises in C++11 instead of Java. Exercise 1.3.29 is to write a Queue that uses a circular linked list, ...
Marlon Smith's user avatar
5 votes
1 answer
190 views

basic singly-linked list in rust

I'm new to rust and tried to implement a singly-linked list as exercise. Is this code so far suitable to solve the problem? What elements of the language should I consider to make the code more ...
panda_snail's user avatar
2 votes
1 answer
163 views

Advice for optimization of a custom doubly Linked List class

This is my custom implementation of a double Linked list. Code is apparently working fine. Need advices on improvement and/or optimization. This is a tiny academic side-project. I am still pretty ...
SogaBan's user avatar
  • 53
5 votes
2 answers
122 views

Basic Linked List C implementation

I've written a singly-linked list of characters. This is my 3rd C program and I'd like some feedback on what I can improve on in any aspect whatsoever. If you'd prefer to look at the repo directly it'...
Joe Boyle's user avatar
  • 137
6 votes
2 answers
186 views

(Rev. 2) Type-generic queue implementation using singly linked lists

Thanks to the extremely helpful comments and answers from the original post, I've improved the interface and implementation of this general-purpose queue library. Improvements include: Fixed memory ...
Mode77's user avatar
  • 663
11 votes
4 answers
1k views

Type-generic queue implementation using singly linked lists

Simple lightweight queue implementation using data size registration and singly linked lists as the underlying type Update #2 ...
Mode77's user avatar
  • 663
6 votes
2 answers
1k views

Linked List implementation in c++ with all functions

I wrote my implementation to Linked List. And I tried to implement all the functions in the standard library list in CPP! I need a review for it to improve it and improve my coding skill. I also will ...
Omar_Hafez's user avatar

1
2 3 4 5
22