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

3
votes
2answers
40 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 ...
7
votes
2answers
370 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
76 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
51 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
64 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
37 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
320 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
40 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
86 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
146 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
72 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
102 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
149 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
53 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
127 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 ...
6
votes
4answers
148 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
54 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
40 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
429 views

Implementing a linked list using C++

Any suggestions? ...
5
votes
1answer
49 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
71 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
72 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
178 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
174 views

Implementing sequence abstraction

Below is the code that implements sequence abstraction using type abstraction Sequence (in Java): ...
2
votes
1answer
39 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
36 views

Reading from file and storing as Linked List

This is the code I have: ...
1
vote
2answers
58 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
33 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
70 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
46 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
125 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
188 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
76 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
108 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
144 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
261 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
425 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
70 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 ...
11
votes
5answers
1k views

Singly Linked List in Java

I created my own implementation of a Singly Linked List. Is there anything I can improve on, in terms of effciency. Also, what other methods would you recommend for me to try and implement. My goal is ...
5
votes
2answers
180 views

Edge cases for simulated malloc function

I'm trying to simulate the malloc function in C by using mmap and having 2 linked lists to act as memory blocks. The program ...
5
votes
4answers
547 views

C Doubly Linked List

It works, but it seems a bit long winded. I'd like some critiquing. ...
0
votes
2answers
284 views

Using recursion to count nodes in a binary tree, test equality of linked lists, and find extrema of a linked list

I am working with a some small functions to test recursion. I am fairly new to Python and am wondering if there is a cleaner way to get the job done. ...
1
vote
0answers
64 views

Reverse every k nodes of a linked list [closed]

Given a linked list and a number k, Reverse every k nodes in the list. Input: 1->2->3->4->5->6 and k = 1 Output: 2->1->4->3->6->5 How can I ...
1
vote
2answers
112 views

Reverse linked list using recursion

Here is my code to reverse link list in using recursion: ...
2
votes
0answers
104 views

Simulating a linear linked list using an array

A program to simulate a linear linked list using an array: Specs: A y : Create a new node with data value y, and append this node to L I x y : Find the node t with value x, create a new ...
3
votes
0answers
50 views

JavaScript Doubly Linked List

I coded up a basic DLL for use in a Stack or a Queue in JAvaScript for practice. Coming from a C++/Java background so I basically just converted how I would code it up in one of those, not sure if ...
2
votes
0answers
70 views

Linked list order reverse program efficiency

Here is my function which convert linked list in the following order: Example: Inputs: 1->2->3->4->5->6->7->8->NULL and k = 3 Output: 3->2->1->6->5->4->8->7->NULL. Code: ...
3
votes
2answers
68 views

Functional-style linked list written in C

For my Operating Systems class, I needed a linked list data structure and didn't have one already written. During the course of thinking about how to implement a linked list again (it had been a ...
1
vote
1answer
38 views

Make a new design of Stack with a new function

I am doing some coding exercise, and I am not sure if I have met the requirement. Can someone help me to figure it out? How would you design a stack which, in addition to push and pop, also has a ...