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
2answers
39 views

Swap Kth node from beginning with Kth node from end in a Linked List

Given a singly linked list, swap kth node from beginning with kth node from end. Swapping of data is not allowed, only pointers should be changed. This code is attributed to geeksforgeeks. I'm ...
1
vote
3answers
96 views

Alternating split of a given singly linked list

Write a function AlternatingSplit() that takes one list and divides up its nodes to make two smaller lists 'a' and 'b'. The sublists should be made from alternating elements in the original list. ...
3
votes
4answers
295 views

Delete duplicates from unsorted linked list

E.g: if a linked list contains 2->3->1->3->4 then the result should be 2->3->1->4. Notice that 3 has been eliminated. This code is attributed to GeeksforGeeks. I'm looking for code-review, ...
2
votes
2answers
50 views

Find a triplet from three linked lists with sum equal to a given number

Given three linked lists, say a, b and c, find one node from each list such that the sum of the values of the nodes is equal to a given number. For example, if the three linked lists are ...
4
votes
4answers
206 views

LinkedList to be used in a stack or queue

This all works. Just wanted to make sure I didn't miss anything. Coming from C++ and working my way through Algorithms, 4th ed. Here is my LinkedList class: ...
3
votes
3answers
79 views

Delete alternate nodes of a linked list

If the linked list is 1->2->3->4 then the output should be 1->3. If the linked list is 1->2->3->4->5, then the output should be 1->3->5. The question is attributed to GeeksForGeeks. I'm looking ...
1
vote
0answers
21 views

Extract Leaves of a Binary Tree in a Doubly Linked List

Given a Binary Tree, extract all leaves of it in a Doubly Linked List (DLL). Note that the DLL need to be created in-place. Assume that the node structure of DLL and Binary Tree is same, only the ...
3
votes
4answers
981 views

Given only a pointer to a node to be deleted in a singly linked list, how do you delete it?

Example: If a linkedlist list contains 10->20->30->40, and 2nd node has to be deleted then the output should be 10->30->40 This question is attributed to Geeksforgeeks. Looking for code-review, ...
0
votes
2answers
41 views

Is this circular linked list better than the fast & slow pointer method?

I have a faster way to find if a list is circular linked list, in contrast to the solution that Cracking the Coding Interview has offered: In the below algorithm, ...
0
votes
3answers
53 views

Linked list vs array performance for RemoveAt() function [closed]

I am trying to compare the RemoveAt() function performance in an array and linked list. For array: ...
1
vote
1answer
39 views

Delete nodes in linkedlist whose next node is greater

Given a singly linked list, remove all the nodes which have a greater value on right side. Examples: a) The list 12->15->10->11->5->6->2->3->NULL should be changed to ...
1
vote
1answer
37 views

Find union and intersection of linked list

Find the union and intersection of linked list, given that elements don't repeat in a single linked list. This question is attributed to GeeksForGeeks. Looking for code-review, optimizations ...
0
votes
0answers
34 views

Convert a doubly linked list into balanced binary search tree in-place

Given a doubly linked list which has data members sorted in ascending order, construct a balanced binary search tree which has same data members as the given doubly linked list. The tree must ...
4
votes
3answers
159 views

Dictionary load function using hash table

This loads a dictionary text file into memory to be used as part of a spell checker. It's part of a larger program, but I wanted general comments so I can clean it up further. ...
6
votes
2answers
104 views

Flatten a multilevel linked list

Given such a structure the output should be ...
0
votes
1answer
75 views

Add two numbers represented by linkedlist

Given two numbers represented by two linked lists, write a function that returns sum list. The sum list is linked list representation of addition of two input numbers. It is not allowed to modify the ...
3
votes
1answer
47 views

Simplifying linked list “search and delete” function

The function asks the user for a value to search for, then deletes all matching values in the list. The program runs flawlessly, but I can't figure out a simple/elegant way of separating cases for ...
1
vote
0answers
29 views

Following-up “given a two dimensional linked list, create a flattened sorted list”

A node has a next and down pointer. Merge the linked-list such that end result is sorted. Here we have a top level linked-list, followed by a down-list. If { 10 : {20, 30} , 35 { 40, 50 } ...
2
votes
0answers
37 views

Deleting nodes having greater value on right side

Problem Summary: Given a singly linked list, remove all the nodes which have a greater value on right side. Example: The list 12->15->10->11->5->6->2->3->NULL should be changed to 15->11->6->3->NULL. ...
6
votes
1answer
84 views

Merge two linked list

Given two linkedlist, merge them. Looking for code review, optimizations and best practices. The code is influenced by feedback here. Changes incorporated were: Linkedlist is no-longer write-only ...
0
votes
1answer
38 views

Implementing a bubble sort on a linked list [closed]

I'm using the following prototype: Data* bubble_sort(Data *list); I'm trying to implement a bubble sort given a linked list of names. Note: this returns ...
0
votes
3answers
128 views

Given a two dimensional linked list, create a flattened sorted list

A node has a next and down pointer. Merge the linked-list such that end result is sorted. Here we have a top level linked-list, followed by a down-list. If { 10 : {20, 30} , 35 { 40, 50 } } is the ...
4
votes
3answers
137 views

Repeatedly skip M nodes then delete N nodes then skip M nodes and so on

Given a linked list and two integers M and N. Traverse the linked list such that you retain M nodes then delete next N nodes, continue the same until end of the linked list. Input: ...
1
vote
1answer
59 views

Sort a linkedlist with 3 elements 0, 1 and 2

Given a linked list of 0s, 1s and 2s, sort it. Looking for code review, optimizations and best practices ...
8
votes
3answers
703 views

Doubly-Linked Circular Linked List

I'm a C++ programmer learning Java in preparation for an OOP class this fall. That being said, Java is fairly new to me so I'd love to hear feedback on how to improve this code. A few notes: Code ...
5
votes
3answers
139 views

Linked list with iterators

This is my second linked list implementation for review. I rewritten pretty much all of this and have added iterators, sentinels and The Rule of Five. Please let me know what's wrong with it; I am ...
0
votes
2answers
76 views

Reverse a doubly linkedlist

Reverse a doubly linkedlist. Looking for code review, optimizations and best practices. ...
11
votes
3answers
552 views

Linked list implementation correctness

I've started learning C++ and I wanted to ask you to take a look at my linked list implementation and give comments what's wrong with. It compiles and runs fine, but I am curious about const ...
4
votes
2answers
109 views

Implement queue using linkedlist

Implement queue using linkedlist. Looking for code review, optimizations and best practices. ...
4
votes
1answer
41 views

Implement stack using a linked list

I am trying to implement Stack using a linked list. Looking for code-review, best practices and optimizations. ...
6
votes
1answer
80 views

Flatten double-linked list

Consider this interview question: Given a Node with a reference to a child, its next, its previous, and a variable for its value (\$\frac{1}{2}\$ tree, \$\frac{1}{2}\$ doubly linked list ...
10
votes
1answer
167 views

Tweets per second, using linked list

This is a TalentBuddy Challenge Your task is to write a function that prints to the standard output (stdout) the highest number of tweets recorded between each second in the array and the past ...
12
votes
6answers
2k views

Implementing a Stack in Java for Technical Interview

This code is based off the Stack implementation in Chapter 3 of Cracking The Coding Interview. I modified the code to make it compile and give me the correct output. I'd appreciate any feedback on ...
2
votes
1answer
36 views

v2 - Adding a duplicate entry randomly into a list in haskell using random monad

Next version of Adding a duplicate entry randomly into a list in haskell using random monad I wrote this trying to set up a Haskell testcase. The aim is to take a list and add a single duplicate from ...
2
votes
2answers
103 views

Pointers for struct and `for`

I know something about pointers, but I'm trying to check my knowledge on a sample. Can somebody check if my code is good? I don't think that I should use pointers in these ...
1
vote
1answer
171 views

Convert sorted linkedlist into balanced binary search tree

Convert a sorted linkedlist into a balanced binary search tree. Looking for code-review, optimizations, and best practices. ...
3
votes
1answer
102 views

Lock-free queue with doubly linked list correctness

I need a lock-free queue which is implemented by doubly linked list. Is my code correct? Are there any errors? Are there any improvements to be made? linkedlist.h ...
10
votes
3answers
107 views

Dynamic library to intercept oddsock hostname lookups

Just for the fun of it, I decided I would try to create sort of an intermediate DNS system for the oddsock SOCKS proxy. With this, the domain name extension .unet is statically resolved when ...
4
votes
2answers
86 views

Reverse sublists of a linked list

This code reverses each consecutive n elements of a linked list, and for spare nodes, leaves them as they are. For example, the linked list 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 for an interval of 3 ...
2
votes
1answer
65 views

Swapping adjacent nodes of a linked list

I just have a small question. The code I wrote works well for the problem. But is it the best way, or can we make it better? ...
5
votes
5answers
465 views

Implementing a set using a linked list

My task is to add the specified element to the linked list if it is not already present ...
2
votes
1answer
45 views

Implementation of the undef function

Write a function undef that will remove a name and a definition from the maintained by lookup and ...
10
votes
3answers
735 views

LinkedList implementation implementing the List interface in Java

So here it is, my linked-list implementation in Java. I have coded against Java's List<E> interface as if my ...
10
votes
1answer
554 views

Bubble Sort in C: Array vs Linked List

A few weeks ago I posted a code review of a linked list so I decided to implement bubble sort on my journey of learning C. Here is the referenced linked list library, though this isn't really what's ...
4
votes
2answers
331 views

Singly linked list implementation

I feel like there is room for improvement in the push/pop methods. Any suggestions? ...
4
votes
2answers
140 views

3-class linked list

I am trying to make a linked list using 3 classes, however I cannot find ANY information online about it, and I can't seem to figure it out myself. If you could please correct and explain what I am ...
7
votes
2answers
131 views

Linked List reversal

Recursive version. The only interesting function: ...
19
votes
1answer
326 views

Stack implemented using linked list in x86_64 assembly

I wrote a stack implementation using a singly linked list in x86_64 assembly. This stack supports the usual push/pop operations ...
11
votes
1answer
254 views

Linux NASM assembly linked list implementation

Inspired by all of the lovely linked lists lately, I decided to implement one in assembly language. This code maintains two linked lists - one is a free store and the other is the active linked list. ...
5
votes
3answers
361 views

Singly-linked grocery list

For my own linked list implementation, I've decided to try something different: a linked list of groceries. The main differences between this implementation and a standard list are: more data ...