Hello, Could any one please answer the following questions. 1.) Describe a recur
ID: 3609503 • Letter: H
Question
Hello, Could any one please answer the following questions. 1.) Describe a recursive algorithm that counts the number ofnodes in a singly linked list. 2.) Describe a linearly recursive algorithm for finding theminimum element in an n - element array. Please reply asp. Thank you Hello, Could any one please answer the following questions. 1.) Describe a recursive algorithm that counts the number ofnodes in a singly linked list. 2.) Describe a linearly recursive algorithm for finding theminimum element in an n - element array. Please reply asp. Thank youExplanation / Answer
Input : Node
Ouput: count
Algorithm CountNodes( Node n , intcount )
{
if( n ==NULL) //there is no node
return;
if (count == -1) //If it is the first node
count=1;
else
count = count+1; //increment the count
call CountNode( NextElement(n) ,count);
Ouput: min
Algorithm MinNodes( Node n , int min )
{
call minNode( NextElement(n) ,min);
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.