Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

dy dx Find the derivative of the function y=(4x+3)5(2x+1)2.

Answered: 1 week ago