Skip to content

Commit 27bfc4b

Browse files
committed
figured out bfs
1 parent a470c86 commit 27bfc4b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

hashset.c

+12-7
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,29 @@ bool addHashed(table* ht, int value, int key)
7070
{
7171
return addListHead(ht->tables[key],value);
7272
}
73-
bool ADD(table* S, int K)
73+
bool ADD(table* S, int K, int key
74+
)
7475
{
75-
return true;
76-
}
76+
if (!HAS(S,K))
77+
{
78+
addHashed(S,K,)
79+
return true;
80+
}
7781
bool DEL(table* S, int K)//remove
7882
{
7983
return true;
8084
}
8185
bool HAS(table* S, int K)//percente
8286
{
8387
int key = hashFunction(K,S->base);
88+
node* tmp = S->tables[key]->head;
8489
while (S->tables[key] != NULL)
8590
{
86-
87-
}
88-
91+
if(tmp->data == K)return true;
92+
tmp = tmp->next;
8993

90-
return true;
94+
}
95+
return false;
9196
}
9297
int AtoI(char input[]) //returns an int from a string
9398
{

0 commit comments

Comments
 (0)