Question: Consider the following algorithm for searching for a target integer k in an array of five integers: // Declare and read varaibles integer k
Consider the following algorithm for searching for a target integer k in an array of five integers: // Declare and read varaibles integer k integer array (5) A integer i k = Get next input i = 0 while (i < 5) A[i] = Get next input i = i + 1 // Search for k in the array i = 0 while (i < 5) if (A[i] == k) Put "Found" to output else Put "Not found" to output i = i + 1 Given the following inputs, what will this algorithm output? k = 1 A = [ 0, 1, 1, 0, 1 ]
Step by Step Solution
3.27 Rating (156 Votes )
There are 3 Steps involved in it
The given algorithm searches for the target integer k in an array A of five integers It uses a while ... View full answer
Get step-by-step solutions from verified subject matter experts
