Skip to main content
11 votes
Accepted

Speller.c appears to be working but is case sensitive (can't recognize capitol letters)

It's something you overlooked. Your hash function determines the hash value by adding the ASCII values of every letter in the word. The problem is that an upper case letter won't produce the same ...
Cliff B's user avatar
  • 69.1k
4 votes
Accepted

How to make the check function faster?

The reason why your check function is slow is because of how the dictionary is loaded into memory. There are two things to do to right this: 1.) Find a good hash function online like this one I found ...
NullityNull's user avatar
3 votes
Accepted

PSET5 Speller, faster check and load times hashmap

This is an ineffective use of a hash function. In essence, your load function simply inserts each word sequentially into an array, along with a hash number, and the check function is doing a linear ...
Cliff B's user avatar
  • 69.1k
3 votes
Accepted

expected expression pset5 dictionary.c if-else

The problem is bad structuring of the chain of ifs and else ifs. Look at the following: if(...) { ... } else if (isupper((char)*(word + i))) { else if (cursor -> children[(...
Cliff B's user avatar
  • 69.1k
2 votes

pset5 trie check segmentation fault

OK, after careful debugging I have discovered and fixed the issue. It doesn't have to do with malloc/calloc. Even though my forward declaration of the struct/root node was properly placed outside of ...
Avishai Fuss 's user avatar
2 votes

pset5 Check Function (trie version) giving a segmentation error

I just figured out the answer (in case anyone has a similar issue). And actually the error was in Load so apologies for not including that (I didn't want to paste too much of the pset in). I declared ...
jamiej's user avatar
  • 21
2 votes
Accepted

Load and Check error in pset5

Simply put, the while loop in check() never starts. Look at the following code: unsigned int c =0; unsigned int i = 0; while(c != '\0') int 0 is the same as \0 in their binary ...
Cliff B's user avatar
  • 69.1k
2 votes
Accepted

PSET5 : Question about structs

When you declare node* you are not declaring a variable of type struct node. Rather, you are declaring a pointer-to-node. A pointer is just a memory address. This is why, when you check the sizeof() ...
hotwebmatter's user avatar
  • 3,050
2 votes

PSET5 Speller, faster check and load times hashmap

As usual, Cliff B has explained things very well in his answer. I'd just like to add a more succinct explanation. Your problem is that you want to keep the dictionary sorted alphabetically and also ...
hotwebmatter's user avatar
  • 3,050
2 votes
Accepted

Pset 5 - Question on check(), diff, and check50 (and I found it interesting)

The second one is incorrect and it only passes check50 because of the very small dictionaries that check50 uses. In your original version, you create a pointer that points to the hashtable, and you ...
curiouskiwi's user avatar
  • 18.7k
2 votes
Accepted

pset5 check function and const char* word

Can't tell you exactly what's happening without seeing your entire code, but one thing I can tell you right away is that you're forgetting to allocate space for the null terminator when you only ...
Yuri Laguardia's user avatar
2 votes
Accepted

PSET5 Speller / Dictionary - Seg Fault and Incorrect Check

You can jump to SUGGESTION for quick answer. I plugged your check() function on my dictionary.c program. I also have a trie in my dictionary.c. I don't know what is causing the segmentation fault. ...
Ricardo David Antonetti's user avatar
2 votes
Accepted

CS50 PSET5 Won't Work With Apostrophes

You have: else if (l == '\'' && trav->children[26] == NULL) { trav->children[26] = calloc(1, sizeof(node)); } So, what if you do have an apostrophe but trav->children[26] is not ...
Ricardo David Antonetti's user avatar
2 votes
Accepted

PSET5 - Trie Check Segmentation Fault

It's a common problem. The problem lies in load(), where you have created a "shadow variable." A shadow variable happens this way: First, the original variable is created, either earlier in main or a ...
Cliff B's user avatar
  • 69.1k
2 votes
Accepted

pset8 - finance - check - ajax - preventDefault()

You have to stop the submission now (in the submit event listener), and in case of success submit in the AJAX callback. Submitting via JavaScript will not trigger another submit event.
Blauelf's user avatar
  • 21k
2 votes
Accepted

PSET 8: Finance /check

So, as it turns out - the error was in the Python code. I used "request.form.get()" when I should have used "request.args.get()" since its a GET request not a POST request. Using "request.args.get()"...
Adam DeCaria's user avatar
2 votes

PSET6 DNA Almost done - matching not working correctly

And I just realized it can be fixed by moving the counter inside of the loop. with open(sys.argv[1], "r") as fl: dictionary = csv.DictReader(fl) for row in dictionary: ...
Alexander Alexandrov's user avatar
1 vote
Accepted

CS50 PSET5 - Segmentation Fault

I debugged your code and I am a little bit puzzled. With your code, both large and small loaded fine and with no Segmentation faults. I did find some lines that might cause logic error though. I am ...
Ricardo David Antonetti's user avatar
1 vote

Capital letters and strcmp() issue in check function

I stopped at this point: strcmp(cursor->word, word) You are creating a new hash_word that is all lower case, but you are then trying to find word in your hashtable. Shouldn't you be trying to ...
curiouskiwi's user avatar
  • 18.7k
1 vote

pset5 check function not working

I am going to talk about line numbers based on your code block. For example: #include <stdbool.h> // line #01 current = (node*)malloc(sizeof(node)); // line #57 I see that ...
Ricardo David Antonetti's user avatar
1 vote

CS50x Fall 2016, check50 doesn't work?

Asked and answered in comments. Please click on the check mark to accept so that this is removed from the unanswered question pool. Sometimes, check50 will throw the unknown error for no apparent ...
Cliff B's user avatar
  • 69.1k
1 vote
Accepted

Array for storing hashtable has remaining NULL bytes after being loaded

Don't forget that fgets will read in the newline character as the last char of each word. Because of this, you are storing that newline char in your head_node->word. But in check, the words don't ...
curiouskiwi's user avatar
  • 18.7k
1 vote

Array for storing hashtable only updates some of its initial NULL bytes

" It was initialized to NULL as soon as the load function ran, prior to being declared globally. " That's not exactly true, nor is it the complete truth. Note the following statement inside of load():...
Cliff B's user avatar
  • 69.1k
1 vote

PSET5 Speller, faster check and load times hashmap

From where I see it, if you want to have an array for all the words, and use a linked list, so that you can use a binary search, you have 2 options: Make an array of strings, and store the words ...
ChrisG's user avatar
  • 7,396
1 vote
Accepted

pset5: All works correctly except "a", "A" and "I" come up misspelled too

You have to consider the case, where the word you try to check is the last word in your linked list. In that case trav->next will be NULL, but since you don't enter the while loop, you never check ...
ChrisG's user avatar
  • 7,396
1 vote
Accepted

pset5: All words misspelled after load and check

At a quick glance, I see one very serious error that results in only one word in the dictionary - "str" - and nothing else. Look at the following: strcpy(hashtable[h_num]->dict_word, "str"); ...
Cliff B's user avatar
  • 69.1k
1 vote
Accepted

Pset5: not setting bools correctly?

The check function has some serious logic issues. As written, among other issues, it is depending on finding a null child to detect the end of a word in one case. This could produce a false positive. ...
Cliff B's user avatar
  • 69.1k
1 vote
Accepted

In Check50 I get a Segmentation Fault, and trying myself gives me an endless loop

I don't understand why you are getting to check, or appear to be getting an infinite loop. When I ran your posted code, it immediately generated a seg fault. The problem is exposed here: for (int c =...
Cliff B's user avatar
  • 69.1k
1 vote

Dictionary.c thinks every word is misspelled

Oh, my. There's a lot of work to be done. Because of this, I only looked at load. I haven't looked at check at all. There are at least three problems that I see. First, although you are counting ...
Cliff B's user avatar
  • 69.1k
1 vote

Dictionary.c thinks every word is misspelled

Take a closer look at your load() function. The most common reason for every word to be misspelled is a lack of words in the dictionary. In particular, since you are using a trie data structure to ...
hotwebmatter's user avatar
  • 3,050

Only top scored, non community-wiki answers of a minimum length are eligible