<?xml version="1.0" encoding="windows-1252"?>
<node id="854966" title="Re: redo entire loop" created="2010-08-13 14:06:48" updated="2010-08-13 14:06:48">
<type id="11">
note</type>
<author id="230012">
jonadab</author>
<data>
<field name="doctext">
&lt;p&gt;From an algorithm analysis perspective, avoiding a second pass is a relatively minor optimization.  Your algorithm is O(n) with the second pass, and it's still O(n) with the optimization.  Unless the performance is so bad that users are timing it with a clock, they won't notice the difference.&lt;/p&gt;
&lt;p&gt;If the performance &lt;strong&gt;is&lt;/strong&gt; so bad that users are timing it with a clock, you should probably think about O(log n) possibilities (such as running a binary search against a sorted index) or, depending on the nature of your data, maybe replacing the flat-file implementation with a DBMS.&lt;/p&gt;</field>
<field name="root_node">
854921</field>
<field name="parent_node">
854921</field>
</data>
</node>
