knightL

Trie* insert

Nov 28th, 2020 (edited)
673
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int insert(int root, int l, int r) {
  2.     position cur = position( root, 0 );
  3.     for(int i=l;i<r;i++) {
  4.         position nxt = readChar(cur, s[i]);
  5.         if(nxt.v == -1) {
  6.             return addChild(i, r, splitEdge(cur) );
  7.         }
  8.         else
  9.             cur = nxt;
  10.     }
  11.     return splitEdge(cur);
  12. }
RAW Paste Data