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
31 views

How should I write function to print a singly linked list in a reverse order?

I am preparing for interview and I want to write the function in the way that the interviewers will expect me to write. This is my solution: ...
5
votes
2answers
223 views

Remove Nth Node from End of Linked List

I am solving the well known problem Remove Nth Node From End of List: Given a linked list, remove the n-th node from the end of list and return its head. Assume that n is between 0 and the ...
3
votes
3answers
78 views

Implementation of a doubly linked list in Java

I'd like to improve this code. DoublyLinkList.java ...
3
votes
3answers
148 views

Is SList class an ADT?

As per the definition given in lecture, ADT is, With reference to this definition, I would like to call SList class an ADT following 6 invariants: Multiple ...
4
votes
1answer
254 views

Queue Implementation using a Linked List

For understanding the concepts, I've implemented the Queue data structures using a linked list. Is there anything to improve? LinkList.java ...
5
votes
4answers
140 views

Creating nodes for linked list in a while loop in C

I am trying to create nodes for a linked list in a while loop. The code works, but it is not very pretty. How would I get the same results the proper way? ...
6
votes
3answers
647 views

Stack implementation using a linked list

To understand the concept, I implemented the stack operations using a linked list. Please review the code and tell me your suggestions. Node.java ...
2
votes
2answers
56 views
3
votes
2answers
65 views

Merge sorting linked lists

This works as expected and I want to get this code reviewed so that I can improve my coding ability. I am concerned about readability and the quality of the code ...
0
votes
1answer
38 views

Possible memory issue in linked list program [closed]

I am trying to write a program which will count the occurrence of words in a paragraph. The logic I am following : I am using a linked list for the purpose. And I am searching sequentially - if new ...
5
votes
1answer
55 views

Simple Linked List with my own super classes and interfaces

I have provided a simple implementation of a linked list using my own super classes and interface. The implementation is for adding, deleting obtaining the size of thew list. I have not yet provided ...
0
votes
2answers
107 views

Josephus Problem in Java

Problem The Josephus Problem is a famous mathematical puzzle that goes back to ancient times. There are many stories to go with the puzzle. One is that Josephus was one of a group of Jews who ...
2
votes
2answers
51 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
122 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
343 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
59 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
241 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
90 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
1answer
57 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
1k 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
47 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
98 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
50 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
81 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
1answer
86 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
180 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
134 views

Flatten a multilevel linked list

Given such a structure the output should be ...
0
votes
1answer
105 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
51 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
1answer
41 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
2answers
63 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 ...
6
votes
1answer
94 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
50 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
140 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
140 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
71 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
806 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
161 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
83 views

Reverse a doubly linkedlist

Reverse a doubly linkedlist. Looking for code review, optimizations and best practices. ...
11
votes
3answers
562 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
147 views

Implement queue using linkedlist

Implement queue using linkedlist. Looking for code review, optimizations and best practices. ...
4
votes
1answer
51 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
96 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
180 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
39 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
327 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
131 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 ...