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

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -