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

0
votes
0answers
13 views

Implementation of circular douby linked list and functions

I have some functions I'd like looked over by better eyes. I consider myself a newbie so I was just wondering if you could spot any errors (or potential errors I may have missed) or maybe see ...
2
votes
3answers
97 views

Linked List in Java

Here is my implementation of a Linked List. I think it should be efficient because of the head node and rear node tracking. Please give any feedback on my implementation of Linked List. ...
-4
votes
0answers
10 views

Java Singly Linked List, add in index [on hold]

I am working on Singly Linked List for an assignment and am stuck on adding items in an index... I believe I am close just need a quick hand from someone :). My current code is listed below: ...
2
votes
1answer
67 views

Linked list using dynamic memory [closed]

I created a simple linked list to test what I've learned so far and if I manage everything correctly. If you see syntax errors is't because of copy-paste. I just want to know if i'm making everything ...
2
votes
3answers
100 views

Linked List design and implementation - C++

Seeking recommendations on how to improve this code, LL always seem to be a struggle. A basic linked list that does include next and previous pointers. I used a struct inside of a class, which I'm ...
4
votes
3answers
115 views

Reversing a linked list (Java)

Triggered by an interview question (I didn't answer during the interview) I wrote a Java program to reverse a linked list. I went with a loop-based approach instead of recursion. I would like to know ...
3
votes
2answers
69 views

Making a sorted linked list into a balanced binary search tree

My code works, but I need help on revising it to make it shorter and simple if possible on my main.cpp part ONLY. The other files is to make the program compile and work out if you want to see the ...
2
votes
1answer
80 views

Linked list C code

This is a toy version of the code I really want to write: ...
4
votes
2answers
54 views

Generic Skip List Implementation in Java

I am interested in implementing advanced data structures. One of them that tickled my fancy is the Skip List. My implementation is shown below: The SkipList node ...
4
votes
2answers
122 views

Poisonous Plants

I have solved the following problem. My code works but Hackerrank says that I can do faster: There are plants in a garden. Each of these plants has been added with some amount of pesticide. ...
2
votes
2answers
60 views

Circular Singly Linked List using Java

Please review my implementation of Circular Singly Linked List ...
0
votes
0answers
83 views

Copy-on-write linked list with value semantics

I'm implementing a SinglyLinkedList struct that uses a private Node class in its implementation. (See this Gist.) ...
4
votes
1answer
73 views

Generic singly linked list using the C++11 standard

This here is a templated singly linked list that I have been working on for the past couple of days in C++. I am not a programmer or computer scientist by training; finishing up my undergrad in ...
3
votes
1answer
40 views

Simple program to insert values in a linked list

I tried to write a simple program using linked list where I just insert the value stored in every node and then through a function print the values. This is the code: ...
4
votes
1answer
84 views

Linked List with c++ class

I am playing with a sort of linked list using C++ classes. I have used a lot of C linked lists (struct based) during C programming course, but there was no behavior. Thus, I am a bit confused about ...
3
votes
1answer
67 views

Simple singly linked list in Java

The list is pretty simple, here is my code: ILinkedList.java ...
10
votes
5answers
2k views

Merge two already sorted linked list

This is code to merge two sorted linked lists. l1 and l2 are sorted. While calling the merge function via ...
3
votes
1answer
67 views

Stack from Linked List

I have written a program that takes a linked list and then converts it to a stack. I would like a code review for my program. Thanks in advance. Stack.java ...
-4
votes
1answer
61 views

Recursive solution for merging two sorted lists [closed]

I came up with a recursive solution for merging two sorted list in Python in interviewbit: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing ...
4
votes
2answers
91 views

Doubly linked list reimplemented with smart pointers

I need some suggestions on my reimplementation of a doubly linked list with smart pointers since I'm new to smart pointers in C++. I read some docs on smart pointers and found out there are ...
0
votes
1answer
93 views

Deleting duplicate elements from a single-linked list in C++11

The code below is a simple coding exercise I got from a book that asks to remove the duplicates from a single-linked list (using a simple struct; this is part 2, ...
5
votes
3answers
90 views

Merging 3 sorted linked lists

I already know how to merge two linked list, but I needed to code a function that'll merge three already sorted linked lists into one. I wrote a code and it is working fine, it takes care of null ...
5
votes
2answers
103 views

Building a simple singly-linked list in C++11

The implementation below works, but I'm wondering if there's a modern C++ alternative. For example: Should I replace the raw new with a braced initializer? ...
3
votes
2answers
100 views

Avoiding misuse of optional unwrapping: LinkedList

Below is my implementation of a generic linked list in swift. Unfortunately, Swift playgrounds won't run until the compiler is totally happy - often, that involves clang making me explicitly unwrap ...
4
votes
2answers
68 views

Single Link List

So I have implemented Single link list using java.Please advice if this is OK or can be made better. ...
4
votes
1answer
54 views

How can I enhance my linkedlist implementation in java?

I recently implemented Linked List on my own. I did not use generics as I am still learning. How can I improve it: ...
2
votes
3answers
103 views

C++ Node class template

I'm working on building understanding of data structures in general, and specifically linked lists in this example. I'm also trying to increase my ability with templates. In cross-referencing dozens ...
3
votes
2answers
81 views

Reverse a linked list recursively

This recursive calls reverseList on each node of the linked list. When returned from the function call, it changes the next link to the previous node. ...
1
vote
3answers
45 views

C single-linked list with remove

Can you please point out any problems with this C forward list with remove node functionality? I believe this can be way simpler ( removeNode function ) but I ...
0
votes
1answer
24 views

Data-structure “Singly-Listed List” in JavaScript

The purpose of the data-structure is to manage person-objects. Persons can be added at any time. But the order can't be changed afterward. Only the deletion of a person is possible. Represents the ...
7
votes
1answer
55 views

Social network graph of characters in a novel

I wrote a C program that builds a social network graph of characters in a novel. The program takes two text files as input: a list of the names of the characters in the novel, and the file of the ...
2
votes
2answers
75 views

Adding two singly linked lists in C++

I took a challenge from a web site. I aim to have a runtime performance as good as possible. My solution was accepted, though I think it is not the most efficient because I saw others having a faster ...
3
votes
1answer
59 views

How to make doubly linked list design more efficient?

I have played recently and implemented doubly linked list with merge sort algorithm. I was wondering if there is any way of improving the algorithm further to make it as fast as possible (I know about ...
6
votes
2answers
160 views

Find minimum node in Linked-List

I wrote a method that will return the minimum element in a linked-list that operates in O(1) time. I tested and everything works fine. However, I was wondering if there is anything that I can do to ...
1
vote
2answers
71 views

linked list in c code

I have implemented linked list data structure in c. linkedlist.h ...
4
votes
1answer
81 views

Avoiding pointers in this C++ linked list

As I know it is not good idea to have so many pointers in c++ code. But I have written this simple implementation of linked list in c++ and there are many pointers in it, how can I improve that? Also ...
4
votes
3answers
134 views

Recursive methods of singly linked list

Can anyone review the methods? If there are better ways to write a certain method I would appreciate it if anyone could tell me. ...
5
votes
1answer
130 views

My first implementation of a linked list in C++

This is my very first implementation of a full-fledged ADT, which could potentially be use-ready. Now, I'm still learning, therefore I would like to ask you what I can do to further improve the ...
2
votes
0answers
50 views

Generic Unrolled Linked List with IList<T> interface implementation

I was inspired by the Phillip Trelford "Beyond Lists" presentation published on InfoQ. So, I decided to make it simple, yet still capable to act as IList<T>. ...
0
votes
1answer
40 views

Detecting cycle in LinkedList

Is this a fair/clean way to detect a cycle in a LinkedList? Should work for both single and double LinkedLists'. ...
1
vote
1answer
30 views

Generic LinkedList with add/exists/delete/dlear/iteration functionality

I've just been going through core data structures and algorithms recently, wanting to get back in touch with the core fundamentals. I'm starting simple with a ...
5
votes
2answers
164 views

Single Linked-List Implementation in C++

I haven't done much C++ coding the last few years, so I've been reviewing in preparation for upcoming interviews. I wrote a minimally functional singly linked-list. I'm using my implementation for ...
0
votes
2answers
32 views

Singly linked list abstraction in ES5 JavaScript

Below is the code for, Singly linked list implementation, ...
4
votes
3answers
98 views

Check for palindrome in singly linked list

Looking for code review, optimizations and best practices. Node.java ...
5
votes
2answers
90 views

Doubly linked list of strings

This code works just fine as I get the correct output. However I want to make my code more simple. I want to avoid using the setPrev(Node n) method and would rather ...
2
votes
2answers
87 views

A linked list with push pop append and destructor

I tried to implement a linked list that can do pop(), push(), append(), printall(), and so on, and also I tried to handle the wraparound features, and de-wrap it when check if the list is cyclic to ...
2
votes
2answers
141 views

C++ Generic Linked List

My goal is to write a reasonably robust c++ linked list class. The current code represents the latest phase in this attempt. My future goal is to implement a doubly linked list along with more member ...
4
votes
2answers
45 views

Copy Constructor for a linked list with self-referential pointers

I came across a coding challenge that looked something like this (recreating from memory, sorry) Suppose you have the following interface for a linked list. Implement an efficient and correct ...
3
votes
2answers
77 views

Stack and Queue implemented with a LinkedList

I am looking for feedback on my implementations of Queue, Stack, and LinkedList using Java ...
3
votes
2answers
263 views

Small improved std::list to manage doubloons and pointers

I am extending std::list in order to have access to convenience member functions that simplify my everyday developments (e.g. ways to deal with doubloons, delete ...