linked-list

Problem printing out linked-list

I am trying to create my own datatype that is like a vector or an array. I am having troubles with my print function; When I go to print the list, it only prints the last item in the list. // LinkedListClass.cpp : Defines the entry point for the console application. #include "stdafx.h" #include <iostream> class Node { public: int va...

Template argument missing for boolean operator?

I'm currently creating a circular doubly-linked list as exercise. The exercise is templating the damn thing, which is proving to be quite a pain. After many, many, many error-removals I get more errors. I'd laugh at that, but I'm quite tired and exhausted now. Node.h template<class T> class Node { public: Node(T val) : data(val), n...

how to find that is there any loop exist in the link list using two pointers?

Possible Duplicate: How to determine if a linked list has a cycle using only two memory locations. hello i have been asked in an interview that how can i find a loop exists in a link list using only two pointers. i have done the following: 1) find the center of the link list each time 2) by iterating this at the end both th...

Linked list of timers in C

Hello people, I'm supposed to write a program with two functions: One function is responsible for building a data structure populated by a list of functions within a run (you get a function pointer) its run time (a few seconds after starting a given program running). You should know to operate the function, adding the data structure o...

How to store ordered items which often change position in DB

I need to be able to store a large list of ordered items in the DB. So far that's straight-forward: ID Position OtherFields 1 45 ... 2 4736 ... 3 514 ... ... In queries, I always need to get just a few items (filtered based on OtherFields) but in the correct order. Easy as well, putting an index on Position...

Flattening a doubly linked list with child lists - optimizations, feedback, possible modifications

Attached is a quick program written under interview conditions that is designed to flatten a doubly linked list with child links. I was wondering what folks thought and if there were some optimizations (or possibly another way of doing things) you could point out that I could learn from. Code is below - Test7 is the test of the flattenin...

Adding nodes to LinkedList<T> in foreach

Can I safely add nodes to LinkedList container inside foreach statement? Is there any difference if I used while loop? Or it is never allowed and can cause some problems? foreach(var node in myList) { if(condition) myList.AddLast(new MyNode()); } Will it always work? ...

What will be the complexity of the operation to remove an element from the end of the singly linked list ?

What will be the complexity of the operation to remove an element from the end of the singly linked list ? I have implemented linked-list in C. Here is the code for removing a element from the end of linked-list. Now my query is that how to calculate the complexity of this snippet. What are the factors involved. There are other operation...

Linked list problems

Possible Duplicate: Copy a linked list Hello stackoverflow! I am trying to learn more about linked lists so I am trying to create a function that deep copies a linked list. I've got this under control. The hard part is that the input list is going to contain nodes that reference other random nodes within the list. First probl...

Swapping Nodes on a single linked list

Since long back I have not used C or C++ ,so forget completely about Pointers. I'm familiar with C# and have written a basic version of this. Need to know whether I'm doing right/wrong? Input:Linked List a->b->c->d->e->null Output: Linked List b->a->d->c->e->null We have to write code such that memory position is swapped and not the n...

Need Exercise to solve based on Linear Linked List

I have completed implementing Operation of Linear Linked List using C, Now inorder to test my ability i need to solve some problems based on Linear Linked List, and there you people can help me by suggesting some problems/assignments ... I think there is nothing wrong in asking this type of help from my community members . ...

how to create intersecting linked lists in C#?

Hi, I'm trying to create 2 linked list with a common intersection node. As I see this is a very hot question in LinkedList to find the intersection node. I have written following code but it throws InvalidOperationexception. LinkedList<int> LL = new LinkedList<int>(); LL.AddFirst(5); LL.AddFirst(4); LL....

structure with linked-list memory dump

Hi, is there any standard approach which I've missed at school to dump C structure with nested linked lists on disk in reasonable way? What I don't want to do is: use protocol-buffers or any other like serializators, don't want to create JSON, XML or other I've few ideas: allocate accurate memory amount (or extend existing one) and...

How to merge two linked lists in O(1) time in c?

Given two lists l1,l2, show how to merge them in O(1) time. The data structures for the lists depends on how you design it. By merging I mean to say union of the lists. Eg: List1 = {1,2,3} List2 = {2,4,5} Merged list = {1,2,3,4,5} ...

What is the complexity of a circular doubly linked list using binary search?

Is it O(n log n) or O(log n)? ...

C code for XOR linked list

I have been trying to Implement XOR linked list and its operations but I have not been able to do it properly. Is it possible to implement it in C since XOR link list involves operations on addresses?? I would be very thankful if some actual working code is given. ...

please can some one help me explain linked list?

I have tried a lot to learn linked list.But all my efforts were wasted.Please can some one help me understand linked list by providing his/her own code?Thanks in advance. ...

About the linked list

Give the advantages and the disadvantages of Linked List in Data Structure. ...

Grid data structure

Usually ‘expandable’ grids are represented as list of lists (list of rows, each row has list of cells) and those lists are some kind of linked lists. Manipulating (removing, inserting) rows in this data structure is easy and inexpensive, it’s just matter of re-linking previous nodes, but when it comes to columns, for instance removing...

Java: Good algorithm for removing an element from a linked list?

I have a pretty basic question here. I am implementing a few operations on a linked list as an exercise. One such operation is removal: /** * Removes the element at index. * @param index * @throws IndexOutOfBoundsException If index is greater than the list's length. */ public void remove(int index) throws IndexOutOfBoundsExceptio...