小编meo*_*tet的帖子

cs50 pset5 拼写器优化

我已经完成拼写并通过了所有检查。但我仍然对性能感到困扰。我尽了最大努力进行研究和运行测试,但与员工的相比,我的实施速度慢了 10-20%。我该如何改进我的代码?

\n
    // Implements a dictionary\'s functionality\n\n#include <ctype.h>\n#include <stdbool.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <strings.h>\n#include "dictionary.h"\n\n// Represents a node in a hash table\ntypedef struct node\n{\n    char word[LENGTH + 1];\n    struct node *next;\n}\nnode;\n//Prototypes\nunsigned int hash(const char *word);\n\n// TODO: Choose number of buckets in hash table\nconst unsigned int N = 187751; //odd prime number bigger than word count, because math\n\n// Hash table\nnode *table[N]; //may need to use calloc\n\n//word count\nint word_count = 0;\n\n// Returns true if word is in dictionary, else false\nbool check(const char …
Run Code Online (Sandbox Code Playgroud)

c performance hashtable linked-list cs50

5
推荐指数
1
解决办法
8106
查看次数

标签 统计

c ×1

cs50 ×1

hashtable ×1

linked-list ×1

performance ×1