Answered step by step
Verified Expert Solution
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
You are given two linked lists with On 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 time.
a Please provide a pseudo code that has the growth rate of On
b Improve your solution, and give a pseudo code that has a better growth rate which is Onlogn
c Is it possible to make it On 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.
You are given the following pseudocode for an algorithm:
methodn
if n
return
else
return methodn nn
methodm k
if m
return methodk
else
return methodm k
a What would be the output for the following method call?
System.out.printlnmethod;
b Please provide the recurrence form for the running time function of this algorithm.
c Please find the growth rate of the algorithm in BigO notation.
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