-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Hashing implementation with collision resolution using chaining #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Work! I have some requests.
Hashing/Chaining.cpp
Outdated
cout<<"5. Exit."<<endl; | ||
cin>>c; | ||
switch(c){ | ||
case 1:{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the curly braces by the case
branches.
Hashing/Chaining.cpp
Outdated
cout<<"Element not found"; | ||
return; | ||
} | ||
while(1){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead you can write
while(temp->data != x && temp->next)
temp=temp->next;
Hashing/Chaining.cpp
Outdated
#include<iostream> | ||
#include<math.h> | ||
using namespace std; | ||
struct node{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use upper case.
Hashing/Chaining.cpp
Outdated
} | ||
|
||
void add(int x,int h){ | ||
struct node *temp = new node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of node
write Node
Hashing/Chaining.cpp
Outdated
struct node *temp; | ||
int i; | ||
for(i=0;i<mod;i++){ | ||
if(head[i]==NULL){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of if(head[i]==NULL){
write if(head[i]) {
Hashing/Chaining.cpp
Outdated
#include<iostream> | ||
#include<math.h> | ||
using namespace std; | ||
struct node{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave a space between the curly brace and node
.
@@ -0,0 +1,132 @@ | |||
#include<iostream> | |||
#include<math.h> | |||
using namespace std; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this line write a empty line.
Hashing/Chaining.cpp
Outdated
int c,x,mod; | ||
cout<<"Enter the size of Hash Table. = "; | ||
cin>>mod; | ||
while(1){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of while(1){
write while(loop)
. For a boolean variable loop
. Then you write bool loop = true;
Hashing/Chaining.cpp
Outdated
case 4:{ | ||
display(mod); | ||
} | ||
default:{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the case 5
you turn of the loop flag loop = false
Hashing/Chaining.cpp
Outdated
break; | ||
} | ||
} | ||
if(c>4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid this if
. see my comment above.
Thanks for reviewing my pull request @christianbender :) |
Hello @christianbender, |
Relates to Issue #24