2014 | OriginalPaper | Chapter
4. How Long Is a Piece of String?
Published in:
What Is Computer Science?
Abstract
This chapter highlights the important role of data structures as a natural companion to algorithms. The premise is that computers can only store and operate on primitive data types, which essentially means just numbers; if we need another data type (e.g., to represent an image, or an email), we need to design it ourselves by enforcing a format on numerical data.
The running example used is that of strings, which in theory are just sequences of characters. Faced with a practical need to represent strings in memory however, a range of options exist. By examining two different string data structures and a range of algorithms that operate on them, various trade-offs in terms of efficiency are highlighted: ultimately, what seem be subtle or unimportant differences have a major impact.