DO NOT USE STRING LIBRARY OR SUBSTR!!! Write a recursive function to determine if strA goes before strB in a dictionary. Deciding whether to go
DO NOT USE STRING LIBRARY OR SUBSTR!!!
Write a recursive function to determine if strA goes before strB in a dictionary.
Deciding whether to go first depends on the alphabetical order and the length of the strings.
Make your function case insensitive i.e. upper and lower case letters are treated as being the same same: the case is ignored.
Do NOT make your solution quadratic.
Use the function prototype
// p r e c o n d i t i o n :
// s trA and s t rB c o n t a i n l e t t e r s e x c l u s i v e l y , or are t h e empty s t r i n g
short g o e s F i r s t ( const s t d : : s t r i n g& strA , const s t d : : s t r i n g& s t rB ) ;
goesFirst returns
0 if strA is equal to strB
a positive value if strA goes first in a dictionary i.e. strA is listed before strB
a negative value if strB goes first in a dictionary i.e. strB is listed before strA
Do not use string library functions nor C string functions except for the function length http://www.cppreference.com/wiki/string/length, at, and the overloaded operator [ ].
You may write your own helper function(s).
You may overload goesFirst if you need extra parameters.
Do not use magic numbers e.g. numeric ASCII codes.
Do not allocate any memory in the function goesFirst (nor when calling it) except for allocating a few int/short/char local variables: so do not use substr nor concatenation
Do NOT use loops.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started