Esempio n. 1
0
void verifySolution()
{
	Node*list = new Node();
	Node *tmp = list;
	tmp->d = 3;
	tmp->next = new Node();
	tmp = tmp->next;
	tmp->d = 6;
	tmp->next = new Node();
	tmp = tmp->next;
	tmp->d = 3;
	tmp->next = new Node();
	tmp = tmp->next;
	tmp->d = 4;
	tmp->next = new Node();
	tmp = tmp->next;
	tmp->d = 5;
	tmp->next = new Node();
	tmp = tmp->next;
	tmp->d = 3;
	tmp->next = NULL;

    auto start = std::chrono::steady_clock::now();
    
	partitionList(&list, 5);
	printList(list);
	partitionList(&list, 4);
	printList(list);
    auto end = std::chrono::steady_clock::now();
    auto diff = end - start;
    std::cout << std::endl;
    std::cout << "Microseconds: " << std::chrono::duration <double,std::micro> (diff).count() << " us" << std::endl;

	checkPartition(4,list);
}
//To check if node a can be inserted
bool ispossible(int**p, int *a, int k)
{
	for(int j=dim-1;j>=0;j--)//Decrement each coordinate
	{
		int *b = copyNode(a);
			if(--b[j]>=0 && !checkPartition(p,b,k))//Check if node is positive and not present in partition
			{
				delete [] b;
				return false;
			}
			delete [] b;
	}
	//delete [] b;
	return true;
}