Timeline for Speller Pset4 Hashtable Doesn't Have Correct Output for load function
Current License: CC BY-SA 4.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 7, 2019 at 3:24 | comment | added | wolfbagel | Oh, I see the issue now. Really tired at the moment, need some serious sleep. | |
Jun 7, 2019 at 3:18 | comment | added | Cliff B | The problems are obvious. You should be able to recognize the errors instantly at this point. | |
Jun 7, 2019 at 3:11 | comment | added | wolfbagel | Also, I can't access the new_node because it's in the first while loop and out of scope for my other loop | |
Jun 7, 2019 at 3:02 | comment | added | wolfbagel | When I put hashtable[26] in the for loop like this: for(int i = 0; hashtable[26]; i++){ } I get this error: ordered comparison between pointer and integer ('int' and 'node *' (aka 'struct node *')) | |
Jun 7, 2019 at 2:54 | comment | added | Cliff B | Exactly. The FOR loop selects the elements for the start of each linked list, for example hashtable[0]. Then, that is used as the starting point for the while loop. The while loop cycles down the linked list until it hits a null and exits. The code goes back to the for loop to move to hashtable[1] and the while loop executes again, and so on. | |
Jun 7, 2019 at 2:52 | comment | added | wolfbagel | Also, when you say cycle across the hashtable, do you mean hashtable[26]? To iterate over every letter in the alphabet? | |
Jun 7, 2019 at 2:49 | vote | accept | wolfbagel | ||
Jun 7, 2019 at 2:49 | comment | added | wolfbagel | k, thanks Cliff! I'll mark your answer as correct. | |
Jun 7, 2019 at 2:48 | comment | added | Cliff B | Still don't need it. All you need is a FOR loop with a nested WHILE loop. Create a for loop to cycle across hashtable[]. Then, inside a while loop, print out the word for the current node and move to the next node until you get to a NULL. | |
Jun 7, 2019 at 2:37 | comment | added | wolfbagel | Thank you Cliff, very helpful! So then how would I traverse each bucket and print out the linked list? That's one of the reasons I used 'head'. But your way is much more clear. | |
Jun 7, 2019 at 0:00 | history | answered | Cliff B | CC BY-SA 4.0 |