Dictionary Operations using ‘C

A paired max load is a finished twofold tree that fulfills the maximum store property. In a maximum stack, for some random hub, the worth of that hub is more noteworthy than or equivalent to the upsides of its youngsters.


Here are the vital highlights and tasks of a twofold max store:


1. Structure:


·        A double max stack is addressed as a twofold tree, where every hub contains a worth.


·        The tree is finished, meaning all levels are filled with the exception of conceivably the last level, which is filled from left to right.


2. Max Store Property:


·        For any hub in the store, the worth of that hub is more noteworthy than or equivalent to the upsides of its youngsters.


·        The greatest worth in the stack is situated at the root hub.


3. Inclusion:


·        To embed a component into a maximum store, it is added at the following accessible position, commonly at the base furthest right spot in the tree.


·        The load property is then reestablished by over and over contrasting the embedded component and its parent.


·        On the off chance that the parent's worth is not exactly the embedded component, the components are traded.


·        The cycle is rehashed until the component is in its right position, fulfilling the maximum pile property.


4. Separate Greatest:


·        The concentrate greatest activity eliminates the most extreme component from the root hub of the maximum load.


·        The last component in the store is moved to the root position, and the load property is reestablished by "rising down" the component.


·        The component is contrasted and its youngsters, and in the event that any kid has a bigger worth, they are traded.


·        This cycle is rehashed until the component is in its right position, keeping up with the maximum pile property.


5. Heapify:


·        Heapify is an activity that changes over a variety of components into a maximum load.


·        Beginning from the last non-leaf hub and going up to the root, the components are "rose down" to their right situations to fulfill the maximum stack property.


·        This interaction guarantees that the whole exhibit shapes a substantial max stack.


The time intricacy of inclusion and extraction in a double max pile is O(log n), where n is the quantity of components in the store. Heapify has a period intricacy of O(n).


Twofold max piles are ordinarily utilized in different applications, for example, need lines, arranging calculations (e.g., store sort), double stack based information structures (e.g., parallel load based execution of a need line), and then some.


In outline, a paired max stack is a finished double tree that fulfills the maximum pile property, guaranteeing that the worth of every hub is more noteworthy than or equivalent to the upsides of its kids. It gives effective inclusion, exDictionaries, otherwise called cooperative exhibits or guides, are a typical information structure that store key-esteem matches. They permit effective addition, erasure, and recovery of values in light of their related keys. The particular tasks accessible in a word reference might differ relying upon the programming language or library being utilized, however here are the normal activities found in word reference information structures:


1. Addition:


·        Embedding a key-esteem pair into a word reference. The worth is related with a particular key, taking into consideration later recovery utilizing that key.


·        Model: dictionary[key] = esteem or dictionary.insert(key, esteem)


2. Update:


·        Changing the worth related with a particular key in the word reference.


·        Model: dictionary[key] = new_value


3. Erasure:


·        Eliminating a key-esteem pair from the word reference.


·        Model: del dictionary[key] or dictionary.remove(key)


4. Recovery:


·        Getting to the worth related with a particular key in the word reference.


·        Model: esteem = dictionary[key]


5. Check for Key Presence:


·        Deciding if a particular key exists in the word reference.


·        Model: key in word reference or dictionary.has_key(key)


6. Size or Length:


·        Acquiring the quantity of key-esteem matches in the word reference.


·        Model: size = len(dictionary)


7. Emphasis:


·        Emphasizing over the keys, values, or key-esteem matches in the word reference.


·        Model: for key in word reference, for esteem in dictionary.values(), for key, esteem in dictionary.items()


8. Clear:


·        Eliminating all key-esteem matches from the word reference, making it unfilled.


·        Model: dictionary.clear()


Program:-

#include<stdio.h>

//#include<conio.h>

struct node{

int key;

char a[50];

struct node*next;

}*head;

int main()

{

int n,choose;

printf("enter no of keys u want to enter");

scanf("%d",&n);

create(n);

display();

printf("enter u r choice");

scanf("%d",&choose);

switch(choose)

 

{

case 1:delnode(n);

        display();

        break;

case 2:search();

       break;

}

}

int create(int n)

{

int i;

struct node*c,*temp;

c=(struct node*)malloc(sizeof(struct node));

printf("enter the key");

scanf("%d",&c->key);

printf("enter name");

scanf("%s",c->a);

c->next=NULL;

head=c;

temp=head;

for(i=1;i<n;i++)

{

c=(struct node*)malloc(sizeof(struct node));

printf("enter the key");

scanf("%d",&c->key);

printf("enter name");

scanf("%s",c->a);

c->next=NULL;

temp->next=c;

temp=temp->next;

}

}

int display()

{

struct node*temp;

temp=head;

while(temp!=NULL)

{

printf("%d:%s",temp->key,temp->a);

temp=temp->next;

}

}

 

int delnode(int n)

{

int x,i;

struct node*temp,*temp1;

printf("enter the key u want to delete");

scanf("%d",&x);

temp=head;

temp1=head;

while(temp!=NULL)

{

if(temp->key==x)

{

temp1->next=temp->next;

temp->next=NULL;

free(temp);

}

temp1=temp;

temp=temp->next;

}

return 0;

}

 

 

int search()

{

int x;

struct node*temp;

temp=head;

printf("enter the element to be searched");

scanf("%d",&x);

while(temp!=NULL)

{

if(temp->key==x)

{

printf("%d:%s",temp->key,temp->a);

temp=temp->next;

}

}

}

Output:-