How can I transform or copy an array to a linked list?
I need to copy an array to a linked list OR transform the array in a linked list. How this can be done in .NET (C# or VB)? Thanks ...
I need to copy an array to a linked list OR transform the array in a linked list. How this can be done in .NET (C# or VB)? Thanks ...
10 years ago I was shown a technique for traversing a linked list: instead of using a single pointer, you used a double-pointer. The technique yielded smaller, more elegant code by eliminating the need to check for certain boundary/edge cases. Does anyone know what this technique actually is? (Trying to remember, but cannot) ...
I have problems understanding why when I create two or more nodes (as shown below), the function void del_end()will only delete the char name[20] and not the whole node . How do I fix this problem without memory leak? #include <iostream> using namespace std; struct node { char name[20]; char profession[20]; int age; no...
I've been trying to figure out how to reverse the order of a doubly-linked list, but for some reason, in my function void reverse() runs while loop once and then crashes for some reason. To answer some questions ahead, I'm self-teaching myself with my brothers help. This isn't all of the code, but I have a display() function which prin...
I have written my own linked list implementation in C, and it works fine for storing values, but whenever I try to run through the list I get a segmentation fault. I'm not sure why the issue arises, and I spent a decent amount of time trying to run through the program myself but to no avail. Could you guys help me find the reason for the...
Is there any way to abbreviate the print() and toString() into one function in a Java linked list function or is there any explanation as to why someone would format this way? public void print() { System.out.println(this.toString()); } @Override public String toString() { String display = ""; LinkedList current = this; ...
I am planning to implement a bounded queue without using the Queue<T> class. After reading pros and cons of Arrays and LinkedList<T>, I am leaning more towards using Array to implement queue functionality. The collection will be fixed size. I just want to add and remove items from the queue. something like public class BoundedQueue<T>...
How to represent a two way(doubly) linked list? ...
I am creating a linked list function for homework that adds at any index except last, but I don't understand how to make a conditiontargetList.addToIndexAt(81,0); without sentinel nodes EDIT Okay, I fixed all of the problems, except for one. This time, the code runs the code states that the result is 81,0,0,0,0, which means that after r...
Hello, I have been working with a doubly linked list. Everything works OK with the exemption of the function that should add a copy of 'who' before 'whereX' [see code bellow]. Why is the function not working? void addNodeAt(Node *whereX, Node *who) { //copy Node *temp = (Node*)malloc(sizeof(Node)); temp->count = who->count;...
I'm having trouble reversing my doublely linked deque list (with only a back sentinel) in C, I'm approaching it by switching the pointers and here is the code I have so far: /* Reverse the deque param: q pointer to the deque pre: q is not null and q is not empty post: the deque is reversed */ /* reverseCirListDeque */ void revers...
Hi folks, I have defined a C#-class, that shall be the elements of a directed graph (basically a tree, but an element can have multiple parents - I do not know if there is a special name for that). Each element shall now all its children and all its parents. It exposes those lists as IEnumarable public interface IMyClass { public IE...
Hi, I have seen this in some book/ tutorial. When you pass in the head pointer (of linked list) into a function, you need to pass it as a double pointer. For eg: // This is to reverse a linked list where head points to first node. void nReverse(digit **head) { digit *prev=NULL; digit *curr=*head; digit *next; while(cu...
Hi again, I'm trying to create and maintain a sorted link list. Every new element should be inserted in a way that the list remains sorted. I have been able to code it but am not too happy with my code. Basically there are 4 conditions that need to be satisfied according to me and in my attempt to achieve all of them i think i have ma...
I have to implement a class Doubly-Linked List, but that doesn't have an empty head or tail node. The code listed below is what I have so far. I have no idea how to continue... The actual question: Write a program that implements a class Doubly-Linked List, but that doesn't have an empty head or tail node. Also, include a test program t...
I am continually writing a program to improve my knowledge of linked-lists and how they function. I was wondering if some of you could review my code and notice any faults that you may be familiar with, or any errors in general. The functions work for my test functions, but obviously, I have not tested every scenario possible. // Li...
Same question as this, only I'd like to do it in Hibernate (using grails if that matters). So the domain class looks like this class LinkedElement { LinkedElement precedingElement String someData } and I'd like to query all elements in their linked order (where the first LinkedElement has null as the precedingElement). Is this po...
I got the code from wikipedia for linked list ( http://en.wikipedia.org/wiki/Linked_list ). But it prints the result in reverse order (5 4 3 2 1 ). How to make this to print from begining ( 1 2 3 4 5). ...
Hi, I have a linked list samples: protected LinkedList<RawDataset> samples = new LinkedList<RawDataset>(); I'm appending elements to the list in thread 1 like this: this.samples.offer(data); And I'm retrieving elements from it in a second thread like so: public RawDataset retrieveSample() { return this.samples.poll(); } Wou...
Another data structure I wrote under interview conditions. It is essentially a generic linked list that tracks the head and tail of the list (probably just for academic exercise, in RL life you'd just use List). Does anyone see any possible flaws or optimizations? using System; using System.Collections.Generic; using System.Linq; using ...