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

0
votes
0answers
7 views

Implementing a Trie in Python using lists alone

I've been working on implementing a Trie in Python for educational purposes. I tried implementing one using dictionaries and I was successful; find below my attempt at implementing a trie using lists ...
8
votes
4answers
203 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 ...
5
votes
1answer
92 views

Edge cases for simulated malloc function

I'm trying to simulate the malloc function in C by using mmap and having 2 linked lists to act as memory blocks. The program ...
5
votes
4answers
447 views

C Doubly Linked List

It works, but it seems a bit long winded. I'd like some critiquing. ...
0
votes
2answers
55 views

Using recursion to count nodes in a binary tree, test equality of linked lists, and find extrema of a linked list

I am working with a some small functions to test recursion. I am fairly new to Python and am wondering if there is a cleaner way to get the job done. ...
2
votes
0answers
44 views

Reverse every k nodes of a linked list [closed]

Given a linked list and a number k, Reverse every k nodes in the list. Input: 1->2->3->4->5->6 and k = 1 Output: 2->1->4->3->6->5 How can I ...
1
vote
2answers
70 views

Reverse linked list using recursion

Here is my code to reverse link list in using recursion: ...
2
votes
0answers
40 views

Simulating a linear linked list using an array

A program to simulate a linear linked list using an array: Specs: A y : Create a new node with data value y, and append this node to L I x y : Find the node t with value x, create a new ...
3
votes
0answers
29 views

JavaScript Doubly Linked List

I coded up a basic DLL for use in a Stack or a Queue in JAvaScript for practice. Coming from a C++/Java background so I basically just converted how I would code it up in one of those, not sure if ...
2
votes
0answers
54 views

Linked list order reverse program efficiency

Here is my function which convert linked list in the following order: Example: Inputs: 1->2->3->4->5->6->7->8->NULL and k = 3 Output: 3->2->1->6->5->4->8->7->NULL. Code: ...
3
votes
2answers
45 views

Functional-style linked list written in C

For my Operating Systems class, I needed a linked list data structure and didn't have one already written. During the course of thinking about how to implement a linked list again (it had been a ...
1
vote
1answer
31 views

Make a new design of Stack with a new function

I am doing some coding exercise, and I am not sure if I have met the requirement. Can someone help me to figure it out? How would you design a stack which, in addition to push and pop, also has a ...
5
votes
1answer
48 views

Self-made LinkedList and Node

I have recently made two kinds of linked lists in Java. I know that there is one with generic and one without. However, what I am really concerned about is which style should be used mostly (or which ...
5
votes
2answers
120 views

Data structure to count occurrences of entries

I would love to hear any thoughtful suggestions on how to improve my programming style in order to be more understandable. Listed below is a sample of my code which I wrote in Eclipse: ...
5
votes
3answers
145 views

Optimize huge text file search

I have several huge 100MB text files that I need to scan through to pick out certain frame numbers which relate to a specific log packet of interest. My plan was to scan for these frame numbers and ...
4
votes
1answer
60 views

Design/reiterate or code reuse for linked list

This is what my class hierarchy looks like. I have an abstract superclass, AbstractLinkedMyList, that contains common operations for both sorted and unsorted linked ...
2
votes
1answer
61 views

Circular Queue using Linked List

I want to create a circular queue using a linked list. I also want to create many instances of that data structure (queue) without repeating the code. This is what I came up with: ...
3
votes
1answer
39 views

Returning the next node

What is considered to be a good programming practice for returning value from the function? For example, if we have a function in C named ...
2
votes
1answer
59 views

Rewriting linked list function without a NULL variable

This is how my LinkedList class looks like in PHP. I am trying to figure out if I can rewrite my reverse_list_recursively() ...
4
votes
1answer
20 views

Zip / merge two linked lists together

The following code interweaves two linked lists together in three flavors: iterative, recursive top-down, and recursive bottom-up. My iterative solution feels like it can be optimized better and my ...
3
votes
3answers
87 views

Implementing a singly LinkedList and IList interface

I have implemented a LinkedList in C#. What would you change/make better? What naming conventions are misused? What would you add? Some of my ideas are to make it ...
4
votes
1answer
75 views

Circular linked list in C

Let me know if it seems right to you and if anything can be optimized. My concern is that I'm unsure if circular linked lists are supposed to have a tail. I've implemented it just using a head. Is ...
2
votes
2answers
70 views

Doubly linked list code in C

Let me know if it seems right to you and if anything can be optimized. ...
1
vote
2answers
55 views

Sort and display input numbers

How do I decrease time, especially in sorting? Given a list of numbers, you are to sort them in non-decreasing order. Input t – the number of numbers ...
6
votes
3answers
96 views

Removing duplicates without using a temporary buffer

This question is from Cracking the Coding Interview and in this question they have asked to solve without using temporary buffer. I have used Iterator interface. Can I use it or need to re-implement ...
3
votes
2answers
100 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 ...
3
votes
1answer
83 views

Convert binary tree to doubly linked list

The code works and I get the results I want. Please comment about complexity, a shorter way of implementing the solution, and advice for better unit tests. ...
0
votes
2answers
80 views

Split a Map into sublists

I may get a Map of many many items that needs to be requested to an API. In order to improve performance, I thought about splitting that list into smaller ...
2
votes
1answer
97 views

Deep copy linked list with arbitrary nodes

The original question can be found here. I implemented method 2: Please comment about style, unit testing, code complexity, time and memory space and complexity. ...
12
votes
2answers
113 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 + ...
8
votes
2answers
101 views

The benefits of sentry in a linked list

I'm trying to put together a little tutorial to demonstrate the benefits of using a sentry node when creating a linked list. Target audience is novices that already tried to make a linked list. Any ...
1
vote
4answers
101 views

Is this the right way to delete a node?

This is how I am deleting a node from a singly linked list. Would this be the most correct way? ...
2
votes
1answer
35 views

Simplifying linked list insert_after

Is there a better way to insert after a node in a linked list? Currently I go through the node from the head of the list and find the node that has the value pos. ...
5
votes
1answer
62 views

TrackDAO: what can be improved?

In this specific situation there is a table with trackdata and a form to add rows. For the sake of clarity I won't include the view-related code here. The added rows are added to a LinkedList when ...
2
votes
1answer
51 views

Form a loop with previous and next

I have a class Edge which looks something like this: class Edge { Edge previous; Edge Next; } I have edges in an ...
3
votes
2answers
80 views

First Linked List in Java

I just started learning Java, and wrote up a linked list. I'm coming from just having learned Haskell, so I've been out of the mindset of stateful computations for awhile. I'd like to know how it ...
0
votes
2answers
151 views

Is this implementation of doubly linked list correct?

I am trying to follow the template provided here to create a doubly linked list in java. This homework is based on this lecture. Can someone please review my implementation? No change to this part of ...
3
votes
1answer
110 views

Removing duplicates from unsorted LinkedList

Removing Duplicates: ...
2
votes
1answer
64 views

Implementation of a singly linked list

I wonder if the code below is a good (quality and correctness) implementation of a single linked list in C++, in regard of data structure (not the exposed interface). ...
1
vote
1answer
55 views

Using composition or inheritance to enhance this linked list

Problem Statement: A method called insertEnd() exists, but it runs in linear time, because every time it is called, it walks down the list to find the end. Without changing the meaning of this ...
1
vote
1answer
88 views

Creating an insert at front function for a circular doubly linked list

I have only been working with C for a couple of months and I think I have a pretty good function to insert a node in the front of the circular doubly linked list. I have tested in adding several ...
6
votes
2answers
103 views

Immutable Linked List in VBA

I made an immutable list class using the head-tail idiom. If I did this correctly, it implements persistent data structures. Unfortunately it doesn't scale well ...
2
votes
1answer
237 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 ...
4
votes
2answers
101 views

Optimizing squish() method further

Part II of this question says: Fill in the squish() method in the SList class so that it performs as indicated in the ...
8
votes
3answers
288 views

Linked list C implementation

I'm reading a data structure and algorithm book in C. I have implemented a generic single linked list in the C programming language, and I want to know your opinion on my implementation: ...
6
votes
3answers
116 views

Singly Linked List Implementation in C

I'm preparing for an interview soon, and I've written the following linked list implementation from scratch. This is all self-taught, and I'm still working on my C. I feel that the implementation is ...
7
votes
2answers
314 views

Linked list implementation of a stack

I am working on a basic linked list implementation of a stack of ItemType (currently set to double but can be changed) values. The stack code will then be used in a ...
1
vote
1answer
39 views

Self-made linked list implementing List<E>

I have to make a linked list as a quasi-homework task, about which I have already asked two questions about here and here. Since the whole code is really big (400 lines approx.), I will include only ...
5
votes
3answers
773 views

Custom linked list implementing Iterable used as stack

I have created a custom linked list that implements the Iterable interface. I am then using this linked list to implement my custom stack. I have also thrown a ...
8
votes
2answers
139 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 ...