Explore BrainMass

Explore BrainMass

    Three example C++ programs

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Please assist with questions 1, 2, and 3... do not assist with 4. Please see the attached file.

    © BrainMass Inc. brainmass.com December 15, 2022, 7:19 pm ad1c9bdddf


    Solution Preview

    This solution addresses the first three questions in the posting. Each question has an associated cpp file.

    The first question deals with sorting an array of names. The sort algorithm used is the bubble sort. The bubble sort is a simple but inefficient sorting algorithm. Due to its simplicity it is easy to implement. However, for longer data sets its inefficiency makes it unsuitable for use.

    The basic bubble sort algorithm is to go through the list, from front to back, and compare adjacent elements. If the elements are out of order, swap them. After making one pass through the list then the largest element is guaranteed to be at the end of the list. It
    "bubbled" to the end. Since each full pass of the list guarantees the one more element will be in the correct location, we need to do "n" passes. The ...

    Solution Summary

    This solution provides three complete C++ programs. The first program uses a bubble sort to sort a list of strings. The second calculates the difference between two dates. The third shows how to calculate the roots of a polynomial.