As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [hash-table]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
10 votes
3 answers
1k views

pset4 speller - can't pass valgrind test - 32 bytes still reachable

Can't pass valgrind test on pset4 speller (hashtable). The speller works perfectly but, I'm getting this message from valgrind: ==3911== ==3911== HEAP SUMMARY: ==3911== in use at exit: 32 bytes ...
agraffe's user avatar
  • 101
6 votes
1 answer
103k views

How to fix the "conditional jump or move depends on uninitialized value" valgrind error?

Need help again. I've got my linked list working. It copies a list of words from a file into a linked list. Now I want to make a hash table so that all words starting with the letter 'A' go into a ...
jzz's user avatar
  • 65
2 votes
1 answer
5k views

CS50 good hash function for PSET5 Speller

I was looking up different hash functions and was getting really confused following what the code was doing. I stumbled upon this hash function: int hash(const char * str) { int hash = 401; ...
ayeeitsalpha's user avatar
2 votes
1 answer
2k views

How to know how many buckets for hash table - Speller PSET5

I am implementing the hash table for load at the moment, but I don't know how I should figure out how many buckets I should be using. Is there a 'rule' for this when creating hash functions, or is it ...
Davis's user avatar
  • 144
2 votes
2 answers
2k views

implementation of hash table

I have been having trouble with the implementation of the hash table and linked lists. I don't know if I am on the right track or not, but I think my main problem is not knowing how to automate the ...
sousheel's user avatar
  • 149
2 votes
2 answers
131 views

how effective would it have been to use an array for the dictionary?

I just completed pset5 using a trie, but I'm curious about other methods. How effective would it have been to load the dictionary into an array and then use a binary search function to locate words ...
736f5f6163636f756e74's user avatar
1 vote
2 answers
1k views

how to check if just the load function is implemented correctly?

I've just started this pset and only implemented load. So how do I know if my load function actually loads the dictionary and there are words in the hashtable without implementing the other functions ...
VishG's user avatar
  • 13
1 vote
1 answer
676 views

pset5, load function. Initializing elements in hashtable to null

This is my load function from dictionary.c. I'm trying to create a hashtable of linked lists with separate chaining. There are 26 elements corresponding to each letter in the alphabet. My questions ...
tadm123's user avatar
  • 215
1 vote
2 answers
379 views

Why should we mod a hash value by the size of the hash table?

Week 7 Short on Hash Table provides the following suggested hash function: int hash_function (char* key) { // hash on first letter of string int hash = toupper(key[0]) - 'A' ; return hash ...
Allen Mark Brown Jr's user avatar
1 vote
1 answer
163 views

Pset5: Hashtable, cannot submit my code

I am unable to submit my code to test it against other cs50 students :) dictionary.c and dictionary.h exist :) speller compiles :( qualifies for Big Board expected exit code 0, not 139 How ...
user avatar
1 vote
1 answer
638 views

pset5 speller.c with hashtable errors and seg fault

this is my code so far for pset5. I would appreciate giving me hints about my erros. I also get a segmentation fault. thanks. when I implemented load and check only, it seemed to load the text and ...
Riham Nour's user avatar
1 vote
1 answer
954 views

Pset6: Is it possible implement a 3D Hash table Matrix?

It might be too early on for me to ask questions in this problem set, as I am just getting started with load. I was looking up Hash Functions, and they look a little cryptic to me. Is it possible to ...
Erin Magner's user avatar
1 vote
1 answer
500 views

malloc an array - hash table - Pset 6

Initially i had no problems implementing my hash table during the load function. however when it came time to check for errors, i couldn't access my hash table in order to traverse my linked list. I ...
MJay's user avatar
  • 11
1 vote
1 answer
425 views

My check function in speller isn't working

I have implemented everything else but this check function when I try to test it it seems like the the check function isn't working, because the no. of misspelled words is the same as the no. in text.....
Ojou Nii's user avatar
  • 711
1 vote
0 answers
110 views

Is hash table a type of dictionary?

In week 7 shorts for trie it is said that "a dictionary is a type of data structure that maps a key (usually string) to value". So is hash table considered a dictionary too?
Avi's user avatar
  • 93
1 vote
2 answers
7k views

PSET5 Speller hash function

I have been working on the speller problem in pset5 for a while now, and I am not able to figure out the problem in my hash function: unsigned int hash(const char* word) { int M = 1000000001; ...
Shrey Tripathi's user avatar
0 votes
1 answer
110 views

PSET6: Sorted List?

I just finished pset6 following the videos of Zamyla and the section. At the end I realized that my code implements a sorted linked list (via strcmp) but then I don't take advantage of that in my ...
Juan Carlos Piñeros's user avatar
0 votes
1 answer
470 views

When declaring an array of pointers that will be a hash table, do you have to set all the elements of the array to NULL?

In the distribution code for Speller in pset5, they include this line in dictionary.c // Hash table node *table[N]; Should I set every element in the array to NULL, because they are pointers? (the ...
Matt R.'s user avatar
0 votes
1 answer
325 views

PSET 4 - Speller: Every single word is misspelled

When I run the program, all words are considered misspelled. I can't figure out where the problem is. Can someone please help me? It also says that my program is free of memory errors - can't check ...
dino's user avatar
  • 3
0 votes
1 answer
394 views

Speller 2019: dictionary could not be unloaded and the program identifies misspelled words wrongly

my code does not work so well because it could not unload the dictionary/large eventhough there are no leaks in memory. My programm does also identify the misspelled words wrongly. Just comment if ...
Tien Thang Dinh's user avatar
0 votes
2 answers
184 views

Speller (Hash) not handling substrings properly

All tests seem to pass okay apart from the substrings test.The results of this test are : :( handles substrings properly expected "MISSPELLED WOR...", not "MISSPELLED WOR..." Log running ./...
Chesny's user avatar
  • 29
0 votes
2 answers
557 views

PSET4 Speller(hashtable) cs50 2019 HELP!

Can somebody please help me whenever i execute check50 on my code i get this :( handles most basic words properly expected "MISSPELLED WORD...", not "MISSPELLED WORD..." :( handles min length (1-...
Rahat Muneeb's user avatar
0 votes
1 answer
410 views

How can I optimize load in pset5

I'm trying to optimize my load function (after using gprof to profile speller), as it takes 99.6% time of my program. How can I do it? Here is dictionary.c: /* This function opens a dictionary file ...
Cstudent's user avatar
0 votes
2 answers
340 views

Pset5 - Problem with hash table load(), malloc, and segmentation-fault

I am having problem with the load function. When I run: valgrind --leak-check=full ./speller texts/austinpowers.txt it gives me the following report (I am using the small dictionary to test my code) ...
Levblanc 's user avatar
0 votes
3 answers
313 views

Declaring struct node and node array globally (hashtable implementation)

When coding load (using the hashtable method), I declared the structure for a node and an array of nodes within the function. However, this--of course--means I can't use these things in the check ...
Andrea Perry's user avatar
0 votes
2 answers
138 views

Hash tables running time

In the week 6, it was said for hash tables that - "We could even combine names and birthdays somehow to create a larger hash table that’s even more uniform and have smaller chains, and be even faster" ...
hagrawal7777's user avatar
0 votes
1 answer
247 views

Speller not working! What's going on?

My function returns this: WORDS MISSPELLED: 375902 WORDS IN DICTIONARY: 143091 WORDS IN TEXT: 376904 TIME IN load: 0.02 TIME IN check: 1.20 TIME IN size: 0.00 TIME ...
bobthebuilder's user avatar
0 votes
1 answer
46 views

Speller skips last word in testfile I use

The title speaks for itself, but here is a bit more in-depth explanation. While my check() function runs, it always skips the last word in whatever file it is checking out. The source code for my ...
Ruben Alias's user avatar
0 votes
1 answer
65 views

CS50 (Speller) returns all words as misspelled

I'm right on the verge of cracking this problem. I ran the program on the small dictionary provided in the distribution code. It returned both words as misspelled. So I debugged the program. I noticed ...
jaxk's user avatar
  • 3
0 votes
1 answer
151 views

PSET5 Compiling issue

So I finally finished my code and received 20 errors when attempting to compile, after my first attempt fixing the errors I tried again and received 15 errors, once more and received 17, and now am ...
ayeeitsalpha's user avatar
0 votes
1 answer
60 views

Speller.c doesn't work

I've spent pretty much time trying to solve a speller and got really stuck, don't know what's wrong with my code. It compiles but check50 says it's totally incorrect. I would be grateful if you could ...
HackeR73's user avatar
0 votes
1 answer
52 views

on pset4 speller load() struggling to understand if populating dictionary correctly and how to check hashtable

I am building my load() function and I'm wondering if I'm building it so that it is indeed storing the dictionary words correctly. I tried printing both: printf("%s\n", new_node->word); //to see ...
Katie Melosto's user avatar
0 votes
1 answer
75 views

speller double free or corruption hashtable

I'm getting a "double free or corruption" error when running this code. I don't know in which function the error is. I get the error after the code has run through check, before it gets to the unload ...
Kevin's user avatar
  • 1
0 votes
1 answer
51 views

do not understand why check function checks new word against dictionary

I am trying to implement the check function of Speller in CS50. The code below may or may not work. But the thing that gets me is that I don't understand the bit : if strcasecmp(cursor-> word, ...
stephen Ong's user avatar
0 votes
1 answer
3k views

I keep getting the message that 'non-ASCII characters are not allowed outside of literals and identifiers.'

I keep getting the message that 'non-ASCII characters are not allowed outside of literals and identifiers.' I get this message when I compile and it is at the strcpy section. Any help gratefully ...
stephen Ong's user avatar
0 votes
1 answer
160 views

CS50 [Speller_hashtable] my hashtable is weird!

After debugging for a long long time, it turned out that my hashtable must have some problem. Therefore, to find out where the problem is, I put this line of code after I insert a word in the ...
AvisTai's user avatar
0 votes
1 answer
149 views

PSET4 (Speller) malloc and calloc usage

After getting my code to work, i looked if there were any memory leaks using valgrind. It found no memory leaks, however it returned these two errors: ==7109== Conditional jump or move depends on ...
tomas-silveira's user avatar
0 votes
1 answer
524 views

Speller (hash) memory leak?

The program seems fine to me (other than this, it runs as intended), when I run valgrind, it says: ==5101== Memcheck, a memory error detector ==5101== Copyright (C) 2002-2017, and GNU GPL'd, by ...
Amit Rajaraman's user avatar
0 votes
1 answer
69 views

I can't figure out what's wrong with my speller (hash) code

When I try to run it, it says that there are no words in the dictionary so there's probably something wrong with the load function. My load code: // Loads dictionary into memory, returning true if ...
Amit Rajaraman's user avatar
0 votes
1 answer
94 views

Speller(hashtable) VALGRIND ERRORS!

i don't know or understand through val grind where and what i'm doing wrong. Except for memory errors my code outputs as correct in check50. my code // Implements a dictionary's functionality #...
Rahat Muneeb's user avatar
0 votes
1 answer
471 views

PSET5 "Linker Command Failed with Exit Code 1"

I've been working on speller (implementing a hashtable) for quite a while now and I'm stuck...my code compiles but I'm assuming there's a run-time error. I'm not sure what to make of my error message, ...
Sean Cheng's user avatar
0 votes
2 answers
563 views

pset4 speller all words are misspelled

I realize that many people have asked this question before but I didn't find my answer in any of them. Or maybe I'm just too stupid to see it. Anyways my code seems to work except that all the words ...
John Doe's user avatar
0 votes
1 answer
140 views

CS50 - Speller (Hashtable) - Misspelled all words

My program is misspelling all words in the texts. There is a problem somewhere in either load or check, but I just can't figure it out. Can you guys help me find the problems I am having in my program?...
HenryVo's user avatar
0 votes
2 answers
1k views

pset4 Speller hash table basics

After struggling with this pset for a while I decided to strip it down to its most basic form and try and understand the implementation of hash tables and linked lists by creating my own. To that end ...
borebot's user avatar
0 votes
1 answer
140 views

pset5 load null pointer issue

Working through the load portion of pset5. Everything compiles, but when I run valgrind it looks as if nothing is actually loading in, with the error of "null pointer passed as argument 1, which is ...
Jake 's user avatar
  • 37
0 votes
1 answer
135 views

HashTable full of single value

I think the problem is in my load function. I am able to successfully create a hash for each word, and I can call my createNode and insertNode functions to such a degree that I create a full hashtable ...
wlh's user avatar
  • 132
0 votes
1 answer
123 views

Two hash table questions

I am working through SPELLER and have a few questions. When I create a new node node *newptr = malloc(sizeof(node)); do I need to say newptr1, newptr2, newptr3 and if so what is the best way of doing ...
ndjustin20's user avatar
0 votes
1 answer
722 views

Struggling with hash table! Pset5

I've been trying to fix this bug for the past couple of days, but it seems this one I really can't figure out on my own. Hope you guys can help a bit. Here's the code for my load function in pset5. #...
Elkan Frank's user avatar
0 votes
1 answer
520 views

Segmentation Fault on Hashtable

PLease Someone help me I was trying to implement a hash table that stores the word of English language for pset 5. So to be in brief, I used an array of linked list ( Chaining ) , I haven't made the ...
amethyst stan's user avatar
0 votes
1 answer
320 views

Speller(hashtable) flagging all words as misspelled

I've exhausted all my options which is why I'm making this post. When I simply run the program it prints every word as misspelled. The problem itself probably lies in load or check. Running the ...
zmmadewell's user avatar