Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[20 points] The following program determines the maximum value in an unordered array A[1n] of distinct elements: 1. max= 2. for i=1 to n do

image text in transcribed

[20 points] The following program determines the maximum value in an unordered array A[1n] of distinct elements: 1. max= 2. for i=1 to n do 3. compare A[i] to max 4. if A[i]>max then 5. max=A[i] (a) If a number x is randomly chosen from a set of n distinct numbers, what is the probability that x is the largest in that set? (b) When line 5 of the program is executed, what is the relationship between A[i] and A[j] for 1ji ? (c) For each i in the range 1in, what is the probability that line 5 is executed? (d) Let s1,s2,,sn be n random variables, where si represents the number of times ( 0 or 1) that line 5 is executed during the i-th iteration of the for-loop. What is E[si] ? (e) Let s=s1+s2++sn be the total number of times that line 5 is executed during some run of the program. Prove that E[s]=(logn)

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

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

Discuss the continuity of the function. f(x, y, z)= xy sin z

Answered: 1 week ago

Question

Explain the various techniques of Management Development.

Answered: 1 week ago