linked-list

I want to quick sort using linked lists

為{幸葍}努か 提交于 2019-12-11 15:21:43
问题 Write a function that takes two student record structures by reference and swaps all their contents except their next pointers. Use your functions to implement bubble sort algorithm to sort the linked list (do not use arrays). #include <stdio.h> #include <stdlib.h> #include <string.h> /*defined a structure for date of birth*/ struct birth{ int date; int month; int year; }; struct studentrecord{ char name[64]; struct birth dob; int height; float weight; struct studentrecord *next; struct

Slow Inserts Linked List multi-threading needed?

丶灬走出姿态 提交于 2019-12-11 15:13:07
问题 In the code bellow, I'm searching for ways to optimize the speed of insertions when dealing with Millions of inserts at the time. the code runs fine but is very slow when performing large amounts of inserts. I already tried some ideas but is always slow. I guess the solution is to use Multi-threading to perform the inserts, and use a global variable "truct Node* nodeObj". I have very few/no experience with Multi-threading and Synchronization in C, C++, If you could give me an example based on

Template error : undefined reference

最后都变了- 提交于 2019-12-11 15:12:04
问题 I am trying to create a class linkedList using template but when I compile it the IDE gives an error : undefined reference to `listType::add(int) I am not understanding why ? linkedList.h #ifndef LINKEDLISTS_H_INCLUDED #define LINKEDLISTS_H_INCLUDED #include "struct.h" template <class type1> class listType { public: void add(type1); void print(); private: node<type1> *head; }; #endif // LINKEDLISTS_H_INCLUDED LinkedList.cpp #include "linkedLists.h" #include "struct.h" #include <iostream>

How to create an LinkedList<Object[]>[]?

醉酒当歌 提交于 2019-12-11 15:08:07
问题 What would be the syntax to create a LinkedList<Object[]>[] type variable? I have tried: public LinkedList<Object[]>[] myList = new LinkedList<Object[]>()[]; but this doesn't work. 回答1: In Java you can't create generic arrays. You can however do this with ArrayList class or any class that implements the List interface. List<LinkedList<Object[]>> myList = new ArrayList<LinkedList<Object[]>>(); 回答2: The declaration LinkedList<Object[]>[] means an array of lists of arrays - is that the intention

How to sort SplDoublyLinkedList?

你。 提交于 2019-12-11 14:58:25
问题 There is a linked list that needs to be sorted in O(n Log n) time. I would like to use merge sort, but I can't figure out how to implement it by extending the SplDoublyLinkedList class. The main problem I encountered is that I cannot divide the SplDoublyLinkedList in half without allocating additional memory. If I had independent nodes, I could easily set pointer "next" of the node to a null value, but SplDoublyLinkedList doesn't let me do it. I mean something like that in Java: node

C Linked List Nodes Not Storing

孤街浪徒 提交于 2019-12-11 14:45:01
问题 This code is supposed to insert a given int after and a given int before a linked list. However, when I pass the arguments in main, they do not store the values in commands insAfter and insBefore, and just return 0. I am guessing it has to do with the integer, but when I had the user input the value in the actual function and set it to the same thing "n" is set to and it worked. struct node { int data; char *item; struct node* next; }; struct node* root = NULL; void insAfter(); void insBefore

C Linked List errors

寵の児 提交于 2019-12-11 14:11:48
问题 I need some serious help with understanding Linked Lists in C++ I am suppose to take a program that I wrote a couple weeks ago using array structures and convert them into linked lists and add a couple new functions. My big concern is I do not feel confident in linked lists and have been spending time on here and other sites gaining knowledge on them. But I cannot find a source that helps me relate to the problem I am facing right now. Here is my original code: #include <stdio.h> #include

Load WebView with .html file linked to /assets folder

寵の児 提交于 2019-12-11 13:38:45
问题 I need to load .html file into WebView but this file is situated in external folder on disk. I cannot copy file into /assets folder under my android project. But i can create a link to this file in Eclipse. The question is how can i load this linked file into WebView? I tried to load it with webView.loadUrl("file:///android_asset/myFile.html") but it did work. WebView cannot find 'myFile.html' in '/assests' folder. ('myFile.html' link in /assests folder to real file in external folder on disk

How to implement doubly linked list in swift?

夙愿已清 提交于 2019-12-11 13:33:39
问题 How can I implement a doubly linked list in Swift with all the operations like insert and deletion? I know how to implement singly linked list but I can't find a way to make it a doubly linked list. I am a beginner in coding. import UIKit struct LinkedList<Value> { var Head : node<Value>? var Tail : node<Value>? var isEmpty : Bool { return Head == nil } // to add at the beginning of the list mutating func push(_ value : Value) { Head = node(value: value, nextNode: Head) if Tail == nil { Tail

Trying to Sort a Linked List only by Manipulating Pointers

ε祈祈猫儿з 提交于 2019-12-11 13:33:01
问题 I am trying to use Selection Sort to sort a Linked list. I can only manipulate the linked lists pointers and not change the keys. I think I have functional logic but, I just return the original unsorted sequence. bool nodeSwap(Node* head){ Node* next = head->next; if(next == NULL){ return head;} head->next = next->next; next->next = head; head = next; return next; } Node* sort_list(Node* head){ for(Node* n = head; n->next != NULL; n = n->next){ for(Node* n1 = head->next; n1 != NULL; n1 = n1-