Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

-2
votes
1answer
36 views

Deleting a node in Linked list [on hold]

For deleting a node in linked list I used 3 steps: 1)Finding the previous node of the node to be deleted. 2)Changing the next of the previous node.(to know what is next see my code it's fully ...
6
votes
4answers
306 views

Add Two Numbers given in Reverse Order from a Linked List

Problem Description You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add ...
1
vote
1answer
28 views

Generic Single Linked List with smart pointers follow up part 3

Okay, this will most likely be the last post I make for Singe Linked List unless significant revision is needed. This post following from here. Shout out to @hoffmale for showing me the ways of the ...
-1
votes
0answers
17 views

How to insertItemAfter in linkedlist java [closed]

so I wanted to insert an item after and this is my code for insertitembefore: ...
3
votes
2answers
50 views

A Stack Implementation In C

I've written a very simple linked list based stack implementation and was wondering if this is the standard way to do it in C. ...
8
votes
2answers
144 views

Modern C++ singly linked list

This is a rather minimal (though fully functional) implementation of a singly linked list. It supports \$\mathcal{O}(1)\$ front insertion and deletions, as well as \$\mathcal{O}(1)\$ random insertions ...
1
vote
2answers
61 views

Generic Single Linked List with smart pointers follow up part 2

This is probably the last time I will post this data structure that I have been working on. I have added in an iterator and const_iterator class (although I do not use them probably where I should be)....
5
votes
2answers
55 views

LinkedList class implementation in Python

I was solving this problem for implementing LinkedList and ListNode classes, and Insert and <...
0
votes
0answers
84 views

Reverse a linked list

I was given 15 minutes to write the code to reverse a singly-linked list. What do you think of the code style here? ...
5
votes
2answers
681 views

Remove the first value for a doubly linked list

You need to remove the first element which contains a given value from a doubly linked list. I created two solutions since I find the edge case of removing the first element to be problematic. So I ...
2
votes
4answers
122 views

Generic Single Linked List Using Smart Pointers Follow up

I am extending this post following from here. I made some of the changes that I could make in the previous post. Although, I have not been successful in creating iterators for my class. The reason ...
1
vote
3answers
73 views

Stack implemented with linked list

I have looked at some previous posts and changed my code accordingly. Do you have some suggestions about my current code? Here are my specific questions: What should ...
5
votes
4answers
137 views

Generic Single Linked List using smart pointers

I have decided to rewrite what I did here, following the suggestions to use smart pointers. I will rewrite the other data structures as well using smart pointers where appropriate. I just want to ...
4
votes
2answers
174 views

Doubly linked list std::unique_ptr template class implementation

Inspired by the talk of Herb Sutter in CppCon2016, I decided to make a doubly linked list using templates, smart pointers, and raw pointers (for back-pointers, having a cycle of ...
4
votes
2answers
111 views

Thread-safe cache using a linked list

Are the final templated functions allocate and deallocate thread safe? The Cache object is a ...
3
votes
1answer
58 views

C++ linkedlist with static next/prev pointers

I did huge review of linkedlist implementations and all of them include separate new call fornode part for entry, which has <...
2
votes
1answer
120 views

Insert and Delete at Head and Tail of Linked List in constant time

I am trying to write a Linked List implementation that can insert and delete at either head or tail in constant time. I think I have it working, but I was curious what improvements I could make to ...
3
votes
1answer
50 views

JavaScript circular linked list compatriot game

I found this question in O'Reilly Data Structure and Algorithm in Javascript: According to legend, the first-century Jewish historian Flavius Josephus was about to be captured along with a band ...
0
votes
2answers
29 views

Delete K nodes in a linked list having their data less than the next node's

The question is from here. Given two numbers N and K where N is the number of nodes and K is the number of nodes to be deleted, delete K nodes whose data is less than their next node's data. If no ...
3
votes
2answers
92 views

Generic Stack Data Structure Using Linked Lists Follow Up

I made a post that follows from this here. I made most of changes that I could understand from the following link, and here is now an update to that original post. I just want to see if there is any ...
1
vote
1answer
42 views

Fixed size double linked list in Scala

I have written a double linked list in Scala. The list should be fixed in size and items are always added to the head. if the list reaches max size then the tail is dropped. This is my code. I want ...
3
votes
2answers
68 views

Generic Double Linked List Follow up

This is a continuation from the previous post found here. I made most of the changes that was suggested. I just want to see if there are any additional changes I should make to my code. Here is my ...
4
votes
3answers
129 views

Sort a linked-list with only three distinct values

I am trying to solve this problem. The problem is to sort a linked list containing only 0s, 1s and 2s by changing their links. Sort a linked list of 0s, 1s and 2s by changing links Given a linked ...
0
votes
1answer
55 views

Subtract first and last nodes of linked list

Problem from www.interviewbit.com. Problem : Given a singly linked list, modify the value of first half nodes such that : 1st node’s new value = the last node’s value - first node’s current ...
5
votes
2answers
42 views

Doubly Linked List implementation with C

I realized that after nearly five years of programming and one year of actual being employed as a programmer professionally that I have never actually sat down and implemented a linked list from ...
7
votes
1answer
515 views

Check if a given linked list is palindrome

I am solving interview questions from here. Problem :Given a singly linked list, determine if its a palindrome. Return 1 or 0 denoting if its a palindrome or not, respectively. Notes:Expected ...
7
votes
1answer
105 views

Generic Double Linked List

I am a mathematician attempting to become proficient with C++. At the moment I am learning about data structures. I am trying to write a double linked list now from scratch with some help from online ...
1
vote
1answer
98 views

Linked List in x86 assembly(MASM)

Module 1: ...
3
votes
1answer
75 views

Creating a generic single linked list, follow up

This is a thread I started from here. I organized my code to make it more organized. Everything works well, but I have not made all the changes from the last link (namely namespace since I am exactly ...
5
votes
1answer
36 views

Custom Templated Linked List

I made a custom linked list implementation. I am trying to improve my coding style, any remarks or suggestions are welcome. ...
6
votes
2answers
222 views

Creating a Generic Single Linked List

This follows from a post I made here. I made changes according to the answer I accepted in the following link. I tried to make all the changes necessary that I could. I just want to see if there are ...
6
votes
3answers
586 views

Generic single linked list

I am a mathematician attempting to become proficient with C++. At the moment I am learning about data structures. I am tried writing a single linked list from scratch with some help from online ...
4
votes
1answer
162 views

Heterogenous persistent list in Rust

I have implemented a basic, but seemingly working, persistent (as in immutable), heterogenous list type in Rust. Here's the code: ...
3
votes
2answers
67 views

Python 2 Stack and LinkedList implementation

I'm currently implementing data structures and algorithms I studed in my college course. This is my implementation of a singly linked list and a stack. I would appreciate some feedback in terms of the ...
1
vote
1answer
91 views

Single Linked List - simple approach

I am a student, trying to learn C++11 and data structures. I would like to ask you to to review my code. I have spent some time and analyse similar questions on Code Review and it gave me basic idea ...
0
votes
0answers
40 views

Linked list stack with O(1) push, pop and max operations

I chose to implement the max stack with a linked list due to the guarenteed O(1) push and pop. Added the max. Just looking to see if this can be done any better or if there are any other improvements....
5
votes
2answers
79 views

LinkedList implementation in Python

I am currently reading through an algorithm book and trying to implement everything as I go. I am also learning python at the same time. This is my implementation of a simple linked-list. I am mainly ...
1
vote
2answers
89 views

linked list implementation attempt

The following is my attempt at writing a linked list that attempts to emulate the behavior of std::list. Any feedback would be appreciated. ...
7
votes
3answers
2k views

Doubly linked list class in C++

I would like some feedback regarding my doubly linked list implementation in C++. I have been programming in C++ for about a year and a half and consider myself fairly proficient in the language. I ...
1
vote
2answers
50 views

Check if an element is present within a linked list - follow up

This is a follow up question from here. I have revised my code as per the suggestions of peer reviewers. I still feel there is lot of scope for improvement in this code. ...
3
votes
1answer
53 views

Implement a simple Doubly Linked List

Purpose I've never implemented a DoublyLinkedList and thought it would be a good data structure exercise. I tried using outside resources as little as possible. I ...
4
votes
1answer
83 views

Stack implementation with singly linked list

The following is my implementation of a stack using a linked list. ...
3
votes
1answer
74 views

Generic linked list

I provided an answer to a question on SO about a generic linked list. I just had the curiosity of having my code peer-reviewed as I wrote the code specifically for the answer. That is, I have not ...
4
votes
1answer
332 views

Stack implementation using a singly linked list

I've implemented a stack using a singly linked list and would like to know if there are any things I could improve on. StackList.h: ...
2
votes
0answers
57 views

Iterator for custom List class

I have extended a custom list class I have been working on with a Iterator class. I have not used std::iterator as a base class as it will be deprecated in C++17. ...
5
votes
4answers
118 views

Yet another doubly linked list (follow-up)

I've integrated the feedback from my previous question "Yet another doubly linked list". In addition to that the list now uses the copy and swap idiom. It also has a very simple iterator to enable it ...
3
votes
2answers
109 views

List implementation

Appreciate your thoughts and feedback on my simple list implementation. I have the code on github with list and some googletests here (not sure why github changes the spacing to be so big) Some ...
4
votes
0answers
71 views

Persistent List with constexpr and pointers

I am trying to implement a linked list in C++, functional and persistent. Before looking into sample implementations, I tried to come up with my own as an exercise. I came up with two versions: One ...
2
votes
2answers
173 views

Swap Nodes in Pairs in singly linked list

Description: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only ...
0
votes
3answers
97 views

Remove nth node from last position in linked list

Description: Given a linked list, remove the nth node from the end of list and return its head. Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the ...