padpowell@wateng.UUCP (PAD Powell [Admin]) (10/28/83)
The other day I came upon a neat little programming question for Ph.d. comprehensives. The challenge is to write it in C, and to come up with an algorithm to do it with the least number of character moves. Question: Given 3 strings, stored sequentially, arrange them in lexigraphical order. It can be assumed that the strings are seqences of ascii characters, terminated by a "null" or 0 character. No extra memory may be used. (Note: by this, the examiners meant that you could use the MALLOC things). For example, the data structure defining the strings could have the form: char *Table[] = { "first", "second", "last string" }; reorder( (char *)(Table) ); This should result in: "first", "last string", "second" I waded into this little problem, thinking that there was nothing to it. Warnings: 1. Handle null string. 2. Watch out for strings with different lengths. (I goofed this.) 3. You can assume that there is only a single "0" between strings. Patrick ("I Hates UNIX Hacks and C Programmers Forever") Powell