Should such CS coursework be subject to plagiarism? I just joined a new CS course and have some trouble understanding whether I should be worried that my coursework is to be considered plagiarized or not. The following is the situation.

I am doing a systems programming project with math. Our professor gave us numerous working code samples and math which can be directly copied over to a program with few changes. Some trivial details about the codebase structure was omitted, but can be easily derived by simple reverse engineering from the provided code samples with some effort; it is very intuitive.

Very few non-trivial details were omitted in the provided code samples and that is where the real effort to distinguish one solution from another is at in my opinion; this is less than 5% of the entire codebase.

The matter becomes more complicated because the answer to this coursework is available online by other students. Looking at the solution of other students, 
one can't help but to see more or less the same solutions with minor variations.

Because I have looked at the solution of other students while developing my own solution, I can't help but feel guilty for having absorbed some of their ideas and thus leading to similar program structure. At the same time, all of us have been using the professor's code samples as our main resource. Where I thought I could improve the structure of the program or add features which were incorrect or omitted by other students, I have done so. So there are some differences from other solutions, but not that much.

So I am conflicted regarding whether I should be worried that my solutions is considered plagiarized in this scenario or not. I guess my solution resembles more a "highly patched up copy" rather than being different from the "ground up".
This is basically a request for opinions because there isn't a general answer to the definition of plagarism in coding. Borrowing code is a huge part of learning how to code!

That said here are my guidelines for myself:

make choices you're comfortable with. 


If it feels wrong it probably is. You should be willing to openly stand by every decision and every google search. 

add comments with sources throughout your code. 


This will make things way easier just from a coding perspective and if you're accused of plagarism, makes it easier to argue that you were not intending to do so. 

In particular, I link to stack exchange answers that were helpful, especially to questions I asked. 

you could even put a link to this thread in your submission code somewhere so that you can demonstrate that you clearly thought about academic honesty. 

Intent matters a lot in plagiarism at a grad or post grad level. It's when things are getting published that it becomes much more objective.