Princeton1/clients/src/main/java/com/hithomelabs/clients/Benchmarks/ArraySize.java
hitanshu310 8c47ac248c Adding benchmarking code (#17)
Reviewed-on: Hithomelabs/Princeton1#17
Reviewed-by: kruti <krutis0201@gmail.com>
Co-authored-by: hitanshu310 <hitanshu98@gmail.com>
Co-committed-by: hitanshu310 <hitanshu98@gmail.com>
2025-02-19 19:53:59 +00:00

31 lines
682 B
Java

package com.hithomelabs.clients.Benchmarks;
public class ArraySize {
private final int size;
public ArraySize(int n){
size = n;
}
public int getSize() {
return size;
}
public double getNSquare(){
return Math.pow(size,2);
}
public double getNlogN(){
return size * Math.log(size)/ Math.log(2);
}
public double getLogN(){
return Math.log(size)/ Math.log(2);
}
@Override
public String toString() {
return "### Sorting an array of size (n) : " + getSize() + " \n" + "n^2 for this array is : " + getNSquare() + "<br> \n" + "nlogn for this array is : " + getNlogN() + "\n";
}
}