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

2
votes
1answer
35 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
21 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
69 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
60 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
66 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
51 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
85 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
90 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
86 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
100 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
96 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
91 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 ...
1
vote
1answer
61 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
54 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
71 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
58 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
131 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
70 views

linked list in c code

I have implemented linked list data structure in c. linkedlist.h ...
4
votes
1answer
80 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
110 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
46 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'. ...
0
votes
1answer
27 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
158 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
1answer
25 views

Singly linked list abstraction in ES5 JavaScript

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

Check for palindrome in singly linked list

Looking for code review, optimizations and best practices. Node.java ...
5
votes
2answers
85 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
79 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
136 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
44 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
75 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
261 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 ...
1
vote
1answer
51 views

Custom C++ STL-like doubly linked-list(C++11)

This is the link list I just created. It works fine for now, but would want to know if I could make it better. list.hpp ...
3
votes
2answers
83 views

Checking if a single linked list is a palindrome in C++

The following is my first try at this classical interview question. It is quiet different from the solutions Gayle Laakmann provides in her book, and in another question on stackoverflow, someone ...
2
votes
2answers
92 views

Linked list copy constructor

This is a working linked list that will be used as a vector. Instead of using dynamic arrays, I am using a linked list. I would like to see a more concise solution without utilizing the STL. ...
3
votes
1answer
91 views

Merging sorted linked lists - C++

Problem from hackerrank: You’re given the pointer to the head nodes of two sorted linked lists. The data in both lists will be sorted in ascending order. Change the next pointers to obtain a ...
2
votes
0answers
60 views

lock-free list performance

I tried to write a lock-free list in c++ unfortunately the performance compared to a std::list secured with a simple mutex is bad what do you think? Are there major performance or code-style issues? ...
2
votes
1answer
53 views

Custom OrderedLinkedList class with nested OrderedListNode class

Everything works with this program. It takes both Strings and ints, however, I feel like my add method is simply too verbose. Does anyone believe I can implement a shorter version of this, or is it ...
2
votes
3answers
100 views

Java Doubly Linked List Implementation

I recently submitted an implementation of a singly linked list and tried to apply some of the suggestions on this implementation. I decided not to implement the List interface as I only wanted to ...
8
votes
2answers
412 views

Java Singly Linked List Implementation

I've implemented a singly linked list in Java as a practice exercise and would appreciate a review. LinkedList.java ...
12
votes
3answers
1k views

Singly Linked list implementation in C++

How can I improve this code Please tell proper indentation and usage of camel-case. ...
0
votes
2answers
101 views

Double linked list c++

I'm trying to figure out double linked lists. I'm looking for any type of comments you might have for my code. Anything that will make it better. ...
4
votes
1answer
331 views

Time limit exceeded for java “insertion sort linked list”

I was working on LeetCode to practice myself with Java programming. I encountered a question about insertion sort a linked list. My code currently runs correctly, but it failed on an instance with ...
0
votes
2answers
158 views

Linked list with deep copy constructor

I've created a linked list template class which contains a copy constructor that performs a deep copy of the list. LinkedList.hpp ...