linked-list

How do I implement a Linked List in Java?

What's the best way to make a linked list in Java? ...

Sorting sets of ordered linked lists

I'm looking for an elegant, high performance solution to the following problem. There are 256 linked lists. Each list contains the same types of object that among other things holds a whole number that is used to define a sort order. All numbers across all lists are unique Each individual list is sorted in ascending order by these ...

Storing more than 1 data item at a single index in a linked-list?

I am trying to store more than 1 data item at a single index in my linked-list. All of the examples in my textbook seem to illustrate adding only 1 piece of data per index. I'm assuming it is possible to add more? For example, using the Collections API to store an integer I would do the following: LinkedList <Integer>linky = new Link...

I want to know more about LinkedList<T> .

Hi, I'm learning c# , and I reached the LinkedList<T> type and I still need to know more, like when should I use it, how do I create one, how do I to use it. I just want information. If any one knows a good article about this subject, or if you can show me some examples with explanation, such as how to create, how to add and remove, an...

Relative performance of std::vector vs. std::list vs. std::slist?

For a simple linked list in which random access to list elements is not a requirement, are there any significant advantages (performance or otherwise) to using std::list instead of std::vector? If backwards traversal is required, would it be more efficient to use std::slist and reverse() the list prior to iterating over its elements? ...

Where can I see the Sun Java source code?

I want to have a look at how Java implements LinkedList. Where should I go to look at the source code? ...

LinkedList remove method

What is a doubly linked list's remove method? ...

Python Linked List

What's the easiest way to use a linked list in python? In scheme, a linked list is defined simply by '(1 2 3 4 5). Python's lists, [1, 2, 3, 4, 5], and tuples, (1, 2, 3, 4, 5), are not, in fact, linked lists, and linked lists have some nice properties such as constant-time concatenation, and being able to reference separate parts of them...

Inserting a node into a linked list in constant-time?

I'm working on an assignment that is telling me to assume that I have a singly linked list with a header and tail nodes. It wants me to insert an item y before position p. Can anybody please look over my code and tell me if I'm on the right track? If not, can you provide me with any tips or pointers (no pun intended)? tmp = new Nod...

How do I create a Generic Linked List?

I am trying to use a Generic Linked List to hold some WorkFlow steps in my application. Here is how I'm persisting it to my database. OrderID  WorkFlowStepID  ParentWorkFlowStepID 178373    1                         NULL 178373    2                         1 178373    3                         2 I get this dataset back in a datareader...

When to use LinkedList<> over ArrayList<>?

I've always been one to simply use List<String> names = new ArrayList<String>(); I use the interface as the type name for portability, so that when I ask questions such as these I can rework my code. When should LinkedList be used over ArrayList and vice-versa? ...

Splitting a linked list

Why are the split lists always empty in this program? (It is derived from the code on the Wikipedia page on Linked Lists.) /* Example program from wikipedia linked list article Modified to find nth node and to split the list */ #include <stdio.h> #include <stdlib.h> typedef struct ns { int data; struct ns *next; /* p...

Binary Trees vs. Linked Lists vs. Hash Tables

I'm building a symbol table for a project I'm working on. I was wondering what peoples opinions are on the advantages and disadvantages of the various methods available for storing + creating a symbol table. I've done a fair bit of searching and the most commonly recommended are binary trees or linked lists or hash tables. I was wonderi...

When to use a linked list over an array/array list?

I use a lot of lists and arrays but I have yet to come across a scenario in which the array list couldn't be used just as easily as, if not easier than, the linked list. I was hoping someone could give me some examples of when the linked list is notably better. ...

How could i create a list in c++?

How can I create a list in C++? I need it to create a linked list. How would I go about doing that? Are there good tutorials or examples I could follow? ...

which one to use linked list or static arrays?

hi all I have a structure in C which resembles that of a database table record. Now when I query the table using select, I do not know how many records I will get. I want to store all the returned records from the select query in a array of my structure data type. Which method is best? Method 1: find array size and allocate first ge...

Algorithm to Find the pointer to the Node M Steps to Tail in a Singly Linked List

Suppose there is a singly linked list whose length is unknown. We want to find the node with M steps to the tail. For example, the singly list is like this: (A)->(B)->(C)->(X)->(Y) and M = 2. Then the output should be pointer to (C). When confronting this quiz, my first reaction is to traverse the singly linked list to get the length N...

How to determine if a linked list has a cycle using only two memory locations.

Does anyone know of an algorithm to find if a linked list loops on itself using only two variables to traverse the list. Say you have a linked list of objects, it doesn't matter what type of object. I have a pointer to the head of the linked list in one variable and I am only given one other variable to traverse the list with. So my...

How do I sort a linked list in sql?

I have implemented a linked list as a self-referencing database table: CREATE TABLE LinkedList( Id bigint NOT NULL, ParentId bigint NULL, SomeData nvarchar(50) NOT NULL) where Id is the primary key, and ParentId is the Id of the previous node on the list. The first node has ParentId = NULL. I now want to SELECT from the t...

Why can't I push this object onto my std::list?

Just started programming in C++. I've created a Point class, a std::list and an iterator like so: class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; std::list <Point> pointList; std::list <Point>::iterator iter; I then push new points onto pointList. Now, I'm needing to ite...