Describe a parallel algorithm for computing the minimum for n numbers on a linked list.
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!)
Describe a parallel algorithm for computing the minimum for n numbers on a linked list.
Describe in detail an algorithm for reversing a singly linked list L using only a constant amount of additional space and not using any recursion.
Describe in detail an algorithm for reversing a singly linked list L using only a constant amount of additional space. Please provide pseudocode for Java.
Q.(1)Describe the algorithm and java implementation for the following operations A. Create a singly linked list L1 with 4 nodes. You can use insert operation to add nodes to the list. Each element represent an airport code (e.g. BOS, ATL, JFK, MSP, etc.). Display the list L1 after it is created. B. Given singly linked list L1, create another singly linked list L2 that contains the same elements but in the reverse order. Display the content of both L1 and...
1. a) Describe an O(m)-time algorithm that, given a set of S of n distinct numbers and a positive integer k c n, determines the top k numbers in s b) Describe an O(n)-time algorithm that, given a set of S of n distinct numbers and a positive integer k < n, determines the smallest k numbers in S.
Given a list of numbers in random order, write an algorithm that works in O( n log(n) ) to find the kth smallest number in the list.
Describe an algorithm that takes as input a list of n integers and produces output the smallest integer in the list.
write an algorithm (algorithm appendToItself(pList)) that appends a list to itself, using linked-list implementation [hint: you may want to utilize insertNode algorithm we developed in the class together]. The desired language is C.
In c++: create an algorithm to convert the 2D matrix into a linked list. what is the BigO of the algorithm?
Discrete Mathematics
5. i) Describe an algorithm that, upon input of a number n given in base 10, outputs the digits of n in base 8, starting from the rightmost. Esrample: If you are given the number 156, the output will be 432, because (156) 10 = (234)s. ii) What will be the complexity of the algorithm? You may assume that performing the division algorithm upon two numbers to find the quotient and remainder is the basic operation. (As a...
For a 2-3 tree containing real numbers, design an algorithm for computing the range (i.e., the difference between the largest and smallest numbers in the tree) and determine its worst-case efficiency.