linked-list

Single linked list

Hello, I have created a single linked list. Everything works fine. I just want to know if I have done anything potentially dangerous in my code. The code snippets I am concerned about is my push, pop, and clean-up. The parts of the code is just for user interaction so not really important (I posted anyway so that it was more clear in ...

How can I use a C linked list from Perl XS?

I writing programing with Perl and XS. I need to display and do some operations that use a linked list from C. How can I accomplish that? ...

linked list

Hello, I am creating a linked list as in the previous question I asked. I have found that the best way to develop the linked list is to have the head and tail in another structure. My products struct will be nested inside this structure. And I should be passing the list to the function for adding and deleting. I find this concept confus...

Generic Linked List for Delphi 2009

I was looking in Generics.Collections and noticed there was no linked list. Sure they are simple to make, but I thought it was odd there was not one (or I just missed it). Are linked lists just outdated when compared to new modern data structures, or is there a need for a general generic linked list? Does anyone know of one? ...

What is a data structure that has O(1) for append, prepend, and retrieve element at any location?

I'm looking for Java solution but any general answer is also OK. Vector/ArrayList is O(1) for append and retrieve, but O(n) for prepend. LinkedList (in Java implemented as doubly-linked-list) is O(1) for append and prepend, but O(n) for retrieval. Deque (ArrayDeque) is O(1) for everything above but cannot retrieve element at arbitrary...

Problems with a Linked List in C

I'm making a linked list (of structs) in C, but I want to be able to call a function and have it add 4-5 stucts to the list by itself. The problem is since in C all the variables created in functions are left on the stack/heap I have no clue how I am supposed to accomplish this. Here is a code example: struct listItem { int value; ...

Sorting two linked lists according to memory location

I need to merge two doubly-linked lists, but not by their values (the lists are not sorted). I want to obtain a single list that has all the nodes from the two, but in the order in which they appear in memory. Maybe this image helps more: http://img140.imageshack.us/i/drawing2.png/ Is there any algorithm (preferably a fast one) that ca...

Can I pass a linked list from a C# Web Service to a JavaScript function?

Hi, I've created a linked list class in my JavaScript code and then translated that code into C#. Right now I have a JavaScript function that calls a Web Service in order to get an array of names, the JavaScript onComplete function then takes that array and makes it into a linked list. Is there any way I can create the linked list i...

Do you use linked lists, doubly linked lists and so on, in business programming?

Are data structures like linked lists something that are purely academic for real programming or do you really use them? Are they things that are covered by generics so that you don't need to build them (assuming your language has generics)? I'm not debating the importance of understanding what they are, just the usage of them outside ...

Is the LinkedList in .NET a circular linked list?

I need a circular linked list, so I am wondering if LinkedList is a circular linked list? ...

Variable Persistence Problem (C)

Hello: I'm making a domino game and when the user adds a domino to the left, the domino is added but when the function exits the domino added is GONE. FYI: fitxesJoc (Link List) contains the dominoes of the game and is a pointer passed to the function (so that it lasts all the game) opcionesCorrectas (Domino) contains the correct cho...

Linked List: Is this solution good?

I was looking for a way to avoid starting from the head of the list each time I want to find a node, so I thought of assigning indexes to nodes, keeping a pointer to a random (not exactly random; see below) node and then finding the pointer that's closest to the index I want to find. Allow me to explain with code: // head and last are p...

How does one add a LinkedList<T> to a LinkedList<T> in C#?

One would think the simple code llist1.Last.Next = llist2.First; llist2.First.Previous = llist1.Last; would work, however apparently in C#'s LinkedList, First, Last, and their properties are Get only. The other method I could think of was llist1.AddLast(llist2.First); However, this does not work either - it fails because the first...

Simple C++ Linked List

I have plenty of previous experience with linked lists in Java, but I seem to have confused myself with this simple attempt in C++. I am getting a segmentation fault at runtime, which from what I understand has to do with assigning a null pointer, but I am at a loss for a solution. Edit: Thank you all for the very helpful responses. The...

What is an efficient algorithm to find whether a singly linked list is circular/cyclic or not?

How can i find whether a singly linked list is circular/cyclic or not? I Tried searching but couldn't find a satisfactory solution. If possible, can you provide pseudocode or Java? For Example 1 3 5 71 45 7 5 -stop , its a circular linked list ...

how can I find last node of a circular linked list whose size I dont know and the last node points to any other node except first node of the linked list?

how can I find last node of a circular linked list whose size I dont know and the last node points to any other node except first node of the linked list? ...

Print a simply linked list backwards with no recursion, in two passes at most, using constant extra memory, leaving it intact

You must print a simply linked list backwards: Without recursion With constant extra memory In linear time Leaving the list intact Added Later Two passes at most ...

Understanding double pointer in doubly linked list in C

Hi, I have an exam tomorrow and I was trying to understand this doubly linked list example that the instructor placed on the class website but I'm having a hard time understanding a bit of it... Here's the code: #include <stdio.h> #include <stdlib.h> typedef struct dl { int key; float value; struct dl *next; struct dl...

use operators in templates in c++

I am trying to implement a List class using pointers and am trying to implement a function LOCATE(T x) where T is for the template and returns the first position of the element x if found, else returns last position + 1. My functions code is template<class T> int List<T>::locate(T n) const { int size = end(); Node<T> * p = head_...

Duplicate a linked list

I wrote a method which creates a copy of linked list. Can you guys think of any method better than this? public static Node Duplicate(Node n) { Stack<Node> s = new Stack<Node>(); while (n != null) { Node n2 = new Node(); n2.Data = n.Data; s.Pu...