# Computer Science Problems

**URL:** <https://www.ruby-forum.com/t/computer-science-problems/128224>\
**Category:** Ruby\
**Created:** [February 6, 2008, 12:35am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224 "2008-02-06T00:35:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 12:35am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/1 "2008-02-06T00:35:41Z")

</div>

Hi all,

In part of James’ summary of Making Change (#154) on rubyquiz he  
states:

"This problem actually turns out to be famous in computer science.  
It’s called the Knapsack Problem. Once you know that you can apply the  
techniques often used on that problem, the most popular of which is to  
use a dynamic programming algorithm. "

My questions are:

1. Is there a definitive book/web site/resource on this and other  
computer science ‘problems’? (Whether Ruby, C, C++, Java, Perl based).
2. Do people have favorite ‘Data Structure and Algorithm’ books?
3. Other Computer Science book recommendations?

I’d love to get to a point where I could look at the quiz description  
and say “oh… that looks like the XXX problem” like some of you are  
able to do. I attempted this quiz and had a solution along the lines  
of Ilan B.'s non-complicated solution, but would never had known it  
was a ‘famous computer science problem’.

cheers,

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 12:46am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/2 "2008-02-06T00:46:52Z")

</div>

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’d love to get to a point where I could look at the quiz description  
> and say “oh.. that looks like the XXX problem”

[http://en.wikipedia.org/wiki/Np\_complete](http://en.wikipedia.org/wiki/Np_complete) would be a good start.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 12:51am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/3 "2008-02-06T00:51:00Z")

</div>

Hello –

On 05/02/2008, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 1. Is there a definitive book/web site/resource on this and other

Start by looking at know University sites – you’ll often come across  
some.  
).

> 1. Do people have favorite ‘Data Structure and Algorithm’ books?

Robert Sedgewick’s books are great, if not a little heavy-going:

> **[Robert Sedgewick - Robert Sedgewick](https://sedgewick.io/)**
>
> Robert Sedgewick is the founding chair and the William O. Baker Professor in the Department of Computer Science at Princeton University.

– Thomas A.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 1:40am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/4 "2008-02-06T01:40:54Z")

</div>

On Tue, 05 Feb 2008 15:31:17 -0800, markonlinux wrote:

> 1. Is there a definitive book/web site/resource on this and other  
> computer science ‘problems’? (Whether Ruby, C, C++, Java, Perl based).

[Dismissed site: www.nada.kth.se](http://www.nada.kth.se/~viggo/problemlist/) discusses optimization  
problems in NP

> 1. Do people have favorite ‘Data Structure and Algorithm’ books?

A good, standard textbook in use today is Thomas H. Cormen, Charles E.  
Leiserson, Ronald L. Rivest, and Cliff Stein _Introduction to  
Algorithms_  
2nd Ed. MIT Press

Donald Knuth, _The Art of Computer Programming_ is like the bible for  
computer scientists.

–Ken

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 2:10am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/5 "2008-02-06T02:10:49Z")

</div>

On Wed, 6 Feb 2008, James G. wrote:

> On Feb 5, 2008, at 6:39 PM, Ken B. wrote:
> 
> > Donald Knuth, _The Art of Computer Programming_ is like the bible for  
> > computer scientists.
> 
> But be warned, it’s as dry as you would expect a computer science reference  
> book to be. 🙂

Dry? Heretic! What is not to love about Mix assembler?

– Matt  
It’s not what I know that counts.  
It’s what I can remember in time to use.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 2:16am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/6 "2008-02-06T02:16:40Z")

</div>

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> My questions are:
> 
> 1. Is there a definitive book/web site/resource on this and other  
> computer science ‘problems’? (Whether Ruby, C, C++, Java, Perl based).
> 2. Do people have favorite ‘Data Structure and Algorithm’ books?
> 3. Other Computer Science book recommendations?

I don’t think there’s any one book. The subject is too broad. However, I  
learned a lot from Bentley’s _Programming\_Pearls_ and from  
_The\_Pragmatic\_Programmer_ by our own Dave T. and Andy H..

You could do a lot worse than these two classics. Find them at your  
favorite online bookseller.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 2:06am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/7 "2008-02-06T02:06:07Z")

</div>

On Feb 5, 2008, at 6:39 PM, Ken B. wrote:

> Donald Knuth, _The Art of Computer Programming_ is like the bible for  
> computer scientists.

But be warned, it’s as dry as you would expect a computer science  
reference book to be. 🙂

James Edward G. II

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 2:48am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/8 "2008-02-06T02:48:20Z")

</div>

On Feb 5, 2008, at 5:34 PM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 1. Is there a definitive book/web site/resource on this and other  
> computer science ‘problems’? (Whether Ruby, C, C++, Java, Perl based)

I have this book on my shelf:

[http://www.amazon.com/Algorithm-Design-Manual-Steve-Skiena/dp/0387948600/ref=sr\_1\_4?ie=UTF8&s=books&qid=1202261989&sr=1-4](http://www.amazon.com/Algorithm-Design-Manual-Steve-Skiena/dp/0387948600/ref=sr_1_4?ie=UTF8&s=books&qid=1202261989&sr=1-4)

In general, it’s a poor book to learn algorithms from. For example, I  
was never able to comprehend its descriptions of dynamic programming  
or simulated annealing.

However, the back half of the book is a reference guide to many famous  
computer problems and it’s really great. It describes common  
variations of the problem and how you might run into it. It also  
covers common ways to attack it, usually giving more than one  
approach. This is great for finding a famous problem.

I have yet to run into the perfect book to learn algorithms and data  
structures from. I’ve had to use many, many sources. I really feel  
like their should be a good algorithms book out there, but I just  
haven’t found it yet.

A Ruby algorithms book would be really nice to have. (I have a Perl  
book like that I’ve used a fair bit.)

James Edward G. II

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 2:50am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/9 "2008-02-06T02:50:05Z")

</div>

On Feb 5, 2008, at 7:10 PM, Matt L. wrote:

> Dry? Heretic! What is not to love about Mix assembler?

Assembler. Thanks for making my point. 😃

James Edward G. II

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 3:18am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/10 "2008-02-06T03:18:14Z")

</div>

On Feb 5, 2008, at 8:49 PM, James G. wrote:

> > > But be warned, it’s as dry as you would expect a computer science  
> > > reference book to be. 🙂
> > 
> > Dry? Heretic! What is not to love about Mix assembler?
> 
> Assembler. Thanks for making my point. 😃
> 
> James Edward G. II

Actually, it isn’t often straightforward to adapt the code in Knuth’s  
book to an object-oriented language. I found this out during quiz  
#150 (AVL Tree Ping-Pong). The algorithms are very much down in the  
pointer/stack details of making an algorithm… but it’s all the math  
you’ll EVER want.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 4:48am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/11 "2008-02-06T04:48:37Z")

</div>

On Feb 5, 2008, at 7:39 PM, Ken B. wrote:

> A good, standard textbook in use today is Thomas H. Cormen, Charles E.  
> Leiserson, Ronald L. Rivest, and Cliff Stein _Introduction to  
> Algorithms_  
> 2nd Ed. MIT Press

Cormen is my CS Professor!

-------------------------------------------------------|  
~ Ari  
seydar: it’s like a crazy love triangle of Kernel commands and C code

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 3:59am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/12 "2008-02-06T03:59:21Z")

</div>

Ken B. wrote:

> A good, standard textbook in use today is Thomas H. Cormen, Charles E.  
> Leiserson, Ronald L. Rivest, and Cliff Stein _Introduction to Algorithms_  
> 2nd Ed. MIT Press

I’ve been wanting to buy this one cheap on eBay, but most of them are  
sold only by Indian people and they charge a ton for shipping. 🙂

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 5:10am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/13 "2008-02-06T05:10:17Z")

</div>

On Feb 5, 2008, at 10:48 PM, fedzor wrote:

> -------------------------------------------------------|  
> ~ Ari  
> seydar: it’s like a crazy love triangle of Kernel commands and C code

Leiserson was my algorithms Prof and Cormen was my TA. (I had Rivest  
for my AI Prof. 😉

(this was before they published their own book, of course)

-Rob

Rob\_Biedenharn [at] alum.MIT.edu [http://agileconsultingllc.com](http://agileconsultingllc.com)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 6:10am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/14 "2008-02-06T06:10:37Z")

</div>

On Wed, 06 Feb 2008 15:27:10 +1100, Clifford H. wrote:

> Lots of good suggestions for algorithms books to answer your 2 & 3, but  
> note that I think I’m the only one who’s attempted to answer your first  
> question, and to point you to a list of the “known hard problems”, which  
> was also the subject of your last paragraph.
> 
> Does anyone else have better answers to question 1, which seems to be  
> Mark’s main question?

I’ll post again:

[Dismissed site: www.nada.kth.se](http://www.nada.kth.se/~viggo/problemlist/) is probably as close as you  
come to a full compendium of NP-Hard optimization problems, and their  
approximation algorithms, etc

–Ken

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 5:30am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/15 "2008-02-06T05:30:47Z")

</div>

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> "This problem actually turns out to be famous in computer science.  
> It’s called the Knapsack Problem.  
> My questions are:
> 
> 1. Is there a definitive book/web site/resource on this and other  
> computer science ‘problems’? (Whether Ruby, C, C++, Java, Perl based).
> 2. Do people have favorite ‘Data Structure and Algorithm’ books?
> 3. Other Computer Science book recommendations?  
> I’d love to get to a point where I could look at the quiz description  
> and say “oh.. that looks like the XXX problem” like some of you are  
> able to do.

Lots of good suggestions for algorithms books to answer your 2 & 3, but  
note that I think I’m the only one who’s attempted to answer your first  
question, and to point you to a list of the “known hard problems”, which  
was also the subject of your last paragraph.

Does anyone else have better answers to question 1, which seems to be  
Mark’s main question?

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 6:25am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/16 "2008-02-06T06:25:52Z")

</div>

Hi Clifford,

On Feb 6, 3:27 pm, Clifford H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > able to do.
> 
> Lots of good suggestions for algorithms books to answer your 2 & 3, but  
> note that I think I’m the only one who’s attempted to answer your first  
> question, and to point you to a list of the “known hard problems”, which  
> was also the subject of your last paragraph.
> 
> Does anyone else have better answers to question 1, which seems to be  
> Mark’s main question?

1. was my main focus, but I am really appreciating answers to 2. and
2. as well. So keep them coming 😉

Thanks for the wikipedia link. It’s definitely a keeper. The book  
James ‘has on his shelf’ lead me to this:

```
 The Stony Brook Algorithm Repository
 (http://www.cs.sunysb.edu/~algorith/)

```

which is also bookmarked!

I reckon I may buy the ‘Algorithm design manual’ based on James’  
description of the second half (even though the best i can find is  
$140 here in Oz!!). Am also looking into Sedgewicks set (or the Corman  
book).

This ([http://www.bioalgorithms.info/book/excerpt-ch6.pdf](http://www.bioalgorithms.info/book/excerpt-ch6.pdf)) was also a  
VERY good find! Seems like a very ‘easy read’ algorithm book.  
I’ll have to apply “The Change Problem Revisited” to Making Change  
(#154) (if I can!) 😉

Keep suggestions coming everyone 😉

cheers,

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 7:01am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/17 "2008-02-06T07:01:04Z")

</div>

Ken B. wrote:

> I’ll post again:

Nice one Ken, sorry I missed that the first time.  
Definitely a keeper.

Clifford H..

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 7:08am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/18 "2008-02-06T07:08:42Z")

</div>

On Feb 5, 2008 11:34 PM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote

> 1. Is there a definitive book/web site/resource on this and other  
> computer science ‘problems’? (Whether Ruby, C, C++, Java, Perl based).
> 2. Do people have favorite ‘Data Structure and Algorithm’ books?
> 3. Other Computer Science book recommendations?

Not a good first, or even second book, but Papadimitriou’s  
“Combinatorial optimization: algorithms and complexity” is an  
excellent book to work your way up to.

martin

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 3:21pm UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/19 "2008-02-06T15:21:52Z")

</div>

On Feb 5, 2008, at 11:24 PM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This ([http://www.bioalgorithms.info/book/excerpt-ch6.pdf](http://www.bioalgorithms.info/book/excerpt-ch6.pdf)) was also a  
> VERY good find! Seems like a very ‘easy read’ algorithm book.  
> I’ll have to apply “The Change Problem Revisited” to Making Change  
> (#154) (if I can!) 😉

This does look like a good find. Thanks for sharing!

James Edward G. II

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2008, 6:36am UTC](https://www.ruby-forum.com/t/computer-science-problems/128224/20 "2008-02-06T06:36:27Z")

</div>

On Feb 6, 4:03 pm, Ken B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > like the XXX problem" like some of you are able to do.
> 
> - Show quoted text -  
> Actually, I meant to acknowledge you Ken in my previous reply to  
> Clifford. I found the book excerpt halfway through writing the reply  
> so got sidetracked. Sorry about that 😉

cheers,

[Next page](https://www.ruby-forum.com/t/computer-science-problems/128224.md?page=2)
