You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you read and understand the instructions, it's easy. You need to be aware that the result of mapF for the KeyValue Value should be a string, which will be "1" in this case. The reduceF needs to be converted to perform summation.
It's pretty simple if you don't consider Part 4. You just need to learn non-buffered channel. Take out the task -> assign worker -> complete call wg.Add.
這樣一來 最內層完成所有task時 會讓mainloop結束 離開
I think this is the most challenging part. I originally wanted to try using Mutex, but I found it more complicated and difficult to write. You need to use buffered and non-buffered channels to accomplish this. Two layers of goroutines are required. The first layer continuously retrieves worker tasks, and because it is a non-buffered channel, it will be blocked if there is no task available. In the inner layer, get an available worker and task (make sure the worker is idle and the task is not completed) and use wg.Add if it is completed. The main loop in the outermost layer uses wg.Wait. This way, when all tasks are completed in the innermost layer, the main loop will end and exit.
Part 5
聽過TFIDF,應該很好寫
If you've heard of TFIDF, it should be easy to write.
Lab 2
A
很難寫
一開始寫了一版本 只能過第一個測試
後來參考別人的解答 修改程式架構 再修一些bug就過了
It's difficult to write. I wrote one version at first, but it only passed the first test. Later, I referred to other people's solutions, modified the program structure, and fixed some bugs, and then it passed.