views:

183

answers:

1

This is related to http://stackoverflow.com/questions/711793/parse-url-strings-into-tree-hierarchy

But i'm implementing in javascript, therefore require some algorithm here instead of using SQL functions.

+1  A: 

Prefix tree/Trie or Suffix Tree

It is really difficult to suggest one over the other unless you specify the sort of operations you intend to perform over and above organising them.

dirkgently
Actually i'm interested in the implementation as well. I need to generate a JSON object based on the URL.{ "text":"aFolder", "children":[ { "text":"file", }, { "text":"file2", } ]},{ "text":"bfolder", "children":[ { "text":"file", }, { "text":"cFolder", "children":[ { "text":"file", } ] } ]}