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
32
votes
3answers
85k views

LinkedList with Node implementation

Below is my implementation of templated Node and LinkedList classes. I would really appreciate it if someone would give me ...
28
votes
4answers
4k views

Validity of doubly linked list

I am currently in a data-structures class. The professor will be providing a singly linked list. I wanted to make a doubly linked list to "learn" how to do it. I tested it and I think it works. After ...
27
votes
2answers
46k views

Custom iterator for a linked list class

I have made a LinkedList class. This is a singly-linked-list and I want to make a forward_iterator for this class without using ...
25
votes
1answer
2k 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 ...
22
votes
7answers
69k views

Singly Linked List in Java

I created my own implementation of a Singly Linked List. Is there anything I can improve on, in terms of effciency. Also, what other methods would you recommend for me to try and implement. My goal is ...
19
votes
5answers
9k views

Linked List in C#

I was searching for a implementation of a Linked List with the same power as a native List. I wanted functionality closer to a ...
19
votes
3answers
3k views

Reversing k-sized sequences in a linked-list

Here is my solution to this problem; please be brutally honest/strict, if I would have written this code, in a 45 minute interview, what would you think? (I am aiming for Google,Facebook). Here is ...
18
votes
5answers
4k views

Self-made Linked List

I was tasked by my teacher with making a linked list by myself, so I could understand the concept better. Here is the MyLinkedList class: ...
17
votes
3answers
4k views

Python code that sorts books

I am currently a student just starting to learn python and I need help improving my code for a school assignment. I've already written the code for the program, just need suggestions on how to improve ...
16
votes
6answers
34k views

Implementing a Stack in Java for a 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 ...
15
votes
3answers
2k views

Simple Linked List

I've implemented a simple linked list in C# using generic T for values. I did not inherit from any of .Net's fun and helpful classes like ...
14
votes
5answers
3k views

Linked list in Python which gets values from keyboard

What do you think about my implementation of linked list, which gets values from keyboard? I implemented three basic functions: print, insert and size. ...
14
votes
3answers
17k views

Implementing a proper linked list for a professional environment

I have some concerns: Is it normal for the class to have at least one node? In other words, this implementation cannot have an empty linked list; the length is always 1. Would this be a proper way ...
14
votes
2answers
113k views

Stack implementation using linked list

This is a working stack implementation using a linked list. I'm just curious to know if this is a good way of doing it. Any suggestions are welcome. Can we keep track of the number of elements in ...
14
votes
2answers
2k views

LinkedList (doubly) implementation

CKLinkedList is the implementation of a doubly linked list. I'd like to see comments on the memory management (I'm using ARC in the code below) and formatting + ...
13
votes
2answers
24k views

Self-made linked list iterator

I recently made a linked list for myself, the code of which was posted here, if anyone would be interested. Now, as the next task, I had to make an Iterator for my ...
13
votes
1answer
3k 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. ...
12
votes
6answers
30k views

C function to find and delete a node from a singly linked list

I'm looking for the most commonly used style for writing the delete_item() function of a singly linked list, that find a matching item and deletes it. Is what I ...
12
votes
4answers
2k views

Singly Linked list implementation in C++

How can I improve this code Please tell proper indentation and usage of camel-case. ...
12
votes
6answers
16k views

In-place reversal of a singly linked list

As suggested in The 2nd Monitor, I'd like a review of this in-place reversal of a singly linked-list: ...
12
votes
2answers
2k views

Templated doubly-linked-list

I've been wanting to revise what I knew on templated classes so thought I'd write a doubly linked list to practice. It works fine, so all is well and good on that front, but is there something I've ...
12
votes
3answers
3k 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? ...
12
votes
3answers
1k views

Doubly linked list with no apparent memory leaks

I've run my code through Valgrind and managed to not get any memory leaks based on the test code in main. I'm looking for things that I may not have thought to check for, and ways to improve my code ...
12
votes
3answers
726 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 ...
12
votes
1answer
3k 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 ...
12
votes
1answer
346 views

Chack miy spellang pleez

For my CS2 project, I am supposed to implement a spell-checker. It is supposed to follow the following: Prompt the user for the name of the file containing the dictionary of correctly ...
12
votes
1answer
6k 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 ...
11
votes
4answers
4k views

C++ Doubly Linked List Implementation

Does anyone have suggestions on how to improve this? Specifically: Am I passing and returning references correctly to prevent unnecessary copying? Am I using destructors and the delete keyword ...
11
votes
3answers
11k views

C++ Stack using template

I'm learning C++, so I wrote a stack with the help of templates. I'm wondering if there is anything I can improve or if I did something vastly wrong. Stack.h ...
11
votes
3answers
8k 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 ...
11
votes
3answers
9k 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 ...
11
votes
2answers
5k views

Always sorted list

In this list, each newly inserted element is put in its place in order using IComparer<T>. The implementation uses a ...
11
votes
3answers
4k views

Python linked list

This is my first attempt at making a singly linked-list class. Would this sort of implementation be sufficient for interviewing quality? ...
11
votes
2answers
1k views

Linked list arithmetic

I am practicing for interviews and I tried solving the problem on my own and got a solution. I was wondering how can I improve the performance and memory on this program? The problem performs ...
11
votes
3answers
70k views

Java code for Linked List

I've been practicing implementing a linked list from scratch. Can someone help review my code? ...
11
votes
3answers
135 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 requested....
11
votes
2answers
563 views

Learning pointers by implementing a basic linked list with tests

I wanted to learn about pointers and someone suggested that I give C a try, so I went through Linked List Basics from Stanford CS library, implemented some of the code (and tried to improve the code a ...
11
votes
3answers
13k 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 ...
11
votes
3answers
1k views

Unrolled linked list

I am interested in the performance tradeoffs of linked lists, standard lists and unrolled linked lists. This will depend on various factors including what operation is being performed (e.g. delete, ...
11
votes
3answers
3k views

Unit testing with a singly linked list

To hone my skills with C++11, I'm implementing a singly-linked list based on the requirements I found at this link. I've implemented code that supports the following subset of requirements from the ...
11
votes
1answer
2k views

Undo and redo functionality for a GTK+ program

I'm working on a small GTK+ program and I'm now implementing undo and redo capabilities. This is the code that I'm using to handle the different states. It's just a linked list storing the allocated <...
11
votes
1answer
413 views

OOP paradigm implementation of a Dictionary data model

Here is the implementation of interface Dictionary using chained hash table class HashTableChained. Despite item 22* saying ...
10
votes
5answers
6k views

Merge two already sorted linked list

This is code to merge two sorted linked lists. l1 and l2 are sorted. While calling the merge function via ...
10
votes
3answers
110k 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 ...
10
votes
2answers
2k views

Check if an element is present within a linked list

I am given a task to ask for a number and then check if it is present within a linked list or not. ...
10
votes
3answers
2k views

Linked list of bunny objects

The exercise is the bunny linked list exercise; the last beginner exercise from here. I'm looking for feedback on absolutely everything that could make me a better programmer: Syntax Optimization ...
10
votes
2answers
4k views

Yet another implementation of malloc() in C

I'm really curious to know someone else's opinion on this implementation. Specifically, I would be interested to know the way you would have implemented it. Here the list of issues I've found with in ...
10
votes
2answers
755 views

Remake of Java's doubly LinkedList

I've been learning to program in Java and I decided to implement a doubly linked list as practice and as a bridge project before going on to learn C++. I know Java includes a ...
10
votes
2answers
350 views

Implementing a linked list in C++

I am an experienced C# developer and started with C++ a few days ago. I implemented a simple linked list to play around with templates, iterators, pointers, references and stuff. What would ...
10
votes
1answer
287 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 <...