Question: Let L = In 1 , n 2 , . , n 2 0 } be a list 2 0 distinct in - tegers. The

Let
L = In1, n2,.,n20} be a list 20 distinct in-
tegers. The integers in the list are randomized and then inserted in an array A[1...20] of size
20. See outline of an algorithm below. It starts with an initial count of 'zero'. If an element A[i]< A(20], then line 4 increments the count by one and Ali] is moved to A[20]
FINDTHENUMBEROFTIMESA[20]IsUPDATED(A)
1 COUNT =0
2 FOR i =1 TO 19
3
IF Ali]< A|20]
4
COUNT = COUNT +1
5
A[20]= A[i]
6 return COUNT
(a)[10 points] What is the expected number of times line 4 of the algorithm will be ex-ecuted, that is, how many times the expression (A[i]< A[20]) is expected to be true.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!