Questions tagged [pset5]

The problem set for Week 5 will challenge you to apply what you've learned about pointers, memory management, file i/o and structs, creating more complex data structures (such as Hash Tables or Tries) and leveraging their power to write a lightning-fast spell check algorithm.

Filter by
Sorted by
Tagged with
0
votes
1answer
553 views

Pset5- speller could not load dictionary

This is what my terminal looks like when I compile and run my program. ('You messed up' is the error message I put in place for when in input dictionary is NULL) This is my full ide window. I ...
0
votes
2answers
598 views

Pset5 - Speller - Load (loading only 1 word in dictionary)

I'm still trying to cope up with Pset5 So what I have: program shows 14 from 17 words in text as misspelled and is ended with *** Error in `./speller': free(): corrupted unsorted chunks: ...
0
votes
1answer
259 views

STILL baffling check50 fail for speller.c!

I am totally stumped by the following problem. My code for dictionary.c compiles with 'make' without a problem. However, when I run check50 it fails the compile test with the error at this sandbox url:...
0
votes
2answers
98 views

Size of large dictionary trie structure seems very large

My speller seems to be working a-okay, but the dictionary load time is about 0.08 seconds slower than the staff implementation, and i wondered if that had something to do with an overlarge trie ...
0
votes
2answers
96 views

pset5. Can't trace memory leak

Load function (with a trie data structure) //DEBUG unsigned int allocs = 0; // define node and create root typedef struct node { bool is_word; struct node* children[27]; } node; node* root; ...
0
votes
2answers
197 views

check50 possessives and substrings

I don't really get why even though I handle the apostrophe case I think correctly here is what check50 gives me :) dictionary.c, dictionary.h, Makefile exist :) speller compiles :) handles most ...
0
votes
3answers
377 views

pset5 - Load - Debug Error - “Process received SIGSEGV: Segmentation fault”

I commented out my check function so it must be something here in load. From what I've read I think the issue is dealing with pointers and fgetc. That or my first for loop is looping weird. granted I'...
0
votes
2answers
54 views

Pset5 load function segmentation fault in middle of dictionary

I having trouble with load function. I am trying to load dictionary in simple linked list, but in middle of dictionary I get segmentation fault. Please help. bool load(const char *dictionary) { ...
0
votes
1answer
370 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 ...
0
votes
2answers
310 views

Pset5 Speller Memory Leak

I have a memory leak. Valgrind told me that I had over 10000000 errors. So what is the problem? Someone told me there was no problem in my unload function, so here's my Load function. bool load(...
0
votes
1answer
61 views

What is this line of code meant for in pset5

if (argc != 2 && argc != 3) In my understanding how this can be possible that argc!=2 and argc!=3. If there is "or" then I can understand. How this code works.
0
votes
1answer
228 views

PSET5 - Trie Check Segmentation Fault

I have been trying with this code for some time and tried numerous permutations, however I am still struggling to get anywhere! I am very new to coding so please give any advice that will improve my ...
0
votes
1answer
61 views

PSET5 segmentation fault cannot scan the word correctly

I've been getting a seg fault in load on this line: strcpy(new_node->string,word); I try to use gdb to print "word",it shows "\177ELF\002\001\001\000\000\000\000\000\000\000\000\000\002\000>\000\001\...
0
votes
1answer
438 views

pset5 check function and const char* word

I think the biggest issue is at the beginning of check. In the first example, I tried altering its declaration (I know I shouldn't) and since words is not a constant anymore, it gets modified by ...
0
votes
1answer
110 views

CS50 PSET5 Trie Segmentation Fault

When I try to use speller.c with the large dictionary and the text 'hi', it says it could not load/open. When I use a large dictionary, it occasionally gives me a segmentation fault. Valgrind says: ==...
0
votes
2answers
389 views

PSET5 CS50 How to Approach As Well As Difference Between *node and node*

I am confused as to how to approach problem set 5. I have watched the lectures and shorts but I am still confused on the subject of pointers. Are there any additional CS50 videos or walkthroughs that ...
0
votes
2answers
302 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) ...
0
votes
1answer
39 views

Hash Table Keeps Calling Everything Misspelled and Ends with a SegFault

I am really stuck at why my cursor is set to NULL in check. This is my code /** * Implements a dictionary's functionality. */ #include <stdbool.h> #include <stdlib.h> #include <...
0
votes
1answer
608 views

What is the difference between fgets and fscanf?

Both seemed same to me can anyone explain to me these two functions in easy english
0
votes
2answers
120 views

program control error

here is my code /** * dictionary.c * * Computer Science 50 * Problem Set 5 * * Implements a dictionary's functionality. */ #include <stdbool.h> #include &...
0
votes
1answer
145 views

Pset5 unload trie 244 bytes lost

So, I'm finishing up pset5 and I'm now just trying to make sure theres no memory leaks. Unfortunaly there are 244 bytes being lost and I'm not sure why they're being lost. This is my free code: bool ...
0
votes
1answer
175 views

Extra word in the dictionary pset5

I really need your help because I'm stuck on pset5 for so many days:( I don't know for what reason but my program always sees one extra word in the dictionary! I mean even in the example with ...
0
votes
1answer
34 views

Pset5: trie check outputs 18000 out of 19000 words in austin powers

Please help me figure this problem out. The program outputs around 14000 words out of the 19000 words in austinpowers. Here is my code: int getSpot(int letter, node* cursor) { if (cursor-...
0
votes
1answer
47 views

In the given code if index=0, then how can the for loop operate? since neither of the three conditions of the for loop satisfying it

// prepare to spell-check int index = 0, misspellings = 0, words = 0; char word[LENGTH+1]; // spell-check each word in text for (int c = fgetc(fp); c != EOF; c = fgetc(fp)) { // allow only ...
0
votes
1answer
99 views

Pset5: Not able to free allocated heap space in dictionary.c load function

I have implemented all 4 functions and the program seems to be working without issues. Here's the result for austinpowers.txt: WORDS MISSPELLED: 644 WORDS IN DICTIONARY: 143091 WORDS IN TEXT: ...
0
votes
1answer
93 views

pset5 Check Function (trie version) giving a segmentation error

Is there anyone that can help with my check function on pset5. I've got load working fine and confirmed that the correct number of words are loading in both the small and large dictionaries. I've ...
0
votes
1answer
1k views

How to cut down on trie load time (pset5)?

I've already completed pset5 and optimized it as best I can, but, as I've decided to store the dictionary in a trie, the load time is really high, at around 0.10. Here's how I implemented load(): ...
0
votes
1answer
72 views

Load and Check error in pset5

I am having a problem is pset5 mispellings. My function tells me that all my words are mispelled. Here are my load function an my check function. #include <stdbool.h> #include <stdio.h> #...
0
votes
1answer
141 views

Pset5 Speller only works with small dictionary and small text file

I've been doing some debugging using gdb using a small dictionary(about 80 words) and a small text file(quote.txt) when I run the program it works perfectly, however, when I use the large dictionary ...
0
votes
1answer
206 views

Pset5 load, accessing head node in linked list

I've decided on a hash table for load in pset5. There is one thing that I have no clue how to implement, though. Here is my load function. When a collision occurs, I need to be able to access the ...
0
votes
2answers
480 views

pset5 trie check segmentation fault

After completing load, I'm working on the check function. My implementation compiles but leads to a segmentation fault with various dictionaries and text files. My load function works, and the program ...
0
votes
1answer
87 views

Segmentation fault in check() function

I think my load() function is correct and I am getting Segmentation fault in check() function. This is my code for dictionary.c #include <stdbool.h> #include<string.h> #include<stdio....
0
votes
2answers
358 views

Too much misspelled in pset5 dictionary

Through my code, I got 19190 misspelled. It seems I have a problem in check though. Anyone who can find any problem here?? dictionary.h /** * dictionary.h * * Computer Science 50 * Problem Set ...
0
votes
1answer
85 views

Pset 5: help identifying source of small memory leak

My speller works properly and passes check50, but the valgrind report is still less than ideal. I believe the problem is somewhere in my check() function, so I've attached a link to that section of ...
0
votes
3answers
310 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 ...
0
votes
1answer
128 views

PSET 5, Load function, Segmentation Faults

I am getting segmentation faults in the PSET 6, the load function I have already searched google but I can't see where I've been wrong, I've been struggling with this function all day with no luck I ...
0
votes
2answers
276 views

Freeing temp node in unload pset5

------------------EDIT---------------- Everything is working fine, except for this one thing. My solution is identical to the staff solution, albeit quite a bit slower, but that's another topic. I ...
0
votes
1answer
237 views

PSET 5 dictionary.c 'char [46]' is not assignable

I am working on my dictionary.c right now and am in the process of debugging. When I try to compile my code, the error message 'char [46]' is not assignable showed up for my malloc function. I tried ...
0
votes
2answers
217 views

Pset5 check() - edited

I have been using Slack exclusively up to this point but, I figured I would give SE a try (plus my boss is out today and I have some free time.) I am working on PSET 5's check(). The error that I ...
0
votes
1answer
293 views

The load function in dictionary.c is segfaulting. 3 tfs have looked over my code and none can figure out what's going on. Can anyone help?

This is how I've implemented my load function: bool load(const char* dictionary) { // Open file FILE* input = fopen(dictionary, "r"); if (input == NULL) { return false; } ...
0
votes
1answer
243 views

Problems with letters “a” and “I” misspellings

My program loads and checks correctly with small texts and the large dictionary. Although when I load large texts, for some reason calls misspelled for the letters "a" and 'I'. I'm struggling with ...
0
votes
1answer
2k views

PSET5 - UNLOAD - Trie, Valgrind Errors

Valgrind is telling me that I have 17 allocs and 17 frees; however, it is also telling me that I have 112 bytes in 1 block that are definitely lost. Here is the code from my unload functions: void ...
0
votes
1answer
212 views

Can't free malloc used in check

My pset5 speller is complete works with all check 50. Hell it's even faster then the staff's speller. BUT valgrind is not happy. I am unable to free malloc function used in check. if i do it before ...
0
votes
1answer
214 views

Cannot clear segmentation fault in load pset5

I use a simple (or so I thought) code to load the dictionary, no optimization. Yet I keep getting into segmentation fault. In this example I use the small dictionary, which only has 2 words. In my ...
0
votes
1answer
1k views

Inserting word into hash array, and linked lists

Ok, I got most of load working. I figured out the hash function, but now I am a little stuck. If you look at "HELP", you will see that I do not know the code syntax to insert my word into the ...
0
votes
1answer
244 views

Pset5 Dictionary lots of misspeled words

So I have a problem here, I have done everything but it is pointing a lot of misspelled words, although all the times and valgrind seems to be correct. WORDS MISSPELLED: 5067 WORDS IN DICTIONARY: ...
0
votes
1answer
200 views

implement hash table with linked list

I'am trying to implement hash table with linked list, as a dictionary. but when I print the word's after the insertion, all the places have the last word on the list. thank you for the help. #...
0
votes
1answer
60 views

Initializing multiple variables inside a for loop

I have been working on the dictionary's "load" function in Problem Set 5, but I have a problem. I don't want to hard-code names for each node within my trie, which I am working on, but in order to ...
0
votes
1answer
503 views

pset5 speller, check function returns all words as false

I've been tearing my hair out over this problem for three days now, and just can;t find where I'm going wrong. All seems okay with this program, it loads the dictionary file (using a trie), gets the ...
0
votes
1answer
229 views

Segmentation Fault in pset5

As part of the edX course, CS50, I'm trying to load all the dictionary information into an array of char pointers. This would give random access and therefore a pretty fast load and unload time. The ...

1
4 5
6
7 8
24