Determine if a string of characters are unique using quicksort This will determine if a string is unique or not using quicksort, so that it should take \$O(nlogn)\$ time and not \$O(n^2)\$ time.

I will call the test function code from main.

This runs successfully, but when I try to write a randomized partition, it will fail. I have written that code separately.

FindUniqueCharInString.h

#define MAX 15
class FindUniqueCharInString
{
public:
    FindUniqueCharInString(void);
    ~FindUniqueCharInString(void);
    void test();

private:
    void swap(int index1, int index2);
    void quickSort(int start, int end);
    int partition(int start, int end);

    char arr[15];
};


FindUniqueCharInString.cpp

#include "FindUniqueCharInString.h"
#include &lt;iostream&gt;

using std::cout;
using std::endl;

FindUniqueCharInString::FindUniqueCharInString(void)
{
    char *tempArr = "SOMESTRING";

    strcpy(arr,tempArr);
}

FindUniqueCharInString::~FindUniqueCharInString(void)
{
}

void FindUniqueCharInString::test()
{
    quickSort(0,strlen(arr));

    for(int i = 0;i&lt;strlen(arr);i++)
    {
        cout&lt;&lt;arr[i] &lt;&lt; " ";
    }

    cout&lt;&lt;endl;

    bool isUnique = true;
    for(int i = 0;i&lt;strlen(arr) - 1;i++)
    {
        if(arr[i] == arr[i+1])
            isUnique = false;
    }

    if(isUnique)
        cout&lt;&lt;"Unique" &lt;&lt;endl;
    else
        cout&lt;&lt;"Not unique"&lt;&lt;endl;

}

void FindUniqueCharInString::swap(int index1, int index2)
{
    if(arr[index1] != arr[index2])
    {
        char temp = arr[index1];
        arr[index1] = arr[index2];
        arr[index2] = temp;
    }
}

void FindUniqueCharInString::quickSort(int start, int end)
{
    if(start &gt;= end)
        return;

    int p = partition(start,end);
    quickSort(start, p - 1);
    quickSort(p + 1,end);
}

int FindUniqueCharInString::partition(int start, int end)
{
    int pivot = arr[end - 1];
    int t = start;

    for(int i = start; i&lt; end-1; i++)
    {
        if(arr[i] &lt;= pivot)
        {
            swap(i,t);
            t++;
        }
    }

    swap(t,end - 1); //swap index and pivot pos

    return t;
}


Randomize partition function:

int FindUniqueCharInString::partition(int start, int end)
{
    int m = start + (end - start)/2;
    int pivot = arr[m];
    int t = start;

    swap(m,end -1); //putting pivot element to end

    for(int i = start; i&lt; end-1; i++)
    {
        if(arr[i] &lt;= pivot)
        {
            swap(i,t);
            t++;
        }
    }

    swap(t,end - 1); //swap index and pivot pos

    return t;
}
Complexity

If the intent was to meet an \$O(N log N)\$ requirement, you've technically failed--quicksort has an expected complexity proportional to N log N, but big-O deals strictly with the worst-case complexity--and worst-case complexity of quicksort is \$O(N^2)\$.

Class Design

One of the old basic ideas of how to do object-oriented design is to start by writing down a one-page (or less) description of what the program is supposed to do. You then pick out the nouns that form the major themes in that description. Those are your classes.

The point of that is to note that most classes should normally represent nouns1. Things that exist. Objects. In a typical case they should not represent verbs.

In this case, however, you have one primary class--and its name is a verb, not a noun. This leads to a lot of question over whether it makes sense for this class to be a class, or whether we have kind of a conglomeration of "stuff" thrown together into something that says it's a class, but isn't doesn't form a particularly coherent...thing.

Standard Containers

Good uses for C style arrays in C++ are quite rare. Your arr doesn't strike me as one of them. If you really need a fixed-size array, you should probably use std::array instead. Otherwise, you're probably best off using std::vector.

Standard Algorithms

The standard library already has algorithms to handle the job at hand. Most code should just use st::sort followed by std::unique, rather than attempting to craft the same on your own.

Self-defeating design

Right now, you've limited the collection size to only 15 elements. For such a small size, a simpler sorting algorithm (e.g., insertion sort) will almost always be at least a little faster than a quicksort. In short, combining the elements you have in the way you have just doesn't make sense.

Use of strlen

If you insist on using strlen at all, you shouldn't call it in the condition of a for loop, like:

for (int i=0; i&lt;strlen(foo); i++)


A few compilers know how to optimize this by hoisting the call to strlen out of the loop, but most don't. With those compilers, this loop will have \$O(N^2)\$ complexity instead of the O(N) you probably want/expect.

Note that if you used std::vector or std::string for your storage, this wouldn't be a problem. Unlike strlen, both these guarantee that you can find the size with \$O(1)\$ complexity instead of \$O(N)\$.

Side Effect-ridden code

Most of your functions implicitly modify FindUniqueCharInString::arr. It's generally much better to avoid this when possible--and it's pretty trivial in most of these cases. Just for a trivial example, right now your swap is passed to integers, i and j, and it swaps arr[i] with arr[j]. It would be much better to pass (for example) pointers or references to the contents, so the modifications are explicit:

swap(i, j); // ambiguous, implicit side effects on `arr`

swap(arr[i], arr[j]); // clear, effect on `arr` is obvious.


Summary

At least in my opinion, the other issues pale compared to just making good use of the standard library. 

std::string arr {"SOMESTRING"};
std::sort(arr.begin(), arr.end());
auto end = std::unique(arr.begin(), arr.end());

// show the unique characters    
std::copy(arr.begin(), end, std::ostream_iterator&lt;char&gt;(std::cout, "\n"));





1. The primary exception to this is function objects--i.e., classes that act mostly like a function, including overloading operator() to do whatever it is they do