Você está na página 1de 2

BST: Left_subtree (keys) ≤ node (key) ≤ right_subtree (keys) struct node* search(int data){ struct

node *current = root; printf(“Visiting elements: “); while(current->data != data){ if(current != NULL)
{ printf(“%d “,current->data); if(current->data > data){ current = current->leftChild; } else {
current = current->rightChild; } if(current == NULL){ return NULL; } } } return current;
} Void bfs(int v) {for( i=0>=n;++ ) if (a[v][i]&&! Visited[i]) q++r=I if(fz=r) { visitd[q[f]]=1 bfs(q[f++]) ;
} } Void dfs(int v) int I; reach [v]=1; for( same)if (a[v][i]&&! Rech[i]) {prif(“%d is %d”, v, I) ; count++;
dfs[i] } } } Mynode*recursive_search(int item, mynode *root) {if(root=NULL item == root->value) {
return(root);} if(item <root->info) {return recursive_search(item, root->left); }else{return recursive
search(item,root->right); }}bool iterative Search(struct Node *root, int key) { while (root != NULL) { if
(key > root->data) root = root->right; else if (key <root->data)root root->left; else { return true;// if
the key is found return 1 } return false; } Alg to add two polymals – Let p and q be th two polymals
represented by linked lists 1. While p and q are not null, repeat step 2. 2. If powers of the two terms ate
equal then if the terms do not cancel then insert the sum of the terms into the sum Polymal Advance p
Advance q Else if the power of the first polymal power of second Then insert the term from first
Polynomia into sum polymal Advance p Else insert the term from second polymal into sum polymal
Advance q copy the remaining terms from the non-empty polymal into the sum polymal. The third step of
Radix-Sort (list, n) shift = 1 for loop = 1 to keysize do for entry = 1 to n do bucketnumber = (list[entry].k
ey / shift) mod 10 append (bucket[bucket number], list[entry]) list = combine buckets() shift = shift *
10 Insertion Sort(A[0..n-1]) /Input: An array A[0..n-1] Output: Array A[0.n 1] for I <1 to n-1 do v< A[i]
j<i-1 while j>= 0 and A[j] > v do A[j+1] → A[j] j<j-1 A [j+ 1]<v static void reverse(struct Node**
head ref){ struct Node *prev = NULL; struct Node* current = *head_ref; struct Node*next; while
(current!= NULL){ next = current->next; current->next= prev; prev = current; current = next; }*head_ref
= prev; }(ii) void concatList(Struct node **list1, struct node **list2) { struct node *temp: if (“listl =
NULL) { *list1= *list2; else if (*list2){ temp=*list; while (temp->nxtPtr) { temp=temp->next Ptr;
}temp->nxt Ptr= *list 2; }return; void insert_front(struct Node** head_ref, int new_data) $ struct
Node* new_node=(struct Node* )malloc(sizeof(struct Node)); $ new_node->data = new_data;
$new_node->next = (*head ref); new_node->prev = NULL:$ if((*head_ref) != NULL)$ (*head_ref)-
>prev = new_node; $(*head_ref) = new_node: DELETE void deleteNode(struct Node **head_ref,struct
Node *del) if (*head_ref ==NULL || del == NULL) return; $ if (*head_ref == del)$ *head_ref=del-
>next; $ if(del-> Next != NULL) del->next->prev = del->next: if( del->prev !=NULL) $del->prev->next =
del->next; free(del): return;} ---- the algorithm is to be processed till the end of the
polymals has not been reached b.

Você também pode gostar