DSortedList11
Home ] Up ]

 

//DSortedList11.cpp
//date: 12/06/2002
//author: AOU


//Dynamic sorted list

////////////////////////////////////////////////////////////
// Include files
////////////////////////////////////////////////////////////
#include<iostream.h>
#include<math.h>
#include<stdlib.h>
#include<time.h>


////////////////////////////////////////////////////////////
// Constants
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
const int MAX_SIZE    = 20; //maximum entries allowed in a list
const int UNDEFINED   = -9999;
const int MAX_VALUE   = 50;
const int TEST_COUNT  = 20;

const int INFINITY    = 32000;


void testInsert(void);
void testConstructorN(void);
void testConstructorChar(void);
void testRemoveAll(void);
void testDestructor(void);

void testAdd(void);  //project#6  Due 11/20/2002
void testDisplayRev(void);

void testShuffle(void);

void testSortBubble(void);

void testSearch(void);


const int sValues[] = {55, 12, 34, 71, 98, 45, 20};
const int S_SIZE = sizeof(sValues)/sizeof(sValues[0]);

 
////////////////////////////////////////////////////////////
//class CNode
////////////////////////////////////////////////////////////
class CNode
  {
  private:
    int m_key;
    // int age;
    // char name[20];
    // char socsec[10];
    CNode *m_next;
  public:
    CNode(void);        //2002.10.30
    void display(void) const; //2002.10.30
    CNode(int x);       //2002.11.04
    CNode(char ch);     //2002.11.04
    //...
  friend class CDSortedList;

  friend ostream & operator <<                  //2002.11.13
    (ostream & bob, const CDSortedList &aList); 

  friend ostream & operator <<                  //2002.11.15
    (ostream & bob, const CNode &aNode); 

  friend void add(const CDSortedList &aList, 
      const CDSortedList &bList, CDSortedList &cList);
  };


////////////////////////////////////////////////////////////
//class CDSortedList
////////////////////////////////////////////////////////////
class CDSortedList
  {
  private:
    int     m_count;
    CNode  *m_first;
    void init(void);  //*should only be called by a constructor

  public:
    CDSortedList(void);   //*2002.10.30
    void display(void) const;   //2002.10.30
    bool insert(int x);   //*2002.11.04

    CDSortedList(int n);  //*2002.11.06
    CDSortedList(char ch);//*2002.11.06
    void removeAll(void); //*2002.11.08 all except dummy values
    ~CDSortedList(void);  //*2002.11.08

    //project#6 Due 11/20/2002
    //Submit well-documented source code and the output
    //The resulting list should be sorted with unique values
    friend void add(const CDSortedList &aList, 
      const CDSortedList &bList, CDSortedList &cList);

    friend ostream & operator <<                  //2002.11.13
      (ostream & bob, const CDSortedList &aList); 

    CNode* addByPos(int pos); //2002.11.15
    void displayRev(void);                        // 2002.11.15
    void shuffle(void);                           // 2002.11.18
    void analyze(void);                           // 2002.11.18

    void sortBubble(void);                        // 2002.11.25
    bool isSorted(void) const;                    // 2002.11.25

    CNode * search(int x);                        // 2002.11.28

    // extra credit 01
    friend void sub(const CDSortedList &aList, 
      const CDSortedList &bList, CDSortedList &cList);
    //c = a - b

    // extra credit 02
    friend void addMultiple(const CDSortedList aList[], int listCount, 
      CDSortedList &mList);

    bool isEmpty(void) const; 
    bool operator ==(CDSortedList list2); 
    bool operator !=(CDSortedList list2); 
    int getCount(void); 
    int getAt(int p);
    bool remove(int x);
    int searchBinary(int x) const;
    int searchBinaryLM(int x) const;
    void sortInsertion1(void);
   
  };


////////////////////////////////////////////////////////////
//void main(void)
////////////////////////////////////////////////////////////
void main(void)
  {
  srand(time(NULL));
  // testInsert();
  //testConstructorN();
  //testConstructorChar();
  //testRemoveAll();
  //testDestructor();
  testAdd();
  //testDisplayRev();
  //testShuffle();
  //testSortBubble();
  //testSearch();
  }


////////////////////////////////////////////////////////////
// CNode * CDSortedList::search (int x)
////////////////////////////////////////////////////////////
CNode * CDSortedList::search(int x)
  {
  if (this->m_count == 0)
    return NULL;

  CNode *p;

  p = this->m_first->m_next;

  while (p->m_next != NULL)
    {
    if (x < p->m_key)
      return NULL;

    if (x == p->m_key)
      return p;
    p = p->m_next;
    }

  return NULL;
  }


////////////////////////////////////////////////////////////
// void testSearch(void)
////////////////////////////////////////////////////////////
void testSearch(void)
  {
  cout << "testSearch\n";
  cout << "==========\n";

  CDSortedList myList('c');
  cout << myList;
  for (int j=0; j<S_SIZE; j++)
    {
    int x = sValues[j];
    CNode *p = myList.search(x);
    if (NULL == p)
        cout << x << " is not in the list\n";
      else
        cout << x << " is in the list at " << p << endl;

    x = sValues[j]+1;
    p = myList.search(x);
    if (NULL == p)
        cout << x << " is not in the list\n";
      else
        cout << x << " is in the list at " << p << endl;
    }
  cout << "-------------------\n";

  for (int i=1; i<=10; i++)
    {
    CDSortedList myList(i-1);
    cout << myList;

    for (int j=1; j<=i; j++)
      {
      int x = rand()%(MAX_VALUE+1);
      CNode *p = myList.search(x);
      if (NULL == p)
          cout << x << " is not in the list\n";
        else
          cout << x << " is in the list at " << p << endl;
      }
    cout << "-------------------\n";
    }
  }


////////////////////////////////////////////////////////////
// void CDSortedList::sortBubble(void)
////////////////////////////////////////////////////////////
void CDSortedList::sortBubble(void)
  {
  if (this->m_count <= 1)
    return;

  int temp;
  CNode *ip;
  bool sorted = false;

  while (!sorted)
    {
    sorted = true;
    for (ip = this->m_first->m_next; ip->m_next->m_next != NULL; ip = ip->m_next)
      {
      if (ip->m_key > ip->m_next->m_key)
        {
        temp = ip->m_key;
        ip->m_key = ip->m_next->m_key;
        ip->m_next->m_key = temp;
        sorted = false;
        }
      } 
    }
  }


////////////////////////////////////////////////////////////
// isSorted(void)
////////////////////////////////////////////////////////////
bool CDSortedList::isSorted(void) const
  {
  if (this->m_count <= 1)
    return true;

  for (CNode*ip = this->m_first->m_next; ip->m_next->m_next != NULL; ip = ip->m_next)
    if (ip->m_key > ip->m_next->m_key)
    return false;

  return true;
  }


////////////////////////////////////////////////////////////
// testSortBubble2(void)
////////////////////////////////////////////////////////////
void testSortBubble(void)
  {
  cout << "testSortBubble\n";
  cout << "==============\n";

  for (int i=1; i<=10; i++)
    {
    CDSortedList myList('r');

    cout << "Original list\n";
    cout << myList;
    if (myList.isSorted())
        cout << "List is SORTED\n";
      else
        cout << "List is NOT SORTED\n";

    myList.shuffle();
    cout << "Shuffled list\n";
    cout << myList;
    if (myList.isSorted())
        cout << "List is SORTED\n";
      else
        cout << "List is NOT SORTED\n";

    myList.sortBubble();
    cout << "After sortBubble\n";
    cout << myList;
    if (myList.isSorted())
        cout << "List is SORTED\n";
      else
        cout << "List is NOT SORTED\n";

    cout << "-------------------\n";
    }
  }
    

////////////////////////////////////////////////////////////
// void CDSortedList::analyze(void)
////////////////////////////////////////////////////////////
void CDSortedList::analyze(void)
  {
  int countUp=0, countDn=0, countEq=0;

  for (int i=0; i<this->m_count-1; i++)
    {
    CNode *p1, *p2;
    p1 = this->addByPos(i);
    p2 = this->addByPos(i+1);

    if (p1->m_key < p2->m_key) countUp++;
    if (p1->m_key > p2->m_key) countDn++;
    if (p1->m_key == p2->m_key) countEq++;
    }

  cout << "Count Up = " << countUp << endl;
  cout << "Count Dn = " << countDn << endl;
  cout << "Count Eq = " << countEq << endl;
  }


////////////////////////////////////////////////////////////
// void CDSortedList::shuffle(void)
////////////////////////////////////////////////////////////
void CDSortedList::shuffle(void)
  {
  /*
  do the following count*100 times
    randomly pick two elements
    swap their values
  */
  for (int i=0; i<this->m_count*100; i++)
    {
    int pos1, pos2;
    pos1 = rand()%this->m_count;
    pos2 = rand()%this->m_count;

    CNode *p1, *p2;
    p1 = this->addByPos(pos1);
    p2 = this->addByPos(pos2);

    int temp = p1->m_key;
    p1->m_key = p2->m_key;
    p2->m_key = temp;
    }
  }


////////////////////////////////////////////////////////////
// void testShuffle(void)
////////////////////////////////////////////////////////////
void testShuffle(void)
  {
  cout << "testShuffle\n";
  cout << "===========\n";

  for (int i=0; i<TEST_COUNT; i++)
    {
    CDSortedList* myListPtr = new CDSortedList('r');

    cout << *myListPtr;

    myListPtr->analyze();

    cout << "After shuffle\n";

    myListPtr->shuffle();

    cout << *myListPtr;

    myListPtr->analyze();

    delete myListPtr;
    cout << "------------------------\n";
    }
  }


////////////////////////////////////////////////////////////
// void CDSortedList::displayRev(void)
////////////////////////////////////////////////////////////
void CDSortedList::displayRev(void)
  {
  cout << "SortedRevr[" << this->m_count << "]= ";

  for (int i = this->m_count-1; i>=0; i--)
    {
    CNode *q = this->addByPos(i);
    cout << *q;
    }

  cout << endl;
  }
 

////////////////////////////////////////////////////////////
// void testDisplayRev(void)
////////////////////////////////////////////////////////////
void testDisplayRev(void)
  {
  for (int i=0; i<TEST_COUNT; i++)
    {
    CDSortedList myList('r');
    cout << myList;
    myList.displayRev();
    cout << "------------------------\n";
    }
  }


////////////////////////////////////////////////////////////
// CNode* CDSortedList::addByPos(int pos)
////////////////////////////////////////////////////////////
CNode* CDSortedList::addByPos(int pos)
  {
  /*
  Possibilities:
    Empty list
    pos < 0
    pos >= m_count
    pos >=0 and pos <m_count 
  */
  if (this->m_count == 0)
    return NULL;

  if (pos < 0)
    return NULL;

  if (pos >= this->m_count)
    return NULL;

  CNode *p;

  p = this->m_first->m_next;

  while (pos > 0)
    {
    pos--;
    p = p->m_next;
    }

  return p;
  }


////////////////////////////////////////////////////////////
// add
////////////////////////////////////////////////////////////
void add(const CDSortedList &aList, 
  const CDSortedList &bList, CDSortedList &cList)
  {
  //put in c distinct values from a and b
  //a={1, 3, 5, 5}, b={3, 3, 4, 6, 6} then
  //c={1, 3, 4, 5, 6}

  /*
  empty the cList
  for each element in aList do the following
    if element is not in cList then insert it in cList

  for each element in bList do the following
    if element is not in cList then insert it in cList

  */
  cList.removeAll();
  CNode *p;

  p = aList.m_first->m_next;
  while (p->m_next != NULL)
    {
    if (cList.search(p->m_key) == NULL)
      cList.insert(p->m_key);
    p = p->m_next;
    }

  p = bList.m_first->m_next;
  while (p->m_next != NULL)
    {
    if (cList.search(p->m_key) == NULL)
      cList.insert(p->m_key);
    p = p->m_next;
    }

  }


////////////////////////////////////////////////////////////
// testAdd
////////////////////////////////////////////////////////////
void testAdd(void)
  {
  cout << "testAdd\n";
  cout << "-------\n";

  int m1 = rand()%(MAX_SIZE/2);
  int m2 = rand()%(MAX_SIZE/2);

  for (int i=0; i<TEST_COUNT; i++)
    {
    CDSortedList aL(m1), bL(m2), cL('r');
    cout << "aL = " << aL;
    cout << "bL = " << bL;
    cout << "cL = " << cL;
    
    add(aL, bL, cL);
    cout << "After add(aL, bL, cL);\n";

    cout << "aL = " << aL;
    cout << "bL = " << bL;
    cout << "cL = " << cL;

    cout <<"=================\n";
    }
  }


////////////////////////////////////////////////////////////
// operator <<
////////////////////////////////////////////////////////////
ostream & operator << (ostream & bob, const CNode &aNode)
  {
  bob << aNode.m_key << ' ';

  return bob;
  }


////////////////////////////////////////////////////////////
// operator <<
////////////////////////////////////////////////////////////
ostream & operator << (ostream & bob, const CDSortedList &aList)
  {
  bob << "SortedList[" << aList.m_count << "]= ";

  CNode *p;

  p = aList.m_first->m_next;

  while (p->m_next != NULL)
    {
    bob << *p;
    p = p->m_next;
    }

  bob << endl;

  return bob;
  }


////////////////////////////////////////////////////////////
// CDSortedList::~CDSortedList(void)
////////////////////////////////////////////////////////////
CDSortedList::~CDSortedList(void)
  {
  cout << "Destructor was called\n";
  CNode *cia1, *cia2;

  cia1 = this->m_first;

  while (cia1 != NULL)
    {
    cia2 = cia1->m_next;
    delete cia1;
    cia1 = cia2;
    }
  }


////////////////////////////////////////////////////////////
// void testDestructor(void)
////////////////////////////////////////////////////////////
void testDestructor(void)
  {
  cout << "testDestructor\n";
  cout << "==============\n";

  CDSortedList *mp1 = new CDSortedList('c');
  mp1->display();
  delete mp1;

  cout << "-----------------\n";

  for (int i=0; i<TEST_COUNT; i++)
    {
    CDSortedList *mp1 = new CDSortedList('r');
    mp1->display();
    delete mp1;
    cout << "-----------------\n";
    }
  }


////////////////////////////////////////////////////////////
// void CDSortedList::removeAll(void)
////////////////////////////////////////////////////////////
void CDSortedList::removeAll(void)
  {
  CNode *cia1, *cia2;

  cia1 = this->m_first;

  while (cia1 != NULL)
    {
    cia2 = cia1->m_next;
    delete cia1;
    cia1 = cia2;
    }

  this->init();
  }


////////////////////////////////////////////////////////////
// void testRemoveAll(void)
////////////////////////////////////////////////////////////
void testRemoveAll(void)
  {
  cout << "testRemoveAll\n";
  cout << "=============\n";

  CDSortedList myList('c');
  myList.display();
  myList.removeAll();
  myList.display();

  cout << "-----------------\n";

  for (int i=0; i<TEST_COUNT; i++)
    {
    CDSortedList myList('r');
    myList.display();
    myList.removeAll();
    myList.display();
    cout << "-----------------\n";
    }
  }


////////////////////////////////////////////////////////////
// void CDSortedList::init(void)
////////////////////////////////////////////////////////////
void CDSortedList::init(void)
  {
  CNode *p1 = new CNode(-INFINITY);
  CNode *p2 = new CNode(+INFINITY);

  this->m_first = p1;
  p1->m_next = p2;
  // p2->m_next = NULL;

  //p1->m_key = -INFINITY;
  //p2->m_key = +INFINITY;

  this->m_count = 0;
  }


////////////////////////////////////////////////////////////
// CDSortedList::CDSortedList(char ch)
////////////////////////////////////////////////////////////
CDSortedList::CDSortedList(char ch)
  {
  this->init();

  if (('r' == ch) || ('R' == ch))
    {
    //insert random number of random values to the list
    int n = rand()%(MAX_SIZE+1);

    for (int i=0; i<n; i++)
      this->insert(rand()%(MAX_VALUE+1));
    }

  if (('c' == ch) || ('C' == ch))
    {
    //insert random number of random values to the list

    for (int i=0; i<S_SIZE; i++)
      this->insert(sValues[i]);
    }

  }


////////////////////////////////////////////////////////////
// void testConstructorChar(void)
////////////////////////////////////////////////////////////
void testConstructorChar(void)
  {
  cout << "testConstructorChar\n";
  cout << "===================\n";

  CDSortedList myList('c');
  myList.display();
  cout << "-----------------\n";

  for (int i=0; i<TEST_COUNT; i++)
    {
    CDSortedList myList('r');
    myList.display();
    cout << "-----------------\n";
    }
  }


////////////////////////////////////////////////////////////
// CDSortedList::CDSortedList(int n)
////////////////////////////////////////////////////////////
CDSortedList::CDSortedList(int n)
  {
  this->init();

  //insert n random values to the list
  for (int i=0; i<n; i++)
    this->insert(rand()%(MAX_VALUE+1));

  }


////////////////////////////////////////////////////////////
// void testConstructorN(void)
////////////////////////////////////////////////////////////
void testConstructorN(void)
  {
  cout << "testConstructorN\n";
  cout << "================\n";

  for (int i=0; i<TEST_COUNT; i++)
    {
    CDSortedList myList(rand()%MAX_SIZE);
    myList.display();
    }
  }


////////////////////////////////////////////////////////////
// bool CDSortedList::insert(int x)
////////////////////////////////////////////////////////////
bool CDSortedList::insert(int x)
  {
  if (this->m_count >= MAX_SIZE)
    return false;

  CNode *p, *p1, *p2;

  p = new CNode(x);

  if (NULL == p) 
    return false;

  p1 = this->m_first;
  p2 = p1->m_next;

  /* first version
  while(true)
    {
    if ((x >= p1->m_key) && (x <= p2->m_key))
      {
      p1->m_next = p;
      p->m_next = p2;
      break;
      }
    else
      {
      p1 = p1->m_next;
      p2 = p1->m_next;
      }
    }

  this->m_count++;
  return true;
  */

  //next version
  while(!((x >= p1->m_key) && (x <= p2->m_key)))
    {
    p1 = p1->m_next;
    p2 = p1->m_next;
    }

  p1->m_next = p;
  p->m_next = p2;
  this->m_count++;
  return true;
  }


////////////////////////////////////////////////////////////
// void testInsert(void)
////////////////////////////////////////////////////////////
void testInsert(void)
  {
  cout << "testInsert\n";
  cout << "==========\n";

  CDSortedList myList;
  myList.display();

  for (int i=0; i<10; i++)
    {
    int x = rand()%MAX_VALUE;
    myList.insert(x);
    cout << "After inserting " << x << endl;
    myList.display();
    }
  }


////////////////////////////////////////////////////////////
//void CDSortedList::display(void)
////////////////////////////////////////////////////////////
void CDSortedList::display(void) const
  {
  cout << "List[" << this->m_count << "] = \n";
  CNode *p;

  p = this->m_first;

  while (p != NULL)
    {
    p->display();
    p = p->m_next;
    cout << endl;
    }

  cout << endl;
  }


////////////////////////////////////////////////////////////
//CDSortedList::CDSortedList(void)
////////////////////////////////////////////////////////////
CDSortedList::CDSortedList(void)
  {
  /*
  create two nodes 
    one pointed to by p1, 
    other pointed to by p2

  make first point to p1
  make p1 point to p2
  make p2 point to nothing

  put -infin in p1 node
  put +infin in p2 node

  set count = 0
  */
  this->init();
  }


////////////////////////////////////////////////////////////
// CNode::CNode(char ch)
////////////////////////////////////////////////////////////
CNode::CNode(char ch)
  {
  if (('r' == ch) || ('R' == ch))
      {
      this->m_key = rand()%(MAX_VALUE+1);
      this->m_next = NULL;
      }
    else
      {
      this->m_key = UNDEFINED;
      this->m_next = NULL;
      }
  }


////////////////////////////////////////////////////////////
// CNode::CNode(int x)
////////////////////////////////////////////////////////////
CNode::CNode(int x)
  {
  this->m_key = x;
  this->m_next = NULL;
  }


////////////////////////////////////////////////////////////
//CNode::CNode(void)
////////////////////////////////////////////////////////////
CNode::CNode(void)
  {
  this->m_key = UNDEFINED;
  this->m_next = NULL;
  }


////////////////////////////////////////////////////////////
//void CNode::display(void)
////////////////////////////////////////////////////////////
void CNode::display(void) const
  {
  cout << this->m_key << " "; 
  }


/*
testAdd
-------
aL = SortedList[4]= 23 39 42 49
bL = SortedList[3]= 19 22 26
cL = SortedList[2]= 31 49
After add(aL, bL, cL);
aL = SortedList[4]= 23 39 42 49
bL = SortedList[3]= 19 22 26
cL = SortedList[7]= 19 22 23 26 39 42 49
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 13 15 17 18
bL = SortedList[3]= 2 26 42
cL = SortedList[3]= 21 31 44
After add(aL, bL, cL);
aL = SortedList[4]= 13 15 17 18
bL = SortedList[3]= 2 26 42
cL = SortedList[7]= 2 13 15 17 18 26 42
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 19 30 34 50
bL = SortedList[3]= 15 29 44
cL = SortedList[20]= 3 4 4 6 9 10 10 11 13 17 19 22 30 32 35 38 40 43 43 49
After add(aL, bL, cL);
aL = SortedList[4]= 19 30 34 50
bL = SortedList[3]= 15 29 44
cL = SortedList[7]= 15 19 29 30 34 44 50
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 6 6 24 36
bL = SortedList[3]= 14 31 49
cL = SortedList[19]= 1 5 8 11 12 12 13 14 21 25 31 33 36 38 39 43 48 49 49
After add(aL, bL, cL);
aL = SortedList[4]= 6 6 24 36
bL = SortedList[3]= 14 31 49
cL = SortedList[6]= 6 14 24 31 36 49
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 24 29 35 40
bL = SortedList[3]= 1 14 38
cL = SortedList[5]= 8 9 10 27 30
After add(aL, bL, cL);
aL = SortedList[4]= 24 29 35 40
bL = SortedList[3]= 1 14 38
cL = SortedList[7]= 1 14 24 29 35 38 40
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 25 27 32 46
bL = SortedList[3]= 2 43 45
cL = SortedList[16]= 2 2 12 12 16 16 16 29 30 37 37 38 42 43 47 48
After add(aL, bL, cL);
aL = SortedList[4]= 25 27 32 46
bL = SortedList[3]= 2 43 45
cL = SortedList[7]= 2 25 27 32 43 45 46
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 14 30 40 46
bL = SortedList[3]= 15 19 31
cL = SortedList[6]= 2 3 8 15 21 23
After add(aL, bL, cL);
aL = SortedList[4]= 14 30 40 46
bL = SortedList[3]= 15 19 31
cL = SortedList[7]= 14 15 19 30 31 40 46
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 29 32 43 43
bL = SortedList[3]= 19 30 42
cL = SortedList[8]= 3 18 21 27 31 45 46 50
After add(aL, bL, cL);
aL = SortedList[4]= 29 32 43 43
bL = SortedList[3]= 19 30 42
cL = SortedList[6]= 19 29 30 32 42 43
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 3 25 34 47
bL = SortedList[3]= 13 24 46
cL = SortedList[7]= 3 5 19 39 42 47 49
After add(aL, bL, cL);
aL = SortedList[4]= 3 25 34 47
bL = SortedList[3]= 13 24 46
cL = SortedList[7]= 3 13 24 25 34 46 47
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 29 32 45 48
bL = SortedList[3]= 20 23 33
cL = SortedList[2]= 43 43
After add(aL, bL, cL);
aL = SortedList[4]= 29 32 45 48
bL = SortedList[3]= 20 23 33
cL = SortedList[7]= 20 23 29 32 33 45 48
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 22 22 32 49
bL = SortedList[3]= 24 26 26
cL = SortedList[4]= 6 14 22 38
After add(aL, bL, cL);
aL = SortedList[4]= 22 22 32 49
bL = SortedList[3]= 24 26 26
cL = SortedList[5]= 22 24 26 32 49
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 7 30 33 34
bL = SortedList[3]= 7 9 22
cL = SortedList[19]= 0 4 4 9 10 12 17 17 23 27 31 35 38 39 40 40 45 45 46
After add(aL, bL, cL);
aL = SortedList[4]= 7 30 33 34
bL = SortedList[3]= 7 9 22
cL = SortedList[6]= 7 9 22 30 33 34
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 4 9 43 45
bL = SortedList[3]= 5 15 43
cL = SortedList[1]= 34
After add(aL, bL, cL);
aL = SortedList[4]= 4 9 43 45
bL = SortedList[3]= 5 15 43
cL = SortedList[6]= 4 5 9 15 43 45
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 0 1 10 24
bL = SortedList[3]= 1 13 27
cL = SortedList[3]= 14 23 35
After add(aL, bL, cL);
aL = SortedList[4]= 0 1 10 24
bL = SortedList[3]= 1 13 27
cL = SortedList[6]= 0 1 10 13 24 27
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 14 16 30 38
bL = SortedList[3]= 36 43 45
cL = SortedList[1]= 23
After add(aL, bL, cL);
aL = SortedList[4]= 14 16 30 38
bL = SortedList[3]= 36 43 45
cL = SortedList[7]= 14 16 30 36 38 43 45
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 0 22 26 34
bL = SortedList[3]= 16 28 32
cL = SortedList[10]= 2 9 11 14 23 23 28 39 40 45
After add(aL, bL, cL);
aL = SortedList[4]= 0 22 26 34
bL = SortedList[3]= 16 28 32
cL = SortedList[7]= 0 16 22 26 28 32 34
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 3 3 21 48
bL = SortedList[3]= 27 45 50
cL = SortedList[9]= 4 8 17 24 33 38 42 49 49
After add(aL, bL, cL);
aL = SortedList[4]= 3 3 21 48
bL = SortedList[3]= 27 45 50
cL = SortedList[6]= 3 21 27 45 48 50
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 17 20 20 41
bL = SortedList[3]= 22 23 36
cL = SortedList[15]= 2 5 8 12 14 15 16 19 19 21 34 34 43 43 49
After add(aL, bL, cL);
aL = SortedList[4]= 17 20 20 41
bL = SortedList[3]= 22 23 36
cL = SortedList[6]= 17 20 22 23 36 41
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 4 17 23 48
bL = SortedList[3]= 22 26 29
cL = SortedList[8]= 1 6 6 26 28 33 35 36
After add(aL, bL, cL);
aL = SortedList[4]= 4 17 23 48
bL = SortedList[3]= 22 26 29
cL = SortedList[7]= 4 17 22 23 26 29 48
=================
Destructor was called
Destructor was called
Destructor was called
aL = SortedList[4]= 11 14 17 21
bL = SortedList[3]= 1 16 50
cL = SortedList[2]= 33 43
After add(aL, bL, cL);
aL = SortedList[4]= 11 14 17 21
bL = SortedList[3]= 1 16 50
cL = SortedList[7]= 1 11 14 16 17 21 50
=================
Destructor was called
Destructor was called
Destructor was called
Press any key to continue
*/