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
0 votes
0 answers
9 views

Insertion of node at tail in linked list [closed]

In this why are we using return statement in if condition of function void tail() also why when we use node* head as argument in void tail() istead of node* &head gives us NULL ?? ...
user avatar
1 vote
1 answer
54 views

Linked list implementation in cpp

I need some review for this CPP Linked list implementation. This is my first time implementing such a data structure in CPP. Thanks in advance. ...
user avatar
2 votes
1 answer
54 views

UpdateCustomer - implementation in C++

I am trying to write a program that does the following: The application will read the customer and book orders data from a data file “BookOrders.txt” and load them in a customer linked list, each ...
user avatar
0 votes
1 answer
63 views

std::list implementation learning exercise

I want to improve my algorithms and data structures in C++ understanding and also learn how the standard library containers are implemented. I implemented a std::vector in a previous review and this ...
user avatar
  • 2,227
2 votes
2 answers
90 views

Linked-list in C without typedefs and globals?

I took RosettaCode's implementation and tried to create something useable (editing their wiki as I go to give-back): ...
user avatar
  • 503
2 votes
1 answer
54 views

Linked List Implementation in C. Looking for feedback

I am new to C programming and DSA. This is my implementation of a Linked List. I am looking for feedback and tips to improve the code design. ...
user avatar
  • 21
2 votes
3 answers
110 views

Suggestions to My Generic Doubly-Linked List

Here's my doubly-linked list implementation. I'd like to hear what the community has to say, and what feedback I can get to further improve it. ...
user avatar
8 votes
4 answers
1k views

Forward linked list implementation in C++

I wrote a linked list implementation in C++ to learn the concepts about linked lists as well as C++(17). I decided to use std::unique_ptr to help me avoid leaks and ...
user avatar
0 votes
2 answers
51 views

C - Linked List Practice

Been studying data structures in C to get more grasp on the fundamentals as a freshman at uni. This is a coding-challenge that I've given to myself to understand Linked Lists better. Basically, my aim ...
user avatar
6 votes
1 answer
380 views

LFU Cache implementation in Python 3

Need some feedback on this implementation of LFU cache in python3. Original problem : https://leetcode.com/problems/lfu-cache/ Would really appreciate some feedback on readability, understandability ...
user avatar
  • 63
0 votes
0 answers
76 views

A doubly-linked list supporting full reversals in O(1) time (Java): Part I/II: the list

I have this Java data structure implementing only the very basic methods of the java.util.Deque and java.util.List interfaces. ...
user avatar
  • 25.3k
6 votes
1 answer
125 views

Implementation of Singly Linked List in Python

I am learning basic data structures in Python. I'm not confident enough if my implementations are OK or I miss any corner cases. So please check my code for Singly Linked List and Let me know where I ...
user avatar
  • 61
1 vote
1 answer
62 views

Reverse a sublist of a singly-linked master list in constant space and maximum of one pass (Java)

So I found this funky programming challenge somewhere on Quora. The idea is to take the head of a singly-linked list, and reverse a specific sublist. The requirements are: runs in constant space, ...
user avatar
  • 25.3k
6 votes
4 answers
650 views

Simple Singly-Linked List class

Decided to write something simple and came up with idea to write simple single linked list in C++ to improve my knowledge about pointers and memory management in C++, and wrote this: ...
user avatar
  • 105
2 votes
1 answer
65 views

Refine Linked List Implementation in Python (pop, insert methods)

I've recently learned how to implement linked list in Python. Can anyone help me to refine my code of implementing methods 'insert()', and 'pop()'. pop(pos) - remove and return item at position pos. ...
user avatar
4 votes
2 answers
73 views

Linked list implementation for a beginner in C

So I've decided to dabble a bit into C, and while it's trippy as heck I've finished an implementation of a linked list for practice. I've pretty sure there's some type of obscure bug or memory leak in ...
user avatar
  • 41
1 vote
0 answers
76 views

Implementing a LinkedList in Rust

I have this LinkedList implementation for rust and it isn't quite what I am looking for. Ideally, it would be more like scala's implementation of List and be entirely immutable. This implementation ...
user avatar
1 vote
1 answer
60 views

Create a linked list from an array, and also free that list

I'm currently learning C/C++ and I saw this question on Reddit on how to create a linked from an array and decided that would make a good exercise for learning the absolute basics of C, so without ...
user avatar
  • 205
1 vote
1 answer
137 views

Generic doubly linked list in C

I have implemented generic doubly linked list in C language in which you can store any data type you want. Just like in C++ and Java, where a list can store any data type, like - string, int, long, ...
user avatar
2 votes
1 answer
92 views

Finding better logic for addition and removal of Nodes in a Linked List

Consider the following piece of code I wrote (a templated Linked List): ...
user avatar
2 votes
4 answers
285 views

Single-linked-list in C++ with iterators

I'm implementing a single linked list as close as it could be to std::forward_list. I would welcome a review and also more suggestions on what to test additionally. ...
user avatar
3 votes
2 answers
62 views

Testing MRU-list vs. standard list

The task is to test the the benefits of a Move-To-Front Linked List vs. a standard Linked List. It was also meant to practice inheritance and pointers. The standard functionality is in ...
user avatar
  • 235
3 votes
2 answers
265 views

Function to create single linked-list

Given the following data struct: typdef struct lista { int num1, num2; struct lista* sig; } nodoNum ; and a declared ...
user avatar
  • 33
0 votes
1 answer
123 views

Linked List Implementation in C#

I wrote an implementation of the Linked list data structure. I mostly did this because it's the simplest collection data structure (at least the simplest to implement), and I wanted to practice ...
user avatar
  • 1,796
0 votes
1 answer
40 views

Faster, indexed, heuristic doubly-linked list data structure in Java: unit tests

Here I have the unit tests for the indexed doubly-linked list. It goes like this: ...
user avatar
  • 25.3k
2 votes
1 answer
62 views

Faster, indexed, heuristic doubly-linked list data structure in Java: benchmark

I have this benchmark program for my indexed linked list. It looks like this: com.github.coderodde.util.benchmark.LinkedListBenchmarkRunner ...
user avatar
  • 25.3k
2 votes
1 answer
128 views

Faster, indexed, heuristic doubly-linked list data structure in Java: implementation

I have this doubly-linked list data structure that runs all the single-element operations in \$\Theta(\sqrt{n})\$ time (refer to this post and this repository). (See this for benchmarks.) (See this ...
user avatar
  • 25.3k
2 votes
1 answer
46 views

Linked list - append, insert, print

I am a beginner in C and am learning linked lists. I have made a program to implement a linked list, allowing certain operations on the linked list. There are 3 functions: ...
user avatar
1 vote
2 answers
184 views

SumList Cracking the coding Interview

Sum of 2 numbers, represented with linked lists, where digits are in backward order or forward order. Backward order Example INPUT:(7->1->6) + (5->9->2) = 617+295 OUTPUT: 2->1->9 = ...
user avatar
3 votes
0 answers
113 views

How can I filter and sort LinkedList faster and more effective?I have list of orders that should be processed

I have method that fetches all orders from Database and filtering, sorting that data(I know better to do It by specific query to Database but I dont know how). I have Order entity that has following <...
user avatar
3 votes
2 answers
46 views

Insert value into multiple locations in a list

Code ...
user avatar
  • 123
2 votes
2 answers
308 views

Filter a Linked List in Place in C

I have created the following function which filters a linked list in place (here it removes all instances of the element k), but it could easily be modified to take a function pointer as an argument ...
user avatar
0 votes
1 answer
507 views

How to have a nested struct as linked list in C? [closed]

I am new in C and I have to do a project which reads data from a .txt file and created linked list of structures to different operation on that structures (CRUD). The file contains data of rooms in a ...
user avatar
2 votes
2 answers
72 views

Merge Sort for Linked List Criticism in C

I previously implemented a Merge Sort for arrays, so after fixing up my code for the array-based merge sort I have now implemented a merge sort for a basic singly-linked list data structure which only ...
user avatar
  • 403
1 vote
0 answers
42 views

Integer Double Ended Queue GO

I'm currently learning Go and I have decided to implement a Circular Doubly Linked List (Deque) structure for the training. Go is not my first language. I program mainly in Python, therefore I would ...
user avatar
1 vote
2 answers
100 views

Delete last node in singly linked list

In a TED talk Linus Torvalds made a point about “good taste” at approximately 14:10 in the interview. I read through his examples of “bad taste” and “good taste” and wanted to implement the same ...
user avatar
2 votes
1 answer
560 views

Ncurses Snake Game using a Linked List in C

This is a lightweight text based version of the popular game Snake written entirely in C. In order to build it, ncurses needs to be installed on the system. Navigation is done using the vim-keys and ...
user avatar
2 votes
1 answer
46 views

Linked list that support modifications during iteration

Update: Fixed last item is not removed during iteration Fixed clear() during iteration does nothing Fixed addition of removed item is ignored The lasted code can ...
user avatar
5 votes
1 answer
148 views

singly linked list python code

I have recently tried converting a singly linked list from a C program into my own python program. I have tested the code myself but I am still unsure if the program has been converted properly. I ...
user avatar
3 votes
1 answer
401 views

Forward List Implementation

NB: There's a bug with my iterator, apparently. I can't use const_iterator because I get some compiler errors. I know using const...
user avatar
4 votes
1 answer
104 views

Hash table library implementation

I wrote my own implementation of generic hash table. I’m using linked list to resolve collision problem. I want to share my code with you and get your opinion about it, and if there are any advice or ...
user avatar
6 votes
4 answers
512 views

Linked list implementation, manipulation, and testing in C

This is a beginner's attempt at implementing a linked list in C. Please read the code and provide recommendations. I do not want to limit the reader's benevolence to only these questions, but my ...
user avatar
1 vote
1 answer
124 views

Binary Radix Sort implementation on linked list

I am trying to implement binary radix sort in C which sorts a linked list of integers stably. Although my algorithm has a time complexity of O(log2(k).n) (where k ...
user avatar
  • 113
1 vote
2 answers
635 views

Splitting a list by predicate

I have written a function splitAtPredicate that splits the list at element x satisfying p, ...
user avatar
  • 113
2 votes
2 answers
71 views

remove kth last element from singly-linked list - Follow up

This code is a revised version of implementation which asked for an improvement. Original question is asked here: remove kth last element from singly-linked list credits to: Toby, Andreas, Arkadiusz ...
user avatar
5 votes
2 answers
307 views

Removing C comments from Source

Challenge posted 5 Dec 2020 to comp.lang.c This program is essentially the same as my Version 8 posted to that thread, but with some further cosmetic improvements. This program reads from stdin (or a ...
user avatar
  • 1,834
6 votes
3 answers
687 views

Double Linked List with smart pointers: problems with insert method

I'm trying to implement a Templated Double Linked List, following Stroustrup's book "Principles and Practice using C++", Chapter 20.4. Instead of raw pointers, I want to use unique pointers. ...
user avatar
  • 161
0 votes
2 answers
164 views

remove kth last element from singly-linked list

I have implemented a code to solve following problem. I would like to improve the code efficiency. Pardon if I just printed out the result. Code has O(N) time and constant space complexity. Given a ...
user avatar
4 votes
1 answer
80 views

Bump Allocator in Linked List

Here is my code for implementing a linked list with custom allocators (the standard malloc/free and a simple bump allocator). I appreciate any comments or critiques about architecture, formatting, and ...
user avatar
  • 557
4 votes
3 answers
312 views

Generic implementation of a hashtable with double-linked list

I implemented a hashtable that handles collisions by chaining entries using a double linked list. The idea is that it can store/lookup any kind of generic data structure, while maintaining an API that ...
user avatar
  • 795

1
2 3 4 5
21