Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-cnmwb Total loading time: 0 Render date: 2024-07-19T20:30:35.204Z Has data issue: false hasContentIssue false

8 - Data Structures for Strings

Published online by Cambridge University Press:  25 January 2011

Peter Brass
Affiliation:
City College, City University of New York
Get access

Summary

Up to now we always assumed that the data items are of constant size, and key values can be compared in constant time, so essentially that they are numbers. A very important class of objects for which these assumptions fail are strings. In real applications, text processing is more important than the processing of numbers, and text fragments have a length; they are not elementary objects that the computer can process in a single step. So we need different structures for strings than for numeric keys; especially the balanced binary search trees, our most useful previous tool, require a key comparison in each node and are quite inefficient as dictionary structure for strings. Also, for strings we will ask different questions. Even though strings can be ordered lexicographically, this order does not reflect the similarity of strings, for two strings that differ in the first character only are closer related than two strings that differ from the third to the tenth character. Thus, range searching makes little sense for strings.

The concept of strings is not entirely uniform and therefore requires some attention. We have an underlying alphabet A, for example, the ASCII codes, and strings are sequences of characters from this alphabet. But for use in the computer, we need an important further information: how to recognize where the string ends. There are two solutions for this: we can have an explicit termination character, which is added at the end of each string, but may not occur within the string, or we can store together with each string its length.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2008

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Data Structures for Strings
  • Peter Brass, City College, City University of New York
  • Book: Advanced Data Structures
  • Online publication: 25 January 2011
  • Chapter DOI: https://doi.org/10.1017/CBO9780511800191.009
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Data Structures for Strings
  • Peter Brass, City College, City University of New York
  • Book: Advanced Data Structures
  • Online publication: 25 January 2011
  • Chapter DOI: https://doi.org/10.1017/CBO9780511800191.009
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Data Structures for Strings
  • Peter Brass, City College, City University of New York
  • Book: Advanced Data Structures
  • Online publication: 25 January 2011
  • Chapter DOI: https://doi.org/10.1017/CBO9780511800191.009
Available formats
×