Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part I: Algorithm Analysis 1 . You are given two linked lists with O ( n ) elements. You are asked to find the intersection

Part I: Algorithm Analysis
1. You are given two linked lists with O(n) elements. You are asked to find the intersection of two lists. Assume that the sets dont have duplicates and not sorted, and also assume that comparison operation is a simple statement and it takes O(1) time.
a. Please provide a pseudo code that has the growth rate of O(n2)
b. Improve your solution, and give a pseudo code that has a better growth rate which is O(nlogn).
c. Is it possible to make it O(n)? Please provide a pseudo code for your solution, if any.
Note: You can call other functions use other data structures, you dont need to give pseudocodes for those functions. Just know their run time complexity.
2. You are given the following pseudocode for an algorithm:
1 method1(n)
2 if n==0
3 return 0
4 else
5 return method2(n-1, n-1)(n-1)
6 method2(m, k)
7 if m==0
8 return method1(k)
9 else
10 return 1+ method2(m-1, k)
a. What would be the output for the following method call?
System.out.println(method1(4));
b. Please provide the recurrence form for the running time function of this algorithm.
c. Please find the growth rate of the algorithm in Big-O notation.

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

Step: 3

blur-text-image

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

How is the NDAA used to shape defense policies indirectly?

Answered: 1 week ago

Question

2. To compare the costs of alternative training programs.

Answered: 1 week ago

Question

1. The evaluation results can be used to change the program.

Answered: 1 week ago