A linked list is a data structure in which the elements contain references to the next (and optionally the previous) element.

learn more… | top users | synonyms

-1
votes
0answers
17 views

linked list query [on hold]

I used the following code to create a linked list of pointers, each having a length of the English alphabet plus one for the apostrophe. I'm trying to load words from a file, dictionary into a trie ...
1
vote
1answer
39 views

Inserting a node at a specific position in a linked list

Given a node class like class Node { int data; Node next; } Provide an implementation to Insert a node at a specific position in a linked list ...
2
votes
1answer
45 views

LRU cache design using dict and doubly linked list

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the value (will always be positive) of the ...
2
votes
2answers
50 views

Linked list insertion

I have written the code below for inserting an element at the position specified by the user. I have seen the code in multiple books, and they have always used two pointers in the function that ...
5
votes
4answers
145 views

Implementation of C linked list (Queue) of C strings on mega AVR

I have been working on a mechanism to queue up strings coming into a system via a USART and have implemented it as a singly linked list. I have done my best to profile the code and its memory usage at ...
8
votes
1answer
37 views

Recursively pop the last node from a singly linked list

I am exploring different ways of implementing a linked list in Rust as a learning project. In one particular place, I've got some code that works properly, but it makes multiple calls to unwrap--I am ...
-1
votes
1answer
41 views

Singly Linked List with Generics and Comparable Data [closed]

I am currently reading about the thread-safe implementation of a linked list. Although I implemented this linked list while keeping in mind the issues from the first code review (Binary Tree). I would ...
4
votes
1answer
55 views

Creating a linked list of strings

Warning: I'm quite new to low-level programming and memory management so please don't mind it when I'm asking incredibly stupid things. I'm working on a project where I need to read all the lines ...
3
votes
1answer
38 views

Ordered doubly-linked lock-free list

I'm implementing a lock-free ordered doubly-linked list based on heavily modified paper entitled Split-Ordered Lists: Lock-Free Extensible Hash Tables by ORI SHALEV. My main concern is correctness of ...
7
votes
1answer
128 views

Searching in a lock-free ordered single-linked list

The code below represents a lock-free ordered single-linked list, and is a modification of the algorithm proposed in this doc. How can I improve speed of searching (lookingup) in the list maintaining ...
3
votes
2answers
70 views

Add two numbers represented by linked lists

I've just encountered this question and am trying to solve it using Java. Here is my solution to it, which may not be optimized or might not be right way to do it. Someone please review whether it is ...
3
votes
2answers
51 views

Find kth element from tail of singly linked list in one pass

I have tried the below program to find (Kth element from tail) of a singly linked list. I have tried to utilize the length field which I am incrementing whenever an item is added into the list or vice ...
8
votes
2answers
387 views

Sum two linked lists

Write code to sum two numbers represented by a linked list. The digits in this linked list are in reverse order. eg. (9->2->3) + (4->8->2) = (3->1->6) Any comments on my solution (especially ...
2
votes
1answer
80 views

Populate the list based on which datacenter code is running on

This is a follow on to : Efficiently detect datacenter based on server hostname and return the full path. I have a library which is running in different datacenters in production. I have three ...
3
votes
1answer
62 views

Making a copy constructor more flexible for ADT queue

I have constructed a copy constructor for an ADT queue. The copy constructor works fine. I would want to improve my code, but I don't really know how to shorten it to make it more flexible. ...
5
votes
1answer
73 views

Single LinkedList using smart pointers

In order to learn C++11, I propose to myself implement a simple single linked list using smart pointers. The idea was to cover the basic operations without leave any memory leak. I came up with a ...
2
votes
1answer
42 views

Linked List Operations in C Read Proof

I am trying to write up all the linked list basic operations (push, pop, add_at_end, pop_from_end, add_at_index, pop_from_index). This is not a school assignment, even though it may look like one. I ...
5
votes
2answers
394 views

Recursively insert a node in an ordered Linked List

I've written this and it works great. Is there any shorter or simpler way to achieve the same result without distinguish between cases? ...
2
votes
1answer
58 views

Doubly Linked List implementation

At university we shortly started using C. I thought it would be a good exercise for almost everything that has to do with basic C to do a doubly linked list implementation. I tried to do it from ...
2
votes
2answers
92 views

Better method structure for insertion in doubly linked list

Here is my insertion method for a doubly linked list. It works, but passing two parameters for the method seems cumbersome. Can anyone suggest a cleaner approach than this? ...
4
votes
2answers
166 views

Implementing a Singly Linked List

I am implementing, in my SinglyLinkedList class, an interface where I redefined linked list. I am trying to learn data structures. Please, let me know what I can ...
4
votes
1answer
90 views

Simple stack and linked list

I know that Python has a built-in list data structure, but I want to implement my own linked list and stack data structures for practice. I have three classes ...
2
votes
1answer
152 views

Priority Queue Linked List Implementation

I am new to Python and wanted to make sure my code answers the question for my assignment due. My Task: A priority queue is a queue in which each item is assigned a priority and items with a ...
5
votes
2answers
193 views

Doubly linked list: iterator/pointer arithmetic

I'm using a doubly linked list container I've written as the working example. The textbook I'm using is from 2001, so feel free to point out where later versions of the C++ standard should be used ...
2
votes
1answer
55 views

Linked list library in C

I just finished my linked list library in C and I am trying to find out what should be improved. The functions provided by the library are members of the main data structure (very important). The ...
3
votes
2answers
162 views

Double-ended linked list

I want to know if there is any redundancy in the code or if it is missing something. I ran it with several different choices and it works fine but I still want to know are there any more subtle ...
7
votes
4answers
153 views

Summarizing calories for a food diary

I'm new to C and I've been working on some code for a project for school. This was the finished result and now that I'm done it, I came back and tried making it better. So I was wondering, how would I ...
2
votes
1answer
70 views

Common operations on a linked list (user defined)

I have just started learning data structures and for the past two days I was going through linked lists. I have implemented the basic/common operations on the linked lists and I would love for some ...
3
votes
1answer
47 views

An implementation of a double linked list

Here is my implementation of double linked list. Is it possible to reduce the code and improve it? Some methods here: head (returns head of the list) tail (returns tail of the list); append ...
2
votes
3answers
658 views

Implementing a linked list using C++

Any suggestions? ...
5
votes
1answer
61 views

Mergesort a LinkedList

I have made an attempt to write the mergesort routine on a LinkedList in Java. It will be great if somebody can review my implementation and point out the issues ...
3
votes
1answer
80 views

Sort a linked list with merge sort in C

This is my version of a linked list in C. The function mergeSort requires a reference to the first and to the last nodes, as well as the indices of the first and ...
2
votes
1answer
74 views

Determine the index where two lists diverge

Background A class provides an API to determine the index where two string lists diverge. ...
6
votes
3answers
185 views

Stack with getMin method

This should implement a stack that has a \$O(1)\$ getMin method. I used an auxiliary stack. Please provide comments on my solution. ...
3
votes
3answers
175 views

Implementing sequence abstraction

Below is the code that implements sequence abstraction using type abstraction Sequence (in Java): ...
2
votes
1answer
43 views

Singly-Linked List In-Place Reversal

I've created a function in C to reverse a singly-linked list in place: ...
1
vote
1answer
46 views

Reading from file and storing as Linked List

This is the code I have: ...
1
vote
2answers
67 views

Univariate polynomial multiplication using Doubly Linked List

A univariate polynomial is a polynomial over a single variable, and in the following discussion when we say polynomial, we mean a polynomial in a single variable. You are given two polynomials ...
1
vote
1answer
35 views

Inserting nodes into a singly linked list based on size of number

Given a set of numbers insert them so that they are ordered ie. ...
5
votes
1answer
84 views

Tree list recursion from Stanford tutorial

I have found this appearing-to-be famous problem in Stanford tutorial about trees and decided to solve it. My solution appears to work great: ...
1
vote
1answer
50 views

Deleting node from LinkedList

I have this function to remove nodes that matches a certain criteria in the list. Initially when I wrote it, head node was not deleted if ...
5
votes
2answers
140 views

Kth to last element of a singly linked list

Find the kth to last element of a singly linked list Any comments? ...
3
votes
2answers
262 views

Delete an item from a linked list

I wrote this code to delete an item from a linked list. I checked it and it works, but I want to know if the logic could be written simpler or clearer. ...
3
votes
1answer
97 views

Remove odd valued nodes from linked list

The function remove_odd is to remove odd valued nodes (surprise!!) from the linked list head. The code is very long and cryptic but it seems to work. Please help ...
1
vote
2answers
166 views

LinkedList implementation (+Sorted)

I was recently learning about nodes and how they work in lists, and to test myself, I decided to write my own LinkedList ...
12
votes
1answer
149 views

Chack miy spellang pleez

For my CS2 project, I am supposed to implement a spell-checker. It is supposed to follow the following: Prompt the user for the name of the file containing the dictionary of correctly ...
4
votes
3answers
270 views

Simple Linked List that holds an int

I am inexperienced in C++. I was able to get my LinkedList to be fully functional. I was hoping to get some feedback as to whether or not I followed bad practices ...
6
votes
2answers
442 views

C++ Linked List Implementation

I'm learning C++ and also about data structures, so I am trying to implement some. This is my linked list. I've included two different ways of getting the length of the list, with a ...
2
votes
2answers
92 views

Implementing a Trie in Python using lists alone

I've been working on implementing a Trie in Python for educational purposes. I tried implementing one using dictionaries and I was successful. The structure of a trie with the words ...