Question: 1.1 Linear Search Linear search algorithm is one of the most basic algorithm in computer science to find a particular element in a list of

1.1 Linear Search Linear search algorithm is one of the most basic algorithm in computer science to find a particular element in a list of elements. Linear Searching problemGiven a set of data -> e.g int [] arr = {10, 2, 7, 9, 8, 4}; and a particular value -> e.g., int val = 7; Find the first index of the value in the data. e.g., return index = 2 (because arrays follow 0 index structure i.e. the index of first element is 0 and so on) In this algorithm we compare the required element with each element in the list or array until it is find or until we reach the end of the list.

int main(void) { int array[] = {10, 2, 7, 5, 15, 30, 8, 6}; // input array int value = 30; //value to be searched int arraySize = sizeof(array)/sizeof(array[0]); int result=-1; int i=0; for(i=0; i < arraySize; i++){ if(value == array[i]){ result=i; } } result= -1

Q\ Write a MIPS assembly program for Linear search translating the C code in 1.1.

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!