Beginning with competitive programming series : Chapter 0
My last post encouraged lot of students to ask me,
HOW TO BEGIN COMPETITIVE PROGRAMMING FROM SRATCH ?
So I am planning to write a series of chapters to cover it based on the response I get from my readers.I will try to lay down a structural way to begin competitive coding so you don't commit obvious mistakes and learn important lessons early in your journey.
Chapter 0
PROLOGUE
Excelling any skill requires spending time on it. Well it's simple right, the more time you give to something, the more knowledge you will have about it. More time you will spend in watching a show, more knowledge of the characters you will have, not that it matters but you get the bigger picture.Hundreds of books or posts(including mine) or videos or courses will do no good to you, unless you follow them and spend time actually learning and practising stuff.
I will try to cover some basic aspects of competitive programming which will help you lay a strong foundation.
So before we jump into learning data structures, practising lots of questions. Let's choose the tool which will help us achieve wonders. The tool I am referring to is the programming language which you will use to code your solutions while practising, giving contests and so on and so forth.
Choose a programming language
If you are already programming in a particular language you can skip this unless it is C. Choose a programming language which provides libraries with prebuilt maps/dictionaries, sets, etc. So that you don't have to implement them during contest.Since all coding platforms and most companies, during hiring events, allow programmers to use these libraries as they are more interested in problem solving skills.
Don't waste much time in choosing the language
Most popular languages used include C++ which provides STL or Java which provides Collections. Python is also used by many programmers. So I will leave this upto you. As for me I code in Java.
Learn the basics
Well great you have chosen your language, now it's time to learn it.If you have completed your 1st year of engineering, you would already be familiar with syntax of C language. So moving to C++ will be easier for you. Also, if you want to learn Java, Python you will have to learn them in one of the following ways:
- Enrol in a course/watch online videos : There are lots of online courses/free videos which help you do it. The downside with random videos is to maintain structure in learning.
Recommended courses
CODING FOUNDATION IN JAVA (Use KUNAL10 for additional 10% discount)
Python free course - Read books, blogs: Reading is at times boring and difficult to follow, however can provide more insights on any topic.
Recommended books
Head First Java: A Brain-Friendly Guide
Effective Java
Some common features which are present in all languages and are used to implement easy to complex solutions are listed below.
- Data types : int, long, character
- Basic operators : Add, subtract, multiply, divide, modulus
- Loops : for, while, do-while
- Decision making : If/else , switch case
- Composite data types: Strings, arrays,
It is imperative to practise whatever you have learnt, to be sure you can actually code in the programming language without making syntax errors.
Learn predefined data structures and algorithms
Don't forget why you picked up the programming language. The main aim is to have some predefined standard data structures and algorithms which you can use when needed, without having to implement them.So it will be appropriate to learn below topics as part of learning the language only. I will write about their usage later.
Some common data structures and algorithms which are provided in libraries and help reduce the implementation time are given below.
Some common data structures and algorithms which are provided in libraries and help reduce the implementation time are given below.
- Sorting
- Binary Search
- Finding maximum/minimum in a list
- Reversing a list
- Stack
- Queue
- Priority Queue/Heap
- Set
- Map
- ArrayList/Vector
These are provided in Java, C++,Python and are extensively used in solving problems.
It is important to know the actual implementation of these data structures and algorithms Do not Skip that!
Sometimes, you will not have the luxury of using these like during interviews and some contests so if you don't know them, you will be at great loss.
Next steps
Once you have mastered coding in the language you choose, you are ready to learn about complexity, data structures and algorithms. Well you could have done it even before knowing a language but what good it would do learning theory, after all you cannot write down theory as a solution to a problem.
Watch out for the next blog about time and space complexity. How they define the effectiveness of any solution for a particular problem.How you can think of solutions based on the constraints given in a problem and so on.
Helpful! Keep posting
ReplyDelete