Find the highest and lowest element from a linked list?
To find the highest and lowest elements in a linked list,
iterate the list and detect the highest and lowest elements.
Details omitted ...
list *head; /* pointer to first element */
list *temp; /* temp pointer
list *high = null; /* pointer to high element */
list *low = null; /* pointer to low element */
for (temp=head; temp!=null; temp=temp->next) { /* iterate all
elements */
if (temp == head ) { /* initial case */
high = low = temp; /* start accumulating results
} else { /* otherwise */
if (higher(temp, high) high = temp; /* choose higher */
if (lower(temp, low) low = temp; /* choose lower */
}
}