Skip to main content.
September 26th, 2006

n-level, m-width tree parsing

I have been programming for several years, and have been exposed to all sorts of problems along the way. However, Friday was about my first opportunity to actually use a tree traversal in a ‘real’ project, not just one assigned by a professor.

As most *nix types are aware, you can set up an aliases file to map addresses onto real world users. The problem with this file is that aliases can get stale, new aliases can be made that end up totally encompassing old ones (unintentionally), etc.

So, the request came about to be able to use a webform to look up where, exactly, an alias points. So, into our work order ticketing system it went, and I started working on it on paper Thursday evening. Turns out that it is not in fact to be a graph problem but rather a tree problem. This is a Good Thing™. Graph problems aren’t horrible to work with, but they are substantially more complex than tree problems.

The general form of the /etc/aliases file is listed above, but I left out an important caveat - aliases can point to a file of delimited targets via the :include: directive. To make a medium-length story pretty short, to parse the aliases file, every line needs to be read, and then tokenized to display the results of a search, recursively.

I suppose you could traverse the tree using a loop-based approach, but heaven help you to handle the corner cases. The only I have to track in traversing the tree is what the most recently checked alias was, and advance to the next one in the list when the check on that iteration is over.

Overall, it turned out to be a really easy to write script, and it’s now live on our site. If you are Shodor staff, you can play with it here.

Posted by wmyers in work

This entry was posted on Tuesday, September 26th, 2006 at 16:29 and is filed under work. You can follow any responses to this entry through the comments RSS 2.0 feed. You can leave a response, or trackback from your own site.

50 Responses to “n-level, m-width tree parsing”

  1. wmyers says:

    Upon further reflection, the alias parsing script wasn’t technically a tree problem - it was more a non-looping, digraph problem, but one that can be treated as a tree

  2. Buy phentermine no prescription bloghoster. says:

    Buy phentermine no prescription bloghoster….

    Buy phentermine without a prescription. Buy phentermine online without a prescription. Buy phentermine without prescription. Buy phentermine online without prescription. Buy no phentermine prescription. Where to buy phentermine without prescription. Bu…

  3. Buy cheap phentermine. says:

    Buy cheap phentermine mg tabs lowest prices….

    Buy cheap phentermine mg tabs lowest prices. Buy phentermine online cheap without prescription. Buy phentermine online without prescription cheap. Buy cheap phentermine now save. Buy cheap phentermine. Phentermine buy cheap online….

  4. Phentermine diet pills. says:

    Phentermine diet pills….

    Phentermine diet pills….

  5. Buy phentermine online 37.5mg no prescription. says:

    Phentermine 37 5mg….

    Phentermine 37 5mg. Phentermine 37 5mg us pharmacies….

  6. kanders says:

    Hello…

    My life,vist it http://blog.extra.by/xiangdress/ ,Thanks….

  7. Chantelles says:

    Hello…

    My life,vist it http://xiangcai.bloginthedark.com/2011/09/02/mickey-mouse-and-minnie-wedding-cakes/ ,Thanks….

  8. kjersic says:

    Hello…

    My life,vist it http://deborahr11.eklablog.com/ ,Thanks….

  9. Sterkers says:

    Great One…

    Everyone can get music from internet or from pirated cds at very low rate. Then how the music industry can still survive in india. And if downloading music from free site like songs.pk is illegal then why govt. do not put ban on these sites.. @shobha- …

  10. playing piano says:

    playing piano…

    […]warren @ shodor » Blog Archive » n-level, m-width tree parsing[…]…

  11. regenerating serum says:

    regenerating serum…

    see here for the greatest anti aging serums around…

  12. more info says:

    more info…

    see here for the top skin care products around…

  13. tammie says:

    tammie…

    Here are the best gold owl pendant necklace now available around and at great prices….

  14. clock hour hands says:

    clock hour hands…

    Here are the greatest clock second hands now available around and reasonably priced….

  15. clocks for schools says:

    clocks for schools…

    see here for the best forschoolssolar powered clocks currently in stock on the market plus reasonably priced….

  16. Resource says:

    Resource…

    get the best wireless clocks for hospitals currently in stock around and reasonably priced….

  17. synchronized wireless clocks for stadiums says:

    synchronized wireless clocks for stadiums…

    click here for the top wireless synchronized clocks for facilities now in stock anywhere plus at the best price….

  18. via says:

    via…

    Here are the best clock second hands now available around plus reasonably priced….

  19. his comment is here says:

    his comment is here…

    Encounter the top clock repair videos now in stock around plus reasonably priced….

  20. fast and furious jewelry says:

    fast and furious jewelry…

    Go here for the top supernatural jewelry currently available around and reasonably priced….

  21. PA speakers for businesses says:

    PA speakers for businesses…

    Click here for the greatest IP POE communication systems currently available on the market plus at great prices….

  22. Police duty led says:

    Police duty led…

    go here for the top pocket led flashlight currently available anywhere plus reasonably priced….

  23. flashlight says:

    flashlight…

    click here for the greatest 18650 Battery currently in stock around plus at the best price….

  24. fast and furious necklace says:

    fast and furious necklace…

    see here for the best harry potter snitch watch necklace currently in stock on the market plus at the best price….

  25. chinese sourcing agent says:

    chinese sourcing agent…

    Get the greatest find china manufacturer now available on the market plus at the best price…..

  26. product sourcing says:

    product sourcing…

    Get the top product sourcing now in stock anywhere and at the best price…..

  27. Brightest Tactical flashlight says:

    Brightest Tactical flashlight…

    See here for the best close proximity flashlights now in stock anywhere plus reasonably priced….

  28. over at this website says:

    over at this website…

    Go here for the best DIY clock hands repair currently in stock on the market and reasonably priced….

  29. wireless communication systems says:

    wireless communication systems…

    Click here for the top time synchronazation clocks currently available on the market plus at the best price….

  30. 5mm earrings actual size says:

    5mm earrings actual size…

    Click here for the greatest time turner jewelry currently available on the market plus at the best price….

  31. digital wireless clocks says:

    digital wireless clocks…

    Go here for the greatest clocks for businesses now in stock anywhere and at great prices….

  32. quartz clock movements and hands says:

    quartz clock movements and hands…

    Go here for the greatest Clock kits and dials now in stock around and at the best price….

  33. best flashlight says:

    best flashlight…

    Go here for the top bright led flashlights currently available anywhere plus reasonably priced….

  34. bright led flashlights says:

    bright led flashlights…

    Click here for the top Best led Flashlight currently in stock on the market plus at great prices….

  35. metal building erection says:

    metal building erection…

    See here for the top specialized building construction now in stock around plus reasonably priced….

  36. clock making kit says:

    clock making kit…

    Click here for the greatest replacement quartz clock movements currently available anywhere plus reasonably priced….

  37. school bell scheduling systems says:

    school bell scheduling systems…

    Get the best wireless public address system now available on the market and at great prices….

  38. clock parts says:

    clock parts…

    see here for the best weather clock plastic dial available…

  39. metal building erectors says:

    metal building erectors…

    Go here for the greatest building contractor California currently in service anywhere around and reasonably priced….

  40. clockkits says:

    clockkits…

    see here for the best manufacture of clocks anywhere…

  41. wireless synchronized clocks says:

    wireless synchronized clocks…

    Find here the best wireless pa system for schools currently in stock and on sale now!…

  42. steel building contractors says:

    steel building contractors…

    Find the best specialized building construction that are now in stock plus reasonably priced now!…

  43. clock kits says:

    clock kits…

    Find here the greatest mantle clock replacement motor currently available and at the best price today!…

  44. cree police flashlight says:

    cree police flashlight…

    See the greatest l e d Flashlight currently in stock plus at great cost today!…

  45. best flash light says:

    best flash light…

    See the best flashlight currently in stock and at great cost today!…

  46. school pa system says:

    school pa system…

    See the best School bell systems now now in stock and on sale today!…

  47. Best led Flashlight says:

    Best led Flashlight…

    See the brightest Cree led Flashlight that is available plus at the best cost today!…

  48. clockkits says:

    clockkits…

    Get the greatest parts for clocks currently now in stock and on sale today!…

  49. online marketing says:

    online marketing…

    See the greatest information on seo marketing omaha now currently available and reasonably priced today!…

  50. clock kit parts says:

    clock kit parts…

    Find the best additional reading that’s available plus at great prices today!…

Leave a Reply

You must be logged in to post a comment.