/*** This algorithm has a problem: It has to return the result of the search and an updated list ***/ /*** right now it is broken, not to be used ***/ datarecord *search( key, list ) typekey key; datarecord *list; { datarecord *p, *q; if ( list!=NULL && key!=list->k ) /*** Find record ***/ for ( p=list; (p->next)!=NULL; p=p->next ) if ( key==p->next->k ) {/*** Move to front of list ***/ q = list; list = p->next; p->next = p->next->next; list->next = q; break; }; if ( list!=NULL && key==list->k ) return( list ); else return( NULL ); }