The Myth of Algorithms and Data Structures

Welcome to this page! First, and foremost, this page is not meant for learning purpose, nor is it meant to flex my programming skills (assuming I have that).
Then Prabhav, what is this page about? Hmm, nice question. This page is meant to share random thoughts and concepts about approaching to solve problems in Competitive Programming, which are not-so-obvious at least to me.
I think being pensive about one idea can generate many other ideas and hence, many ways to tackle more "complex" (whatever this means) problems. Hence, I believe this page is meant to reflect upon the abstract idea built around one concept and break down that myth and gain the power to break it down much more.
Isn't that what the objective of "learning" is? Let us do that with pure heart.

Enough talk, let's begin *evil laughter originating from the corner*
(I might try to divide it into specific algorithmic section provided the blog's content becomes vast and cluttered enough)

DP Tip #1:
If you think that we can come up with a formula to solve a problem, check the formula through induction once before coding up the solution! It might seem correct for small values, but for larger values, it might create a problem.
An example can be found here. For small cases (n<=6), you can come up with a formula 2^(n-1), but unfortunately, it won't hold true, for obvious reasons.

General Tip #1:
Conversion from long long to int makes the code a bit faster, improves the time complexity slightly. Can be implemented in problems where time constraints feel a bit strict.

DP Tip #2:
In some cases, even the ordering of loops become significant, make sure you know at what point of time the state corresponds to what value.

No comments:

Post a Comment