Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 1161

The problem set for Week 7

2 votes
Accepted

Speller getting instant Segmentation Fault

I was successfully able to set break points and execute the program step by step without any problems using gdb. Maybe you're not doing that correctly. I recommend you watch the short on gdb for more …
kzidane's user avatar
  • 17.7k
0 votes

How can i make the hashtable global?

So you need the size to load and you need to load to know the size. This seems infinite. My suggestion would be using the maximum value that your hash function returns as the size of your hash table …
kzidane's user avatar
  • 17.7k
0 votes
Accepted

Declaring and Using an argument in a while loop

An argument is a variable/ a value that is passed to a function when it's called. It actually has nothing to do with what you're describing. Now, for your question, you could actually do something li …
kzidane's user avatar
  • 17.7k
1 vote
Accepted

pset6 - Why is "h" included in the getopt optstring?

if you read the switch statement at the beginning of the program, you'll know that the -h option lets you know how the program should be used. 'h' stands for "help". this is also typically the case wi …
kzidane's user avatar
  • 17.7k
0 votes
Accepted

Permission Denied with staff’s implementation of server

try executing this: sudo chown -R jharvard:students ~cs50/pset6 and try again! …
kzidane's user avatar
  • 17.7k
1 vote

load function in dictionary.c

Okay, here's the thing: this is how you're inserting a new node into your hash table int index = hashfun(new_node->WORD); new_node->next = hashtable[index]->next; hashtable[index]->next = new_node; …
kzidane's user avatar
  • 17.7k
5 votes
Accepted

Why use fgetc instead of fscanf?

If you remember from previous weeks, fscanf() by itself is actually not the best function to use to get input specifically strings. fgetc() reads character-by-character from a stream. This will enabl …
kzidane's user avatar
  • 17.7k
2 votes

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

They, however, expect something a little bit more complicated than this if you chose to implement a hash table for pset6. …
kzidane's user avatar
  • 17.7k
0 votes

pset6 check50 doesn't pass for possessives and substrings properly

When the word "Agetribe" is in the dictionary, but the word "Agetribe's" or "Agetribes'" are not, your program should consider "Agetribe's" and "Agetribes'" as a misspelled words and vice-versa unless …
kzidane's user avatar
  • 17.7k
2 votes
Accepted

Improve load time in pset6

Should I try to improve it more? Yes, if you wish! Does it matter? It's meant to challenge the staff and yourself at the first place, so officially it doesn't matter. If I should improv …
kzidane's user avatar
  • 17.7k
4 votes
Accepted

valgrind messages about "unititialised value(s)" - are they an issue?

You're totally correct. You have to initialize variables before asking for their values. Since a trie is an array of arrays, the root array can be initialized when declared like that node *root[26] …
kzidane's user avatar
  • 17.7k
1 vote
Accepted

Can I improve my new node initialization in load()?

To initialize an array with an initialization list, you must do that in the same statement that declares this array as follows int arr[] = {1, 2, 3, 4, 5}; Since your array is a member of a struct, …
kzidane's user avatar
  • 17.7k
1 vote

what is wrong with this sorting method in load function?

You don't compare strings using the relational operators, but rather, you may use strcmp (declared in string.h). Also, apparently there's a problem with the logic of the insertion here. For example …
kzidane's user avatar
  • 17.7k
1 vote

Valgrind segfaults, programm doesn´t

According to valgrind, an invalid read of size 4 was made exactly at dictionary.c, function addTrie, line 256. "If ptr is NULL, no operation is performed" Apparently, this invalid read is the same one …
kzidane's user avatar
  • 17.7k
1 vote
Accepted

What might be wrong with this pset6 load hash function?

That program that you're trying to compile doesn't have a main function.
kzidane's user avatar
  • 17.7k

15 30 50 per page