Spec 3 comments
This lab took me ~1 hour. The lab itself I think is pretty good. Here's my feedback.
- The
Random.nextInt()
function used to generate array lengths in the stress test can generate negative numbers. It should be surrounded with aMath.abs()
to prevent that. - The stress test often led to my computer running out of memory on the heap because
Random.nextInt()
can generate massive values for array lengths. I think we should useRandom.nextInt() % 1000
or something like that. - I had some issues with using
linearSearch()
as the ground truth value forbinarySearch()
when the randomly generated array in the stress test had duplicate values. For example, one of my randomly generated arrays had the needle value at both index 674 and 675. ThelinearSearch()
found 674, while mybinarySearch()
found 675. I'm not sure how to address this, although I did find I could avoid duplicates if I used a sufficiently small array (i.e.Random.nextInt() % 900
was fine for the length).
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information