CSc265 Lab 3 - Inspection Team Name: Team Members: For the code on the right hand side of this page, carefully examine each function and make sure that it conforms to its specification in the comment block above it, and that it does not violate the assumption given. If you find a fault in one of the functions, enter the line number on which the fault occured and give a brief description of the fault. Also check the code in the main() function for faults. *Note: do not suggest a fix for a bug, just briefly describe what is wrong. Line # description of fault ________________________________________________________________ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #include /* if x is in a[0..n-1] then return its index else return -1 * Assume: n >= 0 and a has at least n elements */ int findpos(int a[],int n,int x) { int i; for (i = 0; i < n; i++) if (a[i] == x) return i; return -1; } /* Shift the elements of a[startpos..endpos] left one position * Assume: 0 < startpos <= endpos < N, * where N is the number of elements in a */ void shiftleft(int a[],int startpos,int endpos) { int i; for (i = startpos; i < endpos; i++) a[i] = a[i+1]; } /* Eliminate all values in a that are not in b. * More precisely, modify a so that a[0..alen-1] contains only * the values originally in a[0..alen-1] and also in b[0..blen-1]. * Change alen to reflect the new length of a. */ void intersection(int a[],int *alen,int b[],int blen) { int i; for (i = alen-1; i >= 0; i--) { if (findpos(b,blen,a[i]) != -1) { shiftleft(a,i,*alen-1); (*alen)--; } } } main() { int a[] = {1,3,5,7,9}; int alen = 5; int b[] = {1,5,9}; int blen = 3; int i; intersection(a,alen,b,blen); for (i = 0; i < alen; i++) printf("a[%d]: %d ",i,a[i]); printf("\n"); }