I know the feeling. I think you would be surprised but I would venture to say that EVERYONE feels inadequate at one time or another. Perfectly normal. There's a book I highly recommend that has really helped me called Feeling Good. Its basic premise is that whenever you have a negative thought you can challenge that negative thought. For instance, you might be feeling "everyone is better than me." The, what the author calls, "rational response" is something like, "Of course EVERYBODY is not "better" than me. Sure there are some people that might be farther along academically but that doesn't mean they are better than me. There are probably some folks who are in my same situation or worse."
The other approach is to always give thanks for your blessings because regardless of how bad things seem sometimes, there is always something to be grateful for. Could be trivial, could be big. Sounds like your taking some interesting courses. Good luck and enjoy!