Algorithms
Effective usage of the
course
Mostafa S. Ibrahim
Teaching, Training and Coaching for more than a decade!
Artificial Intelligence & Computer Vision Researcher
PhD from Simon Fraser University - Canada
Bachelor / Msc from Cairo University - Egypt
Ex-(Software Engineer / ICPC World Finalist)
Studying Algorithms
● Algorithms course is one the hardest courses for most students!
● Here are the possible scenarios:
○ You don’t understand the algorithm itself.
■ Repeating the materials 2-3 times, or using alternative sources will resolve this
○ You got the algorithm and its intuition, but you can’t understand the formal proof
■ I don’t present formal proofs in this course. You will do that on your own
■ You will give a trial. Keep going. Repeat later.
○ You got everything, but can’t solve non-trivial problems: this is the obstacle!
■ People who love problem solving, puzzles, and mathematics find it a reasonable
challenge
■ Others may find it more difficult to proceed smoothly
Gaining the skill: Fundamental facts!
● Problem-solving is NOT an easy skill to master
○ It will be painful but fun
○ It will take a lot of time and repetition
○ You will even fail to re-solve a problem you solved before
○ The process will change your mind totally
○ You must be patient!
○ You will have to repeat topics related to recursion a lot. This is normal!
● Make sure you have basic problem-solving skills from programming
○ Optional but recommended; solve easy algorithmic problems
○ You may use LeetCode website for that
○ Or solve from my Interviews sheet
○ Or solve from my competitions sheet if you target competitive programming
Gaining the skill: Fundamental facts!
● Practice makes perfect!
○ Consistency is KEY! Stopping/Starting is INEFFECTIVE and INEFFICIENT, and leads to
WEAK SKILLS.
○ Make sure to dedicate 5-10+ hours weekly
○ You must solve in the right way: you have to make an honest and earnest initial attempt
■ Never go to the solution without first making a SERIOUS attempt at the problem
■ Always approach learning with a positive attitude.
■ Dismiss doubts such as 'you can't do this'/'you're not good enough'
A serious trial for solving
● A common highly wrong approach
○ Try the problem for a few minutes
○ Tell yourself: 'I can't do it'/'It's too hard' etc...
○ 'I'll just check the solution, and learn from that!'
● Challenge yourself
○ When you read the problem, make a determined effort to solve it by yourself
○ When you get a hint, make another determined effort to solve it by yourself
○ When you think for X minutes, then your mind was training for X minutes, regardless of the
output!
■ Many students think If I couldn’t solve it, I wasted my time ⇒ This is wrong!
● Use a time-limit. Maybe 45-60 minutes. Don’t waste days on a few problems
○ If you have more thoughts, feel free to occasionally go beyond your self-imposed limit
Tackling a problem
● Please take 45-60 minutes to make a determined attempt at the solution.
(Feel free to take longer if necessary)
○ If you can’t make progress, check out my solution
○ If a hint is given, stop the video and make another sustained attempt for 5-10 minutes
○ If you eventually have to listen to my solution: please rewrite the code
■ It's BEST to try to rewrite it in your own style
● What if you can’t understand my solution?
○ Put it in a ToDo list and try it again later
● Think ahead
○ When you read an editorial or listen to a solution, don't listen to it all the way through
○ With every clarification or hint, think for another 5 minutes about it
○ This will make you stronger. You will learn the materials faster
ToDo list approach
● This is simple and effective
● When you can’t solve a problem
○ You made a sustained attempt for 45-60 minutes, without success.
○ Then you tried to understand my videos and editorials, but still can’t get it
● Don’t feel frustrated. This will happen a lot!
● Just mark it in your ToDo list
● Keep going and solve other problems
○ This, by itself, is increasing your problem-solving skills
● From time to time, return to the ToDo list
○ Surprise: you will likely find yourself able to solve some of them
● It's still okay if some problems remain unsolved!
○ Improvement will come over time
Solving order
● Some students just keep learning the algorithms and later, after the course is
done, they come back to solve the challenges
○ DON’T DO That
● What matters is the skill NOT the knowledge!
● There are a few ways to order the challenges
○ Path1: Solve easy and a few medium problems per topic first. Later solve the remaining
challenges. Recommended.
○ Path2: For each topic, try/finish all its problems.
● If you did well in this course, preparing for interviews is a smooth experience
Psychological Concerns
● Don’t compare yourself with your friends
○ Many factors decide the speed and level of progress in each one of us
○ Compare against yourself!
● Be cautious about unrealistic expectations: it is a long and difficult path
○ But you can do it with: 1) proper prerequisites/background 2) consistent long effort
● Be careful about the illusion of effort
○ E.g. solving a lot of easy problems. You must challenge yourself!
● It WILL be frustrating
○ You will fail a lot. You will have to repeatedly cover challenging materials.
● Some boredom might be inevitable
Eliminating Boredom
● Avoid distractions & social media
● Think about your priorities:
○ Don’t train less or more than you scheduled
● Stay motivated … be positive
● Google ‘Relaxation Techniques’
● Spirituality
● Learn new things … do other activities
● Socialize
● Arrange breaks: daily, weekly and long-term
“Acquire knowledge and impart it to the people.”
“Seek knowledge from the Cradle to the Grave.”