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

Sort a linked list with merge sort in C

This is my version of a linked list in C. The function mergeSort requires a reference to the first and to the last nodes, as well as the indices of the first and ...
-1
votes
0answers
12 views

Reverse of linked list not working with argument [on hold]

These are the reverse and display functions of the linked list. Correct output : ...
2
votes
1answer
46 views

Determine the index where two lists diverge

Background A class provides an API to determine the index where two string lists diverge. ...
6
votes
3answers
163 views

Stack with getMin method

This should implement a stack that has a \$O(1)\$ getMin method. I used an auxiliary stack. Please provide comments on my solution. ...
3
votes
3answers
146 views

Implementing sequence abstraction

Below is the code that implements sequence abstraction using type abstraction Sequence (in Java): ...
2
votes
1answer
34 views

Singly-Linked List In-Place Reversal

I've created a function in C to reverse a singly-linked list in place: ...
1
vote
1answer
23 views

Reading from file and storing as Linked List

This is the code I have: ...
1
vote
2answers
31 views

Univariate polynomial multiplication using Doubly Linked List

A univariate polynomial is a polynomial over a single variable, and in the following discussion when we say polynomial, we mean a polynomial in a single variable. You are given two polynomials ...
1
vote
1answer
29 views

Inserting nodes into a singly linked list based on size of number

Given a set of numbers insert them so that they are ordered ie. ...
5
votes
1answer
41 views

Tree list recursion from Stanford tutorial

I have found this appearing-to-be famous problem in Stanford tutorial about trees and decided to solve it. My solution appears to work great: ...
1
vote
1answer
41 views

Deleting node from LinkedList

I have this function to remove nodes that matches a certain criteria in the list. Initially when I wrote it, head node was not deleted if ...
5
votes
2answers
96 views

Kth to last element of a singly linked list

Find the kth to last element of a singly linked list Any comments? ...
3
votes
2answers
142 views

Delete an item from a linked list

I wrote this code to delete an item from a linked list. I checked it and it works, but I want to know if the logic could be written simpler or clearer. ...
3
votes
1answer
55 views

Remove odd valued nodes from linked list

The function remove_odd is to remove odd valued nodes (surprise!!) from the linked list head. The code is very long and cryptic but it seems to work. Please help ...
1
vote
2answers
50 views

LinkedList implementation (+Sorted)

I was recently learning about nodes and how they work in lists, and to test myself, I decided to write my own LinkedList ...
12
votes
1answer
135 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 ...
4
votes
3answers
249 views

Simple Linked List that holds an int

I am inexperienced in C++. I was able to get my LinkedList to be fully functional. I was hoping to get some feedback as to whether or not I followed bad practices ...
6
votes
2answers
386 views

C++ Linked List Implementation

I'm learning C++ and also about data structures, so I am trying to implement some. This is my linked list. I've included two different ways of getting the length of the list, with a ...
1
vote
1answer
23 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 ...
11
votes
5answers
742 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
2answers
154 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
511 views

C Doubly Linked List

It works, but it seems a bit long winded. I'd like some critiquing. ...
0
votes
2answers
95 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
48 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
83 views

Reverse linked list using recursion

Here is my code to reverse link list in using recursion: ...
2
votes
0answers
51 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
40 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
58 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
56 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
32 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
60 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
148 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
151 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
66 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
88 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
64 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
27 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
121 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
97 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
104 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
59 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
128 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
176 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
96 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
123 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
125 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
161 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
108 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 ...