Open atanaspatterson opened 4 months ago
I will code review this!
I will be peer reviewing this :)
Code Review suggestions:
Your functions are well named!
A few minor tweaks: hard coding the size is sort of iffy but sizeof() does return an error so I understand. Similar to above, the intersection function seems to print the entire array rather than only the items that intersect. Same thing happens with union:
int testarray[] = {1, 4, 18, 3, 34, 6, 7, 4, 9};
int array[] = {1, 3, 3, 3, 3, 4, 5};
Union: 1 3 3 3 3 4 5 6 7 9 18 34
Adding to the above comment, other data types like floats or doubles would be a way to add to your project.
Otherwise good job!
Nice work! Here are my suggestions for some minor issues:
Looks good. The 3 code reviews cover what needs to be changed, although you don't need to support data types beyond int (that can be added in a future semester) or move anything to user.h.
This is lacking documentation as well, and I think in this case it's certainly something the library needs.
At this point I believe I have addressed all of the code review points!
I found memory leaks after running my leak check on your testarrays.c:
-- Leak Check -- [BLOCK 0x0000000000006070] 64 '' [BLOCK 0x00000000000060B0] 64 '' [BLOCK 0x00000000000060F0] 80 '' [BLOCK 0x0000000000006140] 80 ''
-- Summary -- 4 blocks lost (288 bytes)
Adding the following code to testarrays.c could resolve the issue: free(intersection); free(arr); free(union_arr); free(union_arr2);
Thanks!
Added the following functions (user/arrays.h, user/arrays.c, user/testarrays.c file ):
void print_array(int arr, int size); void sort_int_array(int arr, int size); void delete_at_index(int* arr, int index, int size); void add_at_index(int* arr, int value, int index, int size); int binary_search(int arr, int target, int size); int array_union(int arr1, int arr2, int size1, int size2, int new_size); int array_intersection(int arr1, int arr2, int size1, int size2, int *new_size);