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.

17 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.