Numeric Representation of Strings: An Optimized Approach to Lexical-Comparisons
Vikram Singh Warraich · 2024
Absurd as it may seem, but strings can be treated as numbers for computation purposes. Most computer programs make extensive use of String operations like string-matching or sub-string lookups. Computer systems represent each character of a string with a numeric code. I take this concept further by applying it to arbitrary strings and explore the performance advantages of representing strings numerically. This paper presents a considerably faster approach for arbitrary String Lexicographic Comparisons and substring lookups. It introduces the concept of String-Numbers, which are arbitrary Strings represented by unsigned numbers. I validate my theory by running performance tests, which prove that String-Number based operations outperform contemporary string operations for a variety of String based algorithms. Test Results confirm the speed improvements delivered by String-Numbers in the areas of Searching, Sorting, Substring-Lookups and String-Matching.