The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [linked-list]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
71 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)....
2
votes
2answers
107 views

My own expandable list

I wondered how an expandable list could be implemented. My first thought: You could create a class that has an array and you can create a new array each time the user wants to append an element and ...
2
votes
3answers
137 views

Singly Linked List in pure C

I recently learned about linked lists and here is my first try to write one in C. I know it's a lot of code, but I hope someone takes a look. Any tips memory allocation and improvements are welcome. ...
2
votes
4answers
180 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 ...
2
votes
1answer
90 views

Populate the list based on which datacenter code is running on

This is a follow on to : Efficiently detect datacenter based on server hostname and return the full path. I have a library which is running in different datacenters in production. I have three ...
2
votes
0answers
53 views

Faster k-shortest path algorithm in Java

In the \$k\$-shortest path problem, we are searching for (at most) \$k\$ distinct, shortest paths connecting two given terminal nodes. You can see the previous version here. This implementation, ...
2
votes
1answer
71 views

Printing heads of stand-alone lists

Please review my code to help improve its quality. ...
2
votes
1answer
664 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 singly-...
2
votes
1answer
509 views

Optimizing twin() method

Part III of this question says: Fill in the twin() method in the SList class so that it performs as indicated in the ...
2
votes
1answer
194 views

Generic Macro Generated Linked List in C

Generate a linked list of any type using macros. The linked list contains functions for adding and removing elements to both ends and also at the middle. You can also add elements relatively to a list ...
1
vote
1answer
492 views

Working C code dealing with lists: problem with memory leak

I have written a working code that generates a simple linked list of dates and associated holidays. I realize that I have a problem with memory leaking as I copy lists repeatedly, so I wrote a ...
1
vote
2answers
1k views

Check if a linked list is a palindrome in O(n) time and O(1) space

I liked this problem because there are so many sub-problems that are interview problems in their own right-- (reverse linked list, find midpoint) ...
1
vote
1answer
619 views

Delete node from singly linked list with tail pointer in C

I'm trying to implement a single linked list based on Linus' comments about double pointers. In my case I'm also using a tail pointer and I'm wondering if there's a better way to update the tail ...
1
vote
2answers
159 views

LinkedList Implementation in Java

Please review my implementation. I know there is already an implementation in Java, but I just wanted to come up with my implementation. Let me know if I can improve this. ...
1
vote
1answer
206 views

OOP paradigm implementation of a linked list

Can this code be improved from an OOP paradigm perspective? ...
1
vote
1answer
90 views

Revision-2 C++ implementation of a linked list

I have addressed all your comments in my previous post. C++ implementation of a linked list Can you please comment on, How efficient the code is? Am i using too much extra variables to implement ...
1
vote
0answers
59 views

Linked list implementation along with unit test - Round 3

Here are the changes I've made thanks to suggestions made by @vnp, and @Henrik Hansen. Here is the link to the previous code review: Linked list implementation along with unit test - Round 2 I've ...
1
vote
1answer
83 views

Linked List Interview Code methods, runtime, and edge cases

Refactored code here I want to write a very simple Linked List with only 3 methods Append, Remove and Print. This is not for production and is to be treated as code that could be used in an interview ...
1
vote
1answer
850 views

Rotating a matrix in Java

Introduction This program is about rotating a matrix. For example, let the matrix be abcde fghij klmno pqrst Now, after rotating two steps clockwise we will ...
1
vote
1answer
64 views

Rotating lists in linear time and constant space (Java) - follow-up

(The previous and the initial iteration.) After some critique, I found the way to keep the rotation operation also for java.util.Lists that do not provide random ...
0
votes
2answers
78 views

Singly Linked List Implementation (With Nodes)

This code was recommended to me by my dear friend Jon after I wrote an implementation using arrays. With his help, I managed to create a Singly linked List similar to std::vector using Nodes. ...
0
votes
2answers
3k views

C++ remove from singly linked list

I asked a similar question (C++ linked list) but I'd like to have this similar code reviewed. It's not the same code, just slightly different and with bugs fixed. The code takes the head pointer of a ...