Check if there are distinct numbers x,y in the input file that satisfy x + y = sum.
For better performance sort the vector in O(n * log n) and then for every element x
binary search for t - x.
Could be done even better instead of binary search for t - x store key t - x in a hash table.
C implementation:
cd C/
gcc -o QuickSort QuickSort.c (Linux) or run the 'make' command
./QuickSort ../in/inputBig.txt (Linux)
compile with Visual Studio | MinGW | DevC++ (Windows)
QuickSort.exe ../in/inputBig.txt (Windows)
Java implementation:
cd Java/
mvn clean install
java -jar target/quicksort-1.0.0.jar ../in/inputBig.txt
For the input files in in/
folder the expected results are: the vectors sorted.
QuickSort
is released under the MIT License
.
You can find a copy of this license in LICENSE.txt.