Re: an old worn interview question
- From: user923005 <dcorbit@xxxxxxxxx>
- Date: Mon, 17 Sep 2007 16:00:38 -0700
On Sep 17, 3:09 pm, Tegiri Nenashi <TegiriNena...@xxxxxxxxx> wrote:
"given a graph of pointers, can you find a loop there"
I must admit that during 20 or so years of programming I never came
across any practical program that required finding a loop in the
directed graph.
I have had to do it many times.
I suspect that finding a loop is really a part of
bigger task such as finding transitive closure of a graph. And the
tricks of finding a single loop provide no insight how to solve bigger
problem. So, any counter examples of an interesting problem, or an
algorithm that requires finding a single loop in the graph?
A typical problem is a database of workers and supervisors. All
employees are kept in a single table, where employees of supervisors
are identified with a 'works_for' field. I guess you can imagine how
easily loops can arise.
A proper algorithm will identify the loops and draw an org chart, with
defects spelled out in some way. You can even do the identification
phase purely in SQL if you use a temp table.
.
- Follow-Ups:
- Re: an old worn interview question
- From: Logan Shaw
- Re: an old worn interview question
- From: Tegiri Nenashi
- Re: an old worn interview question
- References:
- an old worn interview question
- From: Tegiri Nenashi
- an old worn interview question
- Prev by Date: Re: an old worn interview question
- Next by Date: Re: source code of built-in functions
- Previous by thread: Re: an old worn interview question
- Next by thread: Re: an old worn interview question
- Index(es):
Relevant Pages
|