Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

How to make an insertion sort to sort an array of c strings using the following algorithm:

How to make an insertion sort to sort an array of c strings using the following algorithm:

* beg, * end){ (end - beg < ) ; * i; * j; * k; t; (i = beg; i != end; ++i) {t = *i; (k = i, j = k--; j != beg && t < *k; --j, --k)*j = *k;*j = t; }}

I created a bool DictionaryLT(const char* s1, const char* s2) to determine when s1 is greater than s2. I have my bool indicate true when s2 is greater than s1.

This is what I reworked using the algorithm above, but I'm not getting the correct out. How does the algorithm work step by step? Did I set my pointers correctly?

void DictionaryStringSort (char* *beg, char* *end){

 if (DictionaryLT(*beg, *end) == false) return;

    char * i;

    char * j;

    char * k;

    char  t;

    for(i = *beg; i != *end; ++i){

      t = *i;

      for (k = i, j = k--; j != *beg && t < *k; --j, --k)

        *j = *k;

      *j = t;

    }

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question