Exercise 8 - Struct
Last updated
Last updated
The six-star (hardest) question fro CS1010. (Supposed to be)
This question is nothing but tedius. Break the big problem into small problems and solve it. The trickest two parts are as follows:
This involves the technique of searching and sorting. Since the list is unsorted, so we just need to use linear search to find the smallest 5 neighbors. The time complexity is . When doing linear search, follow strictly to what states to write your conditions.
To predict the number using the k-nearest neighbors you have found, there is nothing special, just follow strictly what the states to write the conditions.