• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
June 28, 2022 |7.8K Views

Suffix Tree - Introduction

Description
Discussion

The best time complexity that we could get by preprocessing pattern is O(n) where n is length of the text. In this post, we will discuss an approach that preprocesses the text. A suffix tree is built of the text. After preprocessing text (building suffix tree of text), we can search any pattern in O(m) time where m is length of the pattern.


Imagine you have stored complete work of William Shakespeare and preprocessed it. You can search any string in the complete work in time just proportional to length of the pattern. This is really a great improvement because length of pattern is generally much smaller than text.

Suffix Tree - Introduction  : https://www.geeksforgeeks.org/pattern-searching-using-suffix-tree/