Question: this is Mathematical concept in computing 2.thank you Consider the following procedure called whatisthis whose input is assumed to be a sequence of distinct integers.

 this is Mathematical concept in computing 2.thank you Consider the followingprocedure called whatisthis whose input is assumed to be a sequence of

distinct integers. 1 procedure whatisthis (a1, 22, ..., an) 2 for jthis is Mathematical concept in computing 2.thank you

Consider the following procedure called whatisthis whose input is assumed to be a sequence of distinct integers. 1 procedure whatisthis (a1, 22, ..., an) 2 for j := 2 to n 3 key := aj 4 i:=j-1 5 while (i >0 and ai > key) 6 7 Qit1 := ai := 1 key 8 Ai+1 := Please answer the following two questions, (A) and (B). Part (A) is multiple choice; part (B) asks you to fill out a table. For part (B), make a similar table in your notes and fill it out. (A) Procedure whatisthis (1) sorts its input in ascending order (2) sorts its input in descending order (3) reverses the order of its input elements (4) always replaces ai with the largest element of its input sequence (if aj is the largest, its position is unchanged) (5) multiplies each input element by 2 (6) multiplies each input element by n (For part (A), select all that apply; if only one answer applies, select one answer) (B) Now suppose the following sequence is passed to whatisthis as input: (3, 2, 4, 5, 1,6) Trace the execution of whatisthis to determine the value of the sequence after each iteration of the for loop. Fill out the table below. j after line 8 (see pseudocode) is executed, the input sequence becomes: 2 3 4 5 6

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 Databases Questions!