
Algorithms [pdf] - sonabinu
http://www.cs.berkeley.edu/~vazirani/algorithms/all.pdf
======
jasim
I'd tried studying from both CLRS and this text (S. Dasgupta, C. H.
Papadimitriou, and U. V. Vazirani) some years back.

I had a visceral reaction against CLRS when I saw the standard pseudo-code the
book uses. But as I tried implementing some algorithms in C, I found that the
algorithms were so precise and detailed that there was no better way to
represent it (apart from giving the C code directly).

I've heard claims that CLRS' pseudo-code could be presented in a higher level
manner - but it defeats the purpose of an Algorithms text. Algorithms should
be correct, fast and consume the least memory possible - this requires you to
think about low level memory management, cost of comparisons etc.

However, the density and detail of CLRS forced me to look for other books
which presents the topic in a better manner. Vazirani is an excellent choice
in this regard. The language is clear and easy to understand, and it gives a
better high-level picture than CLRS. I remember reading Chain Matrix
Multiplication (page 184, 6.5) in Vazirani and being overwhelmed by the
simplicity of the presentation compared to the dry formalisms used in CLRS.

From my experience, I recommend using CLRS as an aid for rigorous study and
Vazirani for less rigorous, but very effective learning. Also take a look at
Sedgewick's Algorithms in Java series - <http://www.cs.princeton.edu/~rs/> (he
has C and C++ series, but Java is what I've used). It is more detailed than
Vazirani but at the same time more approachable than CLRS.

~~~
quanticle
Another good algorithms text is Skiena's _Algorithm Design Manual_. It's not
as rigorous as CLRS (it doesn't spend as much time on proving correctness
mathematically), but as an implementer of algorithms, I find Skiena to be more
useful on a day-to-day basis than CLRS. Skiena talks about caveats and
pitfalls that come up when attempting to implement the algorithm on real
hardware (e.g. cache-locality issues, high constant factors, etc.) that CLRS
skims over.

~~~
tptacek
Another vote for Skiena; CLRS for reference, Skiena for how to think about
solving problems with algorithms.

~~~
talentless
For me, Skiena had the added bonus of being an enjoyable read which isn't
always the case for algorithm books. I highly recommend it.

------
Jabbles
So... who's read it? sonabinu? Have you actually used this book enough to
recommend it?

The fact that it's freely available online doesn't make it worth reading. If
someone is actually recommending it, I'd like to know why they prefer this
over, say "The Algorithm Design Manual". Just posting a link tells me nothing.
I hope the people that say they're going to try reading this can give a
detailed review in a few weeks' time - or even a few hours' - I'd be much more
content diving into a chapter of this if I knew someone else thought it
worthwhile.

Edit: I see jasim has read it :)

~~~
Me1000
This book was used for my algorithms class last year. I never buy textbooks
because I never really find them useful (especially CS books). This book,
however, I thought did a great job of explaining how things work and was a
pretty easy read. I even found myself reading ahead and reading content we
didn't cover in class.

If algorithms are interesting to you, I certainly wouldn't turn you away from
it.

~~~
sonabinu
I am doing my MS in Software Engineering and currently reading it.

------
pretz
I had the pleasure of taking the class based around this book from Christos
Papadimitriou while at UC Berkeley. It is indeed a concise and excellent book.
If you see it in person you'll be surprised how short it is compared to most
textbooks. I must confess, though, that some of the exercises can be
absolutely maddening.

Dead tree link for those interested: [http://www.amazon.com/Algorithms-Sanjoy-
Dasgupta/dp/00735234...](http://www.amazon.com/Algorithms-Sanjoy-
Dasgupta/dp/0073523402)

------
vph
Yes, this is one of the best algorithms textbooks due to a few reasons:

* It emphasizes rigor without much formalism.

* Rich number of non-trivial exercises.

* Conciseness of description of algorithms and strategies.

If you look for a textbook with algorithms translatable to C/C++/Java codes
line by line, this is not one of them.

~~~
mamcx
Any suggestion for the topic, more entry level for people that can't read math
notation (ie newbies?), perhaps in python?

~~~
vph
I don't have a good recommendation for your needs. However, there are a few
books that might be close:

1\. Programming Pearls by Jon Benley. 2\. Programming Challenges by Steven
Skiena. 3\. Algorithmic puzzles by Levitin.

The first two are mostly programming focus. I have not read the 3rd book, but
I have a good idea what it is about (based on other books by Levitin); it
should be good.

------
vitalique
Since algorithms are always a hot topic here at HN, I'd like to point out to
those interested two online courses that are going to start at Coursera soon,
both are continuations to previous courses and both are starting in about two
weeks (come December): 'Algorithms, Part II' - by Robert Sedgewick & Kevin
Wayne of Princeton themselves [1], and 'Algorithms: Design and Analysis, Part
2' - by Tim Roughgarden of Stanford [2]. Online courses tend to be by far not
as rigorous as books are, but I took first part of Prof. Roughgarden's course
and it was very enjoyable on all sides.

[1] <https://www.coursera.org/course/algs4partII> [2]
<https://www.coursera.org/course/algo2>

------
wallflower
We also really like Steven Skiena's lecture vault.

<http://www.cs.sunysb.edu/~algorith/video-lectures/>

~~~
Permit
He's also got a really great set of videos on Computational Finance. I haven't
seen the Discrete Mathematics or Computational Biology videos, but I imagine
he does a good job there as well.

I believe all of these videos are also available on his YouTube channel by the
way.

------
intellegacy
A bit off topic, but can anyone recommend a Data Structures book (as a
precursor to Algorithms?)

Or am I incorrect in thinking the two are discrete concepts unable to be
separated?

~~~
jasim
A data structure deals with the way you store data. A singly linked list for
example is a data structure. All you need to understand about it is that every
node except the terminal ones points to one other node. The traversal of this
structure can be called an algorithm, albeit a simple one.

Manipulation of the linked list often requires a traversal. Also, inserting
data between nodes also require a little juggling of the node pointers. These
are all what you can call 'algorithms'. Data structures can exist and be
learnt somewhat independently of their underlying algorithms, but it is rarely
useful like that.

There are however pure algorithms that do not care much about the underlying
data structure - insertion sort is an example. Most data structures though
aren't very much useful when separated from their fundamental algorithms.

Hope that answers your question.

~~~
intellegacy
Thanks. My confusion stemmed from not actually taking Data Structures yet,
along with the fact that some colleges call their second course 'Algorithms',
while including a junior-senior year 'Algorithms' course as well.

------
danso
I never noticed this until now: how does the scribd script work on HN? Does it
automatically suck in the PDF after it's been posted? I didn't realize that
clicking on [scribd] takes you to an actual scribd page (I just thought it was
the convention that people used to indicate that the link goes to a PDF).

Also, why scribd? (API I'm guessing?)

~~~
glesica
I don't understand why you would ever want to ruin a perfectly good PDF by
letting Scribd anywhere near it...

~~~
_delirium
I used to like being able to read PDFs in the browser, which Scribd let you
do, but now the browsers I use (Chrome and Safari) both have in-browser PDF
reading that seems to work more smoothly than Scribd for me, so I've switched
to the opposite preference. I do occasionally click on it for PDFs that I
expect to be large (such as this one) where I just want to skim a few pages
without downloading the whole thing.

------
eshvk
I would also recommend Jeff Erickson's (UIUC) book on algorithms freely
available here ( <http://www.cs.uiuc.edu/~jeffe/teaching/algorithms/> ). It is
very well written challenging material.

------
cotsog
Web page with links to individual chapters:

<http://www.cs.berkeley.edu/~vazirani/algorithms.html>

------
theshadow
Seems to cover less than CLRS. I find that most algorithm books cover the same
general (beginner to intermediate) set of topics as CLRS does. I was hoping to
find something that goes beyond the stuff covered in CLRS but not as far as
the level of TAOCP. Any recommendations will be appreciated.

~~~
jasim
It'd depend on what you're looking for. Sedgewick covers some areas better
than either CLRS or Vazirani. For example, I remember relying on Sedgewick for
B-Tree since neither text covered them. Sedgewick also has an entire text for
Graphs, so I presume he goes into lot more detail than others can.

If you are considering coding competitions like TopCoder, you should look at
Skiena's Algorithm Design Manual. It covers a lot of ground that is not
covered by CLRS or the like.

But I think between Skiena, Sedgewick, CLRS, Vazirani and TAOCP, you have
fundamental algorithms and data structures covered. If you are looking to go
into detail on specialized topics like say AI, these texts wont help much.

------
sravfeyn
Looked at the title and thought 'better than Vazirani!?'. Found it out to be
Vazirani. It's an incredible book. I was (still am) looking for a print Indian
Edition of the book. Is there anyone who can sell it off in India :), second-
hand?

~~~
sunilnimmagadda
Available on flipkart for 356 INR

[http://www.flipkart.com/algorithms-0070636613/p/itmczynvb7p2...](http://www.flipkart.com/algorithms-0070636613/p/itmczynvb7p2zacz?pid=9780070636613)

------
ginko
Looks like it handles all important topics for sequential algorithms quite
well. It even discusses quantum algorithms in the last chapter.

What I really could need though is a reference book for parallel algorithms.
Especially shared memory PRAM algorithms for OpenCL, OpenMP & co. Most current
books only assign a chapter at most to this. I guess the main problem here is
that parallel algorithms are still very much in their infancy compared to
their sequential counterparts.

~~~
ahelwer
The use cases are much different. Once you get outside of the standard
parallel sort/scan/reduce/map functions you can find in Thrust[1], you get
into algorithms that have an entire enormous book[2] explaining the idea
behind them.

That gap is closing slowly as a lot of old algorithms are being remixed into
highly parallel versions. This is noticeable in string pattern matching
applications, driven by the need to analyze tons of DNA.

More people would benefit from knowing how exactly to code efficiently on the
GPU before jumping right in to writing algorithms on it; it's easy to lose
multiples of throughput if you don't know what you're doing. As always it's
becoming easier for programmers though; if you're new to the idea of GPU
programming I really recommend checking out Microsoft's C++ AMP[3], which
shipped with VS 2012. Removes a lot of the headaches of programming with CUDA
and OpenCL. I've had a chance to play around with it, and it's excellent.

[1] <http://thrust.github.com/>

[2]
[http://books.google.ca/books/about/Computational_Electrodyna...](http://books.google.ca/books/about/Computational_Electrodynamics.html?id=n2ViQgAACAAJ&redir_esc=y)

[3] <http://msdn.microsoft.com/en-us/library/hh265137.aspx>

------
almost
Just bought this on Amazon, looks great but I still prefer dead trees for tech
books. Awesome that they've released it for free online though, very cool!

Amazon Link (no affiliate):
[http://www.amazon.com/gp/aw/d/0073523402/ref=mp_s_a_2?pi=SL7...](http://www.amazon.com/gp/aw/d/0073523402/ref=mp_s_a_2?pi=SL75&qid=1352917070&sr=8-2)

~~~
almost
Whoops, seems I posted the mobile link, here's the desktop site link:
[http://www.amazon.com/Algorithms-Sanjoy-
Dasgupta/dp/00735234...](http://www.amazon.com/Algorithms-Sanjoy-
Dasgupta/dp/0073523402/ref=sr_1_3)

And here's the uk one: [http://www.amazon.co.uk/Algorithms-Sanjoy-
Dasgupta/dp/007352...](http://www.amazon.co.uk/Algorithms-Sanjoy-
Dasgupta/dp/0073523402/ref=sr_1_3)

------
macstr1k3r
I'm planning on starting this book any day now. I've already skimmed through
the pages and have came to the conclusion that the lack of code(not pseudo
code) will be a problem for me.

So the question to those who have already read this is: Is there a blog or a
site or something of that sort that has covered this book and posted code
samples or something like that.

~~~
jasim
I think that it pays to implement the code yourself. Even though you think you
understand a concept, you haven't tested it till you write the code. IMO,
there is no better way to learn algorithms than implementing, tweaking,
profiling and trying to visualize them.

~~~
macstr1k3r
I need some basic examples smething in the order of "tips on implementing
algorithms"

------
indy
Are the answers to the exercises available?

~~~
krzyk
Exactly, without answers (or an instructor) exercises are pointless. It really
makes me mad when I see a book that doesn't give also the answers, how should
I know that I did the exercise correctly?

------
33a
From the table of contents, it just looks like the standard stuff you'd see in
an undergraduate class (with an odd-ball bonus section on quantum computing).
What makes this better than standard texts like CLRS that cover the same
subject matter, and in more detail?

------
Permit
Interesting, a chapter on quantum algorithms. I've often wondered whether
there might be room for novel research in this field if quantum computing
became more practical.

I'll definitely give this chapter a read. Thanks for posting it.

------
peterhajas
This was the book I used for my Algorithms class, along with CLRS. I much
(much!) preferred this one for its brevity and clarity.

------
kmfrk
I like the pseudocode, but it's a bit distracting that some of it is
italicized, though.

------
ReshNesh
Looks interesting. Is it possible to get a PDF without signing up to scribd?
Thanks

~~~
jlarocco
Already done. The title has two links.

The first part goes here to the PDF directly:
<http://www.cs.berkeley.edu/~vazirani/algorithms/all.pdf>

The second part, "[scribd]", goes to scribd.

~~~
ReshNesh
Oh, thanks for that. I didn't notice and obviously clicked the wrong link...

------
denzil_correa
TFS. I plan to read this cover-to-cover in the next 10 days

~~~
BlackJack
“Some books are to be tasted, others to be swallowed, and some few to be
chewed and digested: that is, some books are to be read only in parts, others
to be read, but not curiously, and some few to be read wholly, and with
diligence and attention.” - Francis Bacon.

This one should be chewed and digested. It's not a race - work slowly and
diligently, and start exploring the boundaries of the topics covered, and
you'll get much more out of it.

~~~
theshadow
It's possible that he/she is already familiar with the material but is reading
it as review, in which case 10 days sounds more than reasonable.

~~~
denzil_correa
True. As tsahyt puts it,

> it's always good to review things one has already learned. For me this
> usually leads to insights I haven't had before and a deeper understanding.
> Learnings seems to be an iterative process.

This is my primary motivation.

------
napolux
Can you suggest me a free text on genetics algorithms?

~~~
jjhageman
You might want to check out <http://www.cleveralgorithms.com/>. There is a
link to a free pdf version of the book.

------
mepcotterell
f(n) = O(g(n)) irritates me, but I know that people like to express Big-O that
way for convenience.

