A linked list is a data structure in which the elements contain references to the next (and optionally the previous) element. Linked lists offer O(1) insert and removal at any position, O(1) list concatenation, and O(1) access at the front (and optionally back) positions as well as O(1) next element ...

learn more… | top users | synonyms

3
votes
2answers
108 views

Singly-linked List Library

This is sort of a follow-up to a post I created about 10 days ago, but I have completed the implementation: Designing function prototypes for a singly-linked list API in C. As I began to work on the ...
4
votes
2answers
154 views

Doubly Linked List Implementation C++, copy constructor and assignment operator

I have implemented a Doubly Linked List in C++. I have tested it and everything works as expected, but I am not sure if my copy constructor and assignment operator perform a Deep Copy. Can someone ...
2
votes
1answer
52 views

Designing function prototypes for a singly-linked list API in C

I am in the process of rewriting in C all the data structures that I learned about a few years ago to increase my understanding of data structures and the C language. The first one I'm doing is ...
-1
votes
1answer
56 views

Singly Linked List removeLast method implementation [closed]

Hi I am having a little trouble with the implementation for my removeLast method in my singly linked list class. public E removeLast() { E removed = null; if (first != null){ // if list not ...
2
votes
1answer
89 views

Critique Request: Reversing a singly linkedlist in java

I find the tail in the first while loop and store it in the tailEnd node. Then I update the tail to the previous node and change the tail.next to point to previous node. Once head.next.next == ...
5
votes
1answer
103 views

Simple trie implementation in JavaScript

After experimenting with a sorted trie implementation in C, I felt that I understood tries pretty well, but was having trouble explaining how they work. Since the C code was based on existing code, I ...
4
votes
4answers
166 views

General advice on a practice linked_list for C++ classes/templates

Introduction I'm learning C++ (Coming from Haskell, C, and Assembly - and other languages sparsely) and this was my practice with classes and templates. It's a linked list that you can call in this ...
1
vote
1answer
103 views

Sorted trie implementation in C

I wanted to store some dictionary data (key/value pairs of strings) in C, and decided to use a trie. I found what looks like a good implementation here, along with some nice notes. In this ...
3
votes
2answers
165 views

Singly linked list for review c++

#include <iostream> using namespace std; struct node_ll { int payload; node_ll* next;//Pointer to the next node }; void print_ll (node_ll** list) { node_ll* temp = *list;//Let temp ...
0
votes
1answer
43 views

Basic Linked list

I am learning C from K.N. King and at ch-17, I covered linked list and wrote a code to add data in the ascending order in the linked list which is opposite to found in the book (In the book, it store ...
1
vote
1answer
55 views

Queue implementation Doubly Linked List

Here is my implementation for a queue using doubly linked list: QUEUE-EMPTY if L.head == NIL return True else return False QUEUE(x): if L.head == NIL: x.prev = NIL L.head = x else ...
1
vote
1answer
111 views

Remove Nth Node From End of List

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

remove all nodes with same value in a linked list

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given 1->2->3->3->4->4->5, return ...
1
vote
3answers
145 views

remove duplicates from linked list

Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. The following is my code: ...
8
votes
3answers
284 views

Please review my exercise about linked lists

I'm learning C++ by myself and therefore I have no direct access to a mentor. This is the reason why I'd love if you guys could take the time to do a peer code review. I am very much aware, as per ...
1
vote
2answers
95 views

Partition a linked list arround an element

This is my code to partition a list into two parts according to a value. I.e. nodes smaller than value x should precede nodes larger than the value x. It seems correct. Any corner cases I am ...
1
vote
2answers
483 views

Ordered Doubly Linked List Insertion

I'm working on a school project right now. It's an ordered(ascending) doubly linked list. I just wrote the Insert operation on it but I feel like the way I wrote it isn't that great. void ...
3
votes
4answers
141 views

Simpler and faster code for reversing list?

I wrote this code for reversing a doubly linked list containing words in each node, which works perfectly fine. My teacher says the algorithm is difficult to understand and the code as a whole could ...
1
vote
1answer
2k views

Implemenatation of Binary search Tree

Written a code to implement BST. I would like a code review and any suggestions to make it better? #include<iostream.h> #include<conio.h> #include<stack> #include<queue> ...
5
votes
2answers
413 views

In Java, how to operate the sublists efficiently?

In my Java program, I need to operate on the sublists a of ArrayList or LinkedList often, like removing a sublist, comparing two sublists. For ArrayList or LinkedList, I didn't find any good APIs to ...
5
votes
3answers
1k views

Removing duplicates from an unsorted linked list

Does the code below look correct and efficient for removing duplicates from an unsorted linked list without using extra memory? An object of type Node denotes a LL node. void removeDuplicates() { ...
1
vote
1answer
175 views

Radix Sorting with using queue [closed]

I have been trying to finish a book, Problem Solving and Program Design in C. In that book, there is a chapter, Dynamic Data Structures. I have understood main parts of that chapter. But, I couldn't ...
9
votes
3answers
288 views

Reversing a linked list

I implemented reversing a linked list in iterative way, just by knowing we need 3 pointers and I have never seen a code before, when I coded. I ran this code and tested it, it works fine. Even for ...
7
votes
5answers
302 views

A simple unrolled linked list implementation

I tried to implement an unrolled linked list in C#. I only needed to add things and clear the whole list so I didn't implement IList<T> (I tried but it was getting too complex, so I postponed ...
0
votes
1answer
384 views

Reverse a linked list [closed]

Problem: create a linked list and reverse the list appending with '<-'. Example, if the linked list is [1,2,3,4,5,6], so the result is 5 <- 4 <- 3 <- 2 <- 1. Here is the code class ...
1
vote
2answers
271 views

Confusing program for reversing link List using recursion? [closed]

I was trying to reverse the link list using recursion and somehow I did it? But one think is bothering me how the head in the last line finally points to the element 4 (i.e. the first element after ...
2
votes
2answers
273 views

C++ Null Object design pattern in a linked list

I'm trying to create a doubly linked list using the null object design pattern. I've implemented four classes: a node abstract class, nullnode and datanode classes for the null node object and the ...
1
vote
4answers
3k views

Is this good code? Linked List Stack Implementation

I have used the following code for a stack implementation. The top keeps track of the topmost node of the stack. Now since top is a data member of the node function, each node created will have a top ...
8
votes
3answers
560 views

Linked list in C++

Could someone review my linked list code? Specificially, is the design to separate Node and actions to create linked list appropriate? template <typename T> class Node { public: Node() : ...