linked-list

Linked List Print Error Using Time Functions

不想你离开。 提交于 2019-12-14 03:27:35
问题 The program crashes when printing the timestamp. I believe the error is located in the function void flightRec_PrflightRecData(flightRecRead* thisFlight) which is designed to do three things: declare the time struct flighttime, flighttime is in POSIX format. Localtime converts the POSIX time to a human-readable time. The fourth specifier prints the converted time using asctime which prints it in Www Mmm dd hh:mm:ss yyyy format. The error is tb != NULL and shows other information specifying

Implementing a push function in c++

心不动则不痛 提交于 2019-12-14 03:25:18
问题 I'm having some trouble with creating a push function (adding a node to the front of the list). I know that with just a node, you could use the push function given with c++ as push_front(), but would I be able to use that here as well? : struct Node { string val; Node* next; Node* prev; }; struct Stew { Node* first; Node* last; }; Where the Stew structure is defined as having two special pointers, one pointing to the first element and one pointing to the last. The Node structure has links in

Order a linked list alphabetically by name

拥有回忆 提交于 2019-12-14 03:15:44
问题 I am having an issue organizing a linked list alphabetically. I am reading the names in from a text file and storing them into a linked list. The problem I am having is how to sort them alphabetically. If anybody could point me in the right direction that would be amazing. The idea is to get the value of the first 3 letters in each name and compare them to the first 3 in the next name. But where would I compare the letters together? Here is the LinkedListNode class: public class

I made this program and it prints one extra thing

∥☆過路亽.° 提交于 2019-12-14 03:09:20
问题 Program uses a while loop menu in the main to request for the user command: public static void main(String[] args)throws Exception { Boolean meow = true; while(meow) { System.out.println("\n 1. Show all records.\n" + " 2. Delete the current record.\n" + " 3. Change the first name in the current record.\n" + " 4. Change the last name in the current record.\n" + " 5. Add a new record.\n" + " 6. Change the phone number in the current record.\n" + " 7. Add a deposit to the current balance in the

C++:Linked list ordering

戏子无情 提交于 2019-12-14 03:08:51
问题 I have a function and it is suppose to organize a dictionary of stemmed words. I have a function call inserted then suppose to place it in the right alphabetical order. Adding to the front and middle of the list works, but adding to the back doesn't. I've looked at several sources and I can't tell what's wrong. void dictionary::insert(string s) { stem* t = new stem; t->stem = s; t->count =0; t->next = NULL; if (isEmpty()) head = t; else { stem* temp = head; stem* prev = NULL; while (temp !=

C - Linked list of hash table keys

落爺英雄遲暮 提交于 2019-12-14 03:06:31
问题 I try to create a function that get in input an hash table and return a linked list of keys. This is the struct of a list node: struct hash_table_key_list_node_s { char *key; struct hash_table_key_list_node_s* next; }; typedef struct hash_table_key_list_node_s hash_table_key_list_node_t; typedef hash_table_key_list_node_t* hash_table_key_list_t; I don't understand why the list contains only one element but the hash table contains 330 element. This is the code of the function: hash_table_key

How to delete node from linked list?

限于喜欢 提交于 2019-12-14 02:06:10
问题 Adding integers to list works fine, but there's something wrong with deleting and printing. I'm not friendly with debugger yet, but I found out that there is error from node pointer 'first'. Its value is -17891602. I don't know what happened... #include <iostream> using namespace std; class nodeList; class node { friend class nodeList; private: int data; node* link; public: node() { //constructor data = 0; link = NULL; } node(int d) { //constructor data = d; link = NULL; } node(int d, node* l

Java Doubly Linked List Clone Method

[亡魂溺海] 提交于 2019-12-14 01:59:12
问题 I'm working on coding some data structures on my own time. I've noticed that the clone method is not copying the list as I expect. I'll post my results underneath the code as the main method is near the bottom of the class. Here is the class I have written so far: public class DoublyLinkedList<E> implements Cloneable { //------------nested Node class------------ private static class Node<E> { private E element; // reference to stored element private Node<E> prev; // reference to previous

Using single versus double pointers in Linked lists implemented in C

…衆ロ難τιáo~ 提交于 2019-12-14 01:24:42
问题 I was writing this code for adding element at the end of linked list: struct node{ int info; struct node* link; }; void append ( struct node **q, int num ) { struct node *temp, *r ; if ( *q == NULL ) // if the list is empty, create first node { temp = (struct node*) malloc ( sizeof ( struct node ) ) ; temp -> info = num ; temp -> link = NULL ; *q = temp ; } else{ temp = *q ; /* go to last node */ while ( temp -> link != NULL ) temp = temp -> link ; /* add node at the end */ r = (struct node *

Copy constructor for a pointer data linked list

浪子不回头ぞ 提交于 2019-12-14 00:12:48
问题 Can you help me to write a copy constructor for this List, note that the Data is stored indirectly. class List { private: struct Node { Data *data; Node *next; }; Node *head; }; You can assume you have a copy constructor of Data class. Thank you. 回答1: Your class definition needs to add the function signature: List(const List& list); The parameter is the list you are copying from. You also need to implement this function. List::List(const List& list) { //Iterate through the list parameter's