Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

UL 2 0 / 0 0 3 2 ALGORITHM 1 function A 1 ( root , x ) Q = new Queue ( ) ENQUEUE

UL20/0032ALGORITHM 1
function A1(root,x)
Q= new Queue()
ENQUEUE (Q, root)
while ! ISEMPTY(Q) do
t=PEEK(Q)
if (t==x
return TRUE
else
ENQUeUe(Q,left(t))
, right (t
DEQUEUE (Q)
end while
return FALSE
end function
Note: the function ENQUEUE only inserts
a new element in the queue if this element
is different from NULL
See the image as reference of two algorithms.
Here are the questions:
(a) see the image
(b) see the image
(c) What is the task performed by algorithms A1 and A2? Dont forget to
mention the return values for the different cases [4]
(d) What is the worst-case time complexity of A1? Use Theta notation [1] and
explain your reasoning [3][4]
(e) Assuming a fully balanced BST (a BST with all its levels fully populated) of N
elements, what is the recurrence equation describing the running time of A2?
[4]
(f) What is the worst-case time complexity of A2? Use Theta notation [1] and
show your workings [3][4]
(g) Which algorithm do you recommend to implement? Why? [6]
image text in transcribed

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

What is a playback robot with point-to-point control?

Answered: 1 week ago

Question

KEY QUESTION Refer to Figure 3.6, page

Answered: 1 week ago