/*internal method to remove from subtree is the item to remove is the node that roots the tree set the new root of the subtree *void removeconst comparable xtreapnode ift !nullnode ifx element removext->left )else ift->element removext->right )else /match found ift->left->priority right->priority rotatewithleftchildt )else rotatewithrightchildt )ift !nullnode removext )else delete ->leftt->left nullnode/continue on down /at leaf figure treapsdeletion procedure suffix arrays and suffix trees one of the most fundamental problems in data processing is to find the location of patternpin textt for instancewe may be interested in answering questions such as is there substring of matching pr how many times does appear in tr where are all occurrences of in