Algorithms
Assume that we have a computer in which computations can only be done in the registers: R [o] , R[1].R[2].....R[m-1].Memoryaccessesarepipelined so that memorylocations M[h] M[h+1], M[h+2],... M[h+d-1] can bc moved to and from registers R[g], R[g+1], R[g+2], . R[g+d-1] at cost of(h+ Bd, where and are constants and fh is anondecreasing function, all dependent on the actual computer. There is a computer dependent constant, s, such that the computer can read or write at most s values at a time (so d must be < s). To keep things simple, we assume that the number of registers is not much larger than s; perhaps m = s+ 16 The two instructions are read(g,h,d),which copics M[h], M[h+1],...M[h+d-1] to R[g], R[g+1],..., R[g+d-1] and writeg,h,d),which copics R[g], R[g+1],. .,R[g+d-1] to M[h],M[h+1],...M[h+d-1]
Problem 1. Assume that an array of n numbers are in memory locations M[1], M[2], M[3],.. M[n]. Show how to implement bubble sort on the array. Give the pseudo-code. You can assume that a small number of index variables (such as i, j, and n) are in register locations > s, so that you can just use their names in your program and not worry about their register locations