"hashtable linear probing ,insertion deletion searching" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "hashtable linear probing ,insertion deletion searching" answered properly. Developers are finding an appropriate answer about hashtable linear probing ,insertion deletion searching related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like hashtable linear probing ,insertion deletion searching. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on hashtable linear probing ,insertion deletion searching. 

hashtable linear probing ,insertion deletion searching

By ujjwal sotraujjwal sotra on May 24, 2021
//all the basic opertaion insertion , deletion ,searching,displaying
#include <iostream>

using namespace std;
void init(int arr[],int size)
{
    for(int i=0;i<size;i++)
    {
        arr[i]=-1;
    }
}
void inserthash(int arr[],int size,int value)
{
    int key=value%size;
    int index=key;
    while(arr[index]!=-1)
    {
        index=(index+1)%size;
        if(index==key)
        {
            cout<<"hash table full"<<endl;
        }
    }
    arr[index]=value;
}
void deletehash(int arr[],int size,int value)
{
    int key=value%size;
    int index=key;
    while(arr[index]!=value)
    {
        index=(index+1)%size;
        if(index==key)
        {
            cout<<"value to be deleted not found"<<endl;
        }
    }
    arr[index]=-1;
}
int searchhash(int arr[],int size,int value)
{
    int key=value%size;
    int index=key;
    while(arr[index]!=value)
    {
        index=(index+1)%size;
        if(index==key)
        {
            return 0;
        }
    }
    return 1;

}
void display(int arr[],int size)
{
    for(int i=0;i<size;i++)
    {
        cout<<arr[i]<<" ";
    }
    cout<<endl;
}
int main()
{
    int n;
    cout<<"enter the size:"<<endl;
    cin>>n;
    int a[n];
    init(a,n);
    int choice;
    while(1)
    {
        cout<<"1. insert"<<endl<<"2.delete"<<endl<<"3.search"<<endl<<"4. display"<<endl<<"5. exit"<<endl;
       cout<<"enter the choice:"<<endl;
       cin>>choice;
       switch(choice)
       {
           case 1:
               {
                   int val;
                   cout<<"enter the value you want to insert:"<<endl;
                   cin>>val;
                   inserthash(a,n,val);
                   break;
               }
           case 2:
            {
                int val;
                cout<<"enter the value you want to delete:"<<endl;
                cin>>val;
                deletehash(a,n,val);
                break;
            }
           case 3:
            {
                int val;
                cout<<"enter the value to be searched:"<<endl;
                cin>>val;
                int l= searchhash(a,n,val);
                if(l==1)
                {
                    cout<<"value found"<<endl;
                }
                else
                {
                    cout<<"not found"<<endl;
                }
                break;
            }
           case 4:
            {
                display(a,n);
                break;
            }
           case 5:
            {
                exit(0);
            }
           default:
            {
                cout<<"invalid choice"<<endl;
            }
       }
    }
}

Add Comment

0

All those coders who are working on the C++ based application and are stuck on hashtable linear probing ,insertion deletion searching can get a collection of related answers to their query. Programmers need to enter their query on hashtable linear probing ,insertion deletion searching related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about hashtable linear probing ,insertion deletion searching for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of hashtable linear probing ,insertion deletion searching while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "hashtable linear probing ,insertion deletion searching". Visit this developer's friendly online web community, CodeProZone, and get your queries like hashtable linear probing ,insertion deletion searching resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "hashtable linear probing ,insertion deletion searching"

View All C++ queries

C++ queries related to "hashtable linear probing ,insertion deletion searching"

Browse Other Code Languages

CodeProZone