Select the correct option to test your answer:
Computer
Miscellaneous On Data Structures
Difficulty: Medium
How many times is the function recursive_min_element() called when the following code is executed? int min_of_two(int a, int b) { if(a < b) return a; return b; } int recursive_min_element(int *arr, int len, int idx) { if(idx == len - 1) return arr[idx]; return min_of_two(arr[idx], recursive_min_element(arr, len, idx + 1)); } int main() { int n = 10, idx = 0, arr[] = {5,2,6,7,8,9,3,-1,1,10}; int min_element = recursive_min_element(arr,n,idx); printf("%d",min_element); return 0; }
More Computer Questions
What will be the output of the following piece of code: class Person{ public void talk() {} } public class Test{ public static void main(String args[]){ Person p = null; try{ p.talk(); } catch(NullPointerException e){ System.out.print("There is a NullPointerException. "); } catch(Exception e){ System.out.print("There is an Exception. "); } System.out.print("Everything went fine. "); } }
This is the stage in database design where one gathers and list all the necessary fields for the database project.
What will be the output of the following C# code? class A { public int i; protected int j; } class B : A { public int j; public void display() { base.j = 3; Console.WriteLine(i + " " + j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.i = 1; obj.j = 2; obj.display(); Console.ReadLine(); } }
How can you quickly reinstate a deleted footer placeholder in master view?
How does the Knuth-Morris-Pratt (KMP) algorithm handle mismatches efficiently?