Beruflich Dokumente
Kultur Dokumente
NAUMAN ALI
02018
DAA ASSIGNMENT NO 1
CODE
//headers
#include <iostream>
#include <vector>
#include "time.h"
using namespace std;
{
//returns true if there are duplicates
for (int i = 1; i < size;i++)
if (input[i] == input[i - 1])
return true;
return false;
}
//Partition function for quickSort
int partition(int *input, int start, int end)
{
int temp;
int x = input[end];
int i = start - 1;
for (int j = start; j < end; j++)
{
if (input[j] < x)
{
temp = input[++i];
input[i] = input[j];
input[j] = temp;
}
}
temp = input[i + 1];
input[i + 1] = input[end];
input[end] = temp;
return i + 1;
}
//Recursive function for quickSort
void quickSort(int *input, int start,int end)
{
if (start < end)
{
int pivot = partition(input, start, end);
quickSort(input, start, pivot - 1);
quickSort(input, pivot + 1, end);
}
}
//binarySearch function returns the index of the value
int binarySearch(int *input, int end, int value)
{
int lower, middle, upper;
lower = 0;
upper = end;
The time
The time
/* To print results
for(vector<int>::size_type i=0; i <FTSresult.size();i++)
{
if(i%3 == 0 && i!=0)
cout<<result[i]<<endl;
else
cout<<result[i]<<" , ";
}
*/
}
return 0;
}
3-sum
Fast 3-sum
THE TABLE
THE GRAPH