algorithm - String datastructure supporting append, prepend and search operations -
i need build text editor mini project, , need design data structure or algorithm supports following operation:
- append : append character @ end of string.
- prepend : prepend character @ beginning of string.
- search : given search string s, find occurrences of string.
each operation in o(log n) time or less. search , replace operations appreciable not necessary. maximum length of string constant. ideas how achieve this?
thanks!
a common data structure kind of application rope, append , prepend o(1), although depends bit on whether tree balanced. however, noted Толя, search linear.
there data structures can make search faster, such suffix tree, not appropriate text editor application.
Comments
Post a Comment