Question
What is the running time of the following code fragment? for(int i=0; i <10; i++) for(int j=0; j
What is the running time of the following code fragment?
for(int i=0; i<10; i++)
for(int j=0; j for(int k=N-2; k System.out.println( i +" "+j); O(n) O(n2) n squared O(n log n) O(n3) n cubed question 2: void fun1 ( Node curr) { if (curr == NULL) return; fun1(curr.next); System.out.print(" "+curr.data); } Prints all nodes of the linked list in order Prints alternate nodes in reverse order Prints all nodes of the linked list in reverse order Prints alternate nodes of the Linked List que 3: long fictitious(int n) { if (n == 0|| n==1 || n==2) return n; return fictitious (n - 1) + fictitious (n - 2)+ fictitious(n - 3); } Suppose n was a very large integer( like 100). What technique would you use to maximize the performance of the recursive code implemented above? Use multiple base cases Use memoization Call another recursive method to help Use 1 extra base case
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started