Diese Präsentation wurde erfolgreich gemeldet.

# Given an unsorted linked list- how to find the minimum element-Solutio.docx

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige  ×

1 von 2 Anzeige

# Given an unsorted linked list- how to find the minimum element-Solutio.docx

Given an unsorted linked list, how to find the minimum element?
Solution
it is simple to find the minium element in the unsorted array or linked list.
first you to look at all the elements of the linked list.
the alforithm is as follows:
minium=first element
repeat untill last position
{
if(minimum>next element)
minimum= next element
}
like this we compare all the elements in the linked list by updating the minimum element with minimum value occured duiring the comparision.
the psudo code for this algorithm is
minimum=list_node->data;
while(list->next !=NULL)
{
if(minimum>list_node->data)
minimum=list_node->data;
}
print minimum;
.

Given an unsorted linked list, how to find the minimum element?
Solution
it is simple to find the minium element in the unsorted array or linked list.
first you to look at all the elements of the linked list.
the alforithm is as follows:
minium=first element
repeat untill last position
{
if(minimum>next element)
minimum= next element
}
like this we compare all the elements in the linked list by updating the minimum element with minimum value occured duiring the comparision.
the psudo code for this algorithm is
minimum=list_node->data;
while(list->next !=NULL)
{
if(minimum>list_node->data)
minimum=list_node->data;