Monday, July 05, 2010

What algorithms should new CS students learn first?

Back in my college days, I tutored a lot. I actually paid my way through college by teaching computer programming to many students. At last count, I think I have taught C, C++, and Java to almost 150 students in total. And along the way, I taught them the basic algorithms they could test out.

Which brings on the question: what algorithms should newbies learn first?

From my experience, I think first-timers ought to start learning simple things (such as finding the maximum of three numbers), then progress towards slightly complex versions of these problems (such as finding the maximum of n numbers). Then they should focus on things such as finding the GCD using Euclid's method; Binary search, etc. Sorting can come next, and I started teaching my students Bubble sort (yes, I know, it's the worst performance algorithm, but easy for people to grasp, compared with Quicksort!!).

Once the students master searching, sorting, max-mins etc., I then taught them recursion. It was quite fun to teach them recursion using the analogy of a staircase ... you go down the stairs, doing something in each step as you go down and then return (or doing something in each step on your way up).

Bernhard Koutschan recently posted a list of the most important algorithms. (thanks to Daniel Lemire for pointing it out). Among my favorites for first-timers, only 2 made that list (Euclid's GCD, binary search). The rest of the algorithms in that list are a bit complex for the newbie CS students to grasp in their first semester ... at least that's what I felt during my tutoring days.

Lemire has also posted a shorter list of the 5 most important algorithms, along with a poll, in his blog. It will be interesting to see what shortlist people come up with.

44 comments:

imyousuf said...

Could not agree more! I found the same sequence helpful as well. These algorithms are particularly good to grasp the different control flows of a programming language.

hopefull4ever said...

hi ragib bhai,
hope 2 fine...
wanna to be introduce here.... my blog link is http://hopefull4ever.blogspot.com/

Faisal Kaiser said...

Nice blog Ragib Bhai, this is Faisal kaiser (Robin) {ex collegiate(batch-95) & BBC high school, ctg}, one of your junior school mate and fan.

Ashily said...

basic algo is you learn than it going to help all the time..

ASUS Router Setup

Walking Sticks said...

Wow ragib bhai....Mast blog hai...

Lindasy Rosenwald said...

Nice blogging, My review is very good example.
Lindsay Rosenwald http://www.lindsayrosenwald.info/ Dr. Lindsay Rosenwald is one of the re-known venture capitalists and the hedge fund managers in the world.

batterie ordinateur portable said...

nice your blog and very nice dear your blog Ranking is too Good we like its you

can see our also website for online shopping......

BatterieOrdinateurPortable.org - AGO Technologie est speialis dans la vente ordinateur portable, Ordinateur, piles et le Chargeur. Nous offre Batterie Ordinateur Portable, Batterie Ordinateur Portable Sony, batterie Ordinateur Portable Dell, Chargeur Ordinateur Portable Sony, Chargeur Ordinateur Portable Hp et Chargeur Ordinateur Portable IBM http://www.batterie-ordinateur-portable.org

John said...

Nice Blogging,
UTAH : Utah Web Design http://www.adaptivitypro.com/utah-web-design/

John said...

Very good blogging,
Utah SEO Adaptivity Pro premier seo services provider based in Utah.

seema said...

nice....!

Tawhid said...

সচলায়তনের একটি পোস্টে আপনার মন্তব্যের সূত্র ধরে অত্যন্ত সম্মৃদ্ধ ব্যক্তিগত ওয়েবসাইট ও এই ব্লগের খোঁজ পেলাম। আপনার অর্জনগুলো দেখে একজন বাংলাদেশী হিসাবে গর্ববোধ হচ্ছে। ভাল থাকুন।

Rehan said...

The study of computer science can cover a broad spectrum of computer training, and there are many different choices when researching Computer science courses in philippines

Mark-Eric Casaje said...

I quite like that stairway idea of yours. I'll be sure to use that when coaching people doing recursion.

Thanks!

seema said...

nice

David said...

Buck Reed Achievements and his vision and success http://www.buckreed.org/buckreedvision.html

SEO Services company said...

CS 332: Algorithms

Panama abogados said...

Thanks for your nice sharing. I hope you keeping update youre blog always.

Christian Jenny said...

What a great post! I really enjoyed reading this. Thank you for sharing this valuable information with us. I have bookmarked this site and will be sure to check for updates. Keep up the good work!

Doridro BD said...

Sir, If you please share your knowledge then it would be great for all of Bangladeshi !

Two Steps From Home said...

Hi Ragib Bhai
Your post is so useful. This very helpful for everyone.
Thank you.

My Complaint said...

This is the Basement of a programer. So your post is so useful. Thanks.

comnetscience said...

This article is very helpful .. I think a new programmer needs to know

Bristlecone Pines said...

Your article is really helpful for a Computer Student. You should continue your writing.

Ankur said...


Nice,
Thanks for your grateful informations, I am working in, asian affairs magazine

so it will be a better information’s for me. Try to post best informations like this always

Bangladesh: A nation in search of its soul

sanjay said...

Appreciation for nice Updates, I found something new and folks can get useful info about BEST ONLINE TRAINING

Trees Planet said...

og 836You are a wonderful writer. Your post is so helpful. But why stop writing please keep it up.

Geeks Fix It said...

Great information…This is certainly distinctive. An stare upon those content articles and we are baffled. We’re interested in this kind of activities

best residual income businesses said...

Your article is really helpful for a Computer Student. You should continue your writing. Thanks for sharing your precious comprehension With us.

Ashish Mishra said...

I totally in your side because as a student of Computer Science I think that it is good to start from a simple one and should go forward. This will help in exams also and by this better understanding of topics.
Computer Science Homework Help provides the all in one assignment solutions that is helpful for every students

Hassanuzzaman said...

Good ! I always try to read ragib and his blog. This article is very helpful to know more about programmed. Thank you for sharing this to us.

teena sirvi said...

Services à domicile bricolage

akshey sharma said...
This comment has been removed by the author.
haroon khan said...

nice post and very useful also.

BUY USA FACEBOOK LIKES

Firoz Khan said...

home air conditioning Oxford-Crystal Sigma Ltd provides home air conditioning Oxford, office air conditioning in Oxford. We cover all areas of Oxford and offer all our specialist services in air conditioning.

srishti ews said...

SHOPPING ONLINE CLOTHES
online bet basketball
thanx to share with us

Rustam khan said...

holiday itinerary planner

Rustam khan said...

Sheharzaad

Rustam khan said...

Intionix Fashion

John Smith said...

land for sale - Broker Gayab: Best Place to post house for sale, land for sale & buy flats without brokers. Buy Apartments, find apartments for rent, real estate & property NEWS India

John Smith said...

Pool safety inspector - Pool Inspectors with over 1000 pool safety inspections worth of experience - Comply with new Qld Pool Safety Regulations. QLD pools must now meet new compliance standards when sold or leased.

Construction Project Technical Support - Construction projects generate volumes of information on a regular basis. Contact us for Construction Project Technical Support and Project Documentation

John Smith said...

Pool safety inspector - Pool Inspectors with over 1000 pool safety inspections worth of experience - Comply with new Qld Pool Safety Regulations. QLD pools must now meet new compliance standards when sold or leased.

Construction Project Technical Support - Construction projects generate volumes of information on a regular basis. Contact us for Construction Project Technical Support and Project Documentation

John Smith said...

Pool safety inspector - Pool Inspectors with over 1000 pool safety inspections worth of experience - Comply with new Qld Pool Safety Regulations. QLD pools must now meet new compliance standards when sold or leased.

Construction Project Technical Support - Construction projects generate volumes of information on a regular basis. Contact us for Construction Project Technical Support and Project Documentation

Samuel K. Houston said...

Luxury Hotel in Dubai - If you’re suddenly in the mood for a restful luxury escape to pamper your body, to treat your palate to a luscious fine dining restaurant meal, or to simply enjoy a glorious time of luxury, then choose one among many of our highly recommended luxury hotels that has Dubai's best luxury experience offerings. Luxury Hotels Dubai

Saree Design said...

See Saree Design