Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

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

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige

Hier ansehen

1 von 2 Anzeige

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

Herunterladen, um offline zu lesen

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;
list_node=list_node->link;
}
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;
list_node=list_node->link;
}
print minimum;
.

Anzeige
Anzeige

Weitere Verwandte Inhalte

Weitere von rtodd751 (20)

Aktuellste (20)

Anzeige

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

  1. 1. 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;
  2. 2. list_node=list_node->link; } print minimum;

×