Created: 2023-01-22 13:44
Status: #concept
Subject: Programming
Tags: C JavaScript Python Boolean Operator Algorithms

String Comparison Algorithm

Description

An Algorithm that allows the comparison of Strings using the alphabetic or ASCII/Unicode values to determine inequalities.

The Pseudocode

  1. Compare the first character of both strings.
  2. If the first character from the first string is greater (or less) than the other string’s, then the first string is greater (or less) than the second. We’re done.
  3. Otherwise, if both strings’ first characters are the same, compare the second characters the same way.
  4. Repeat until the end of either string.
  5. If both strings end at the same length, then they are equal. Otherwise, the longer string is greater.

References