//move to front //improve searching by moving the searched node to the front so that another time it is searched, it will be found in less time //function for moving a node to the head (in search operation) Search(Node *p, int key){ Node *q= NULL; while(p!= NULL){ if(key==p->data) { q-next= p->next; p->next= first; first = p; } q= p; p=p->next; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter