Question

Describe a parallel algorithm for computing the minimum for n numbers on a linked list.

Describe a parallel algorithm for computing the minimum for n numbers on a linked list.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If we have a linked list containing n elements and we have to find out the minimum number of all elements, we define a function suppose called minimum which takes the head of the linked list containing n elements as argument.

int minimum(Node *head)

{

if(head==NULL) return -1; //that is if the linked list is empty return -1.

Node *temp=head;

int mini=INT_MAX; //we initialise the minimum value by the largest possible integer.

while(temp!=NULL) //we traverse through the linked list

{

int x=temp->data;

if(x<mini) mini=x;

temp=temp->next;

}

return mini; //we return the minimum element

}

(If you liked my solution,Please do give an upvote.Thank You!)

Add a comment
Know the answer?
Add Answer to:
Describe a parallel algorithm for computing the minimum for n numbers on a linked list.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT