Search/linkedListMoveToEnd.c File Reference

Task to perform searches in unordered linked list and move to end when found. Load up a linked list of strings and perform number of unordered searches. No check for NULL is used. Move to End of list on a successful find. More...

#include <malloc.h>
#include <stdio.h>
#include "report.h"

Classes

struct  node
 Standard Binary tree data structure to use. More...

Typedefs

typedef node NODE
typedef nodeNODE_PTR

Functions

void construct (int n)
 Method to construct the initial search structure to contain 'sz' elements.
void insert (char *s)
 Method to insert an integer element into the search structure.
int search (char *target, int(*cmp)(const void *, const void *))
 Search for the target within the linked list.

Variables

static NODE_PTR ds
 Head of the linked list of strings.
static NODE_PTR last
 Tail of the linked list of strings.


Detailed Description

Task to perform searches in unordered linked list and move to end when found. Load up a linked list of strings and perform number of unordered searches. No check for NULL is used. Move to End of list on a successful find.

Author:
George Heineman
Date:
6/15/08

Typedef Documentation

typedef struct node NODE

typedef struct node * NODE_PTR


Function Documentation

void construct ( int  n  ) 

Method to construct the initial search structure to contain 'sz' elements.

Simply initialize 'ds' and 'last'.

void insert ( char *  s  ) 

Method to insert an integer element into the search structure.

In our case, we insert the elements into a non-balancing tree.

Parameters:
s Value to be inserted.

int search ( char *  target,
int(*)(const void *, const void *)  cmp 
)

Search for the target within the linked list.

Assume ds and last are never null. When found, move the element to be at the end of the list.


Variable Documentation

NODE_PTR ds [static]

Head of the linked list of strings.

NODE_PTR last [static]

Tail of the linked list of strings.

Algorithm Development Kit 1.0