Consider the following code segment: % outer loop beginning - see question below
ID: 3836207 • Letter: C
Question
Consider the following code segment: % outer loop beginning - see question below % stringVal - list outerIndex); innerIndex - outerIndex; % inner loop beginning - see question below % % data assignment - see question below innerIndex - innerIndex - 1;' % end list (innerIndex) - stringVal % end On line 1 of the code shown above, it is desired to loop as long as the outer index is between one and the number of strings, inclusive. From the following, select the correct code statement to be used onUne 1. Circle the letter to the left of the selection to indicate your answer. a. for outerIndex = 1:1 numStrings b. while outerIndex = 1: numStrings c. while outerIndex x > 1 d. while outerIndex - numStrings: 1 e. All of these selections are correct f. None of these selections are correct. On line 4 of the code shown above, it is desired to loop as long as the inner index is greater than one. In addition, the test string stringVal must be lexically (i.e., alphabetically) less than the element immediately below the current index. From the following, select the correct code statement to be used on line 4. Circle the letter to the left of the selection to indicate your answer. a. while innerIndex > 1 && stringValExplanation / Answer
4(a) for i =1 : 1 : numStrings
Explanation : This instruction will start from 1 and increase the index by 1 till numStrings
5(a) while innerIndex > 1 && stringVal < list (index - 1 )
Explanation: In addition to it is given means its a necessity So its AND condition..If either word was given then Its an || condition.
6(d) list(innerIndex ) = list(innerIndex - 1 )
Explanation : means innerIndex is assigned one string below it
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.