linked-list

Writing an equals() method for linked list object

血红的双手。 提交于 2020-01-17 04:27:11
问题 I'm having trouble with an equals(Object other) method within a class I'm building called LString . The class contains an object called LString that builds strings out of linked lists, and a few other methods. I'm working on two methods, compareTo() and equals() . The class is tested by running another file, called LStringTest , which outputs this error message: Running compareTo and equals tests (18 tests) Starting tests: .E.........E...E.E Time: 0.426 There were 4 failures: 1)

Double linked list in Fortran (type is not judged correctly)

人走茶凉 提交于 2020-01-17 03:40:12
问题 I would like to implement a generic double linked list in Fortran for saving codes, using PGI Fortran compiler version 12.10-0 in Mac OS X 10.8.2. Here is my prototype, including 3 files: ---> File 1: ! ---------------------------------------------------------------------------- ! Description: ! ! This module provides several basic data structures, e.g. double linked list. ! ! Authors: ! ! Li Dong <dongli@lasg.iap.ac.cn> - 2012-11-11 ! ---------------------------------------------------------

C - deleting node in doubly linked list

醉酒当歌 提交于 2020-01-17 03:22:18
问题 When I try to delete every other element in the list using the deleteinst method the method does nothing to the linked list and there are no errors. I'm really not sure why it's not working I've seen the same deleteinst method used in a different program. Maybe it has something to do with the pointers. If I run deleteInst(track.prev, &head); without the while loop the list still remains unchanged. Please let me know if you have any idea or need more info. Thank you for your time. int main() {

Ascending order in linked list in c

梦想的初衷 提交于 2020-01-17 03:02:27
问题 I am trying to do ascending order in linked list through change of links and addresses rather than value struct node { char name[30]; int percent; struct node *link; }; int main { clrscr(); randomize(); struct node *st; st=NULL; for(int i=0;i<7;i++) append(&st,random(101)); //Assigning random values to structure node->percent display(st); AscMarks(&st); //Changing the order of links and addresses to arrange them in ascending order printf("\nAscending order list...\n"); display(st); getch();

Ascending order in linked list in c

对着背影说爱祢 提交于 2020-01-17 03:01:05
问题 I am trying to do ascending order in linked list through change of links and addresses rather than value struct node { char name[30]; int percent; struct node *link; }; int main { clrscr(); randomize(); struct node *st; st=NULL; for(int i=0;i<7;i++) append(&st,random(101)); //Assigning random values to structure node->percent display(st); AscMarks(&st); //Changing the order of links and addresses to arrange them in ascending order printf("\nAscending order list...\n"); display(st); getch();

I don't understand how lastIndexOf method works in java

≡放荡痞女 提交于 2020-01-17 01:27:05
问题 I have to write a method called LastIndexOf that accepts an integer value as a parameter and that returns the index in the list of the last occurrence of the value, or -1 if the value is not found. This is the code I have but it doesn't return anything. To me it looks that it always is going to return -1 but I can't see it on the output because it doesn't print what the method returns. these are the values that list stores. list -> [2, 5, 7, 24, 5, 9, 13, 2] public class LastIndexOf { public

C++ Linked List Printing… I get the infinite loop

梦想与她 提交于 2020-01-16 19:07:29
问题 I used this in my main function but it's not working void LinkedList::TraPrinHead(const LinkedList& p) { Nodes* currentNodes = header->next; while( currentNodes != tail ) { cout << currentNodes->elem << " ----> "; currentNodes = currentNodes->next; } } I expect to print the whole list from this... but I keep getting the infinite loop. cout << currentNodes->elem << " ----> "; currentNodes = currentNodes->next; cout << currentNodes->elem << " ----> "; currentNodes = currentNodes->next; And even

C++ Linked List Printing… I get the infinite loop

穿精又带淫゛_ 提交于 2020-01-16 19:07:09
问题 I used this in my main function but it's not working void LinkedList::TraPrinHead(const LinkedList& p) { Nodes* currentNodes = header->next; while( currentNodes != tail ) { cout << currentNodes->elem << " ----> "; currentNodes = currentNodes->next; } } I expect to print the whole list from this... but I keep getting the infinite loop. cout << currentNodes->elem << " ----> "; currentNodes = currentNodes->next; cout << currentNodes->elem << " ----> "; currentNodes = currentNodes->next; And even

Manually sort a linked list in the C programming language

泪湿孤枕 提交于 2020-01-16 14:46:25
问题 How do you sort a linked list by name in a function in C? struct rec{ char name[20]; int nr; struct rec *nextRec; }; typedef struct rec Rec; /* synonym for struct rec */ typedef Rec *RecPtr; /* synonym for pointer */ void SortLinkedList(RecPtr *sPtr, int p_size);/* prototype */ int main() { RecPtr startPtr = NULL; /* filling upp the linked list... size = nr of nodes in list */ SortLinkedList(&startPtr, size); } void SortLinkedList(RecPtr *sPtr, int p_size){ int i, j; RecPtr tempPtr; RecPtr

Manually sort a linked list in the C programming language

放肆的年华 提交于 2020-01-16 14:46:12
问题 How do you sort a linked list by name in a function in C? struct rec{ char name[20]; int nr; struct rec *nextRec; }; typedef struct rec Rec; /* synonym for struct rec */ typedef Rec *RecPtr; /* synonym for pointer */ void SortLinkedList(RecPtr *sPtr, int p_size);/* prototype */ int main() { RecPtr startPtr = NULL; /* filling upp the linked list... size = nr of nodes in list */ SortLinkedList(&startPtr, size); } void SortLinkedList(RecPtr *sPtr, int p_size){ int i, j; RecPtr tempPtr; RecPtr