Notification
No New notification
Learn to code with PrepInsta
Check PrepInsta Coding Blogs, Core CS, DSA etc
Never Miss an OffCampus Update
Get OffCampus Updates on Social Media from PrepInsta
Java program to find minimum scalar of two vectors
Login/Signup to comment

























//Finding Minimum scalar product of two vectors
public class MinScaller {
public static void main(String arg[]) {
int arr1[]= {10,40,20,30};
int arr2[]= {3,1,4,2};
int temp;
int res=0;
for(int i=0;i<arr1.length;i++) {
for(int j=0;j<arr1.length;j++) {
if(arr1[i]arr2[j]) {
temp=arr2[i];
arr2[i]=arr2[j];
arr2[j]=temp;
}
}
}
for(int i=0;i<arr1.length;i++) {
res=res+(arr1[i]*arr2[i]);
}
System.out.println("Minimum scalar product of two vectors :"+res);
}
}
//Time Complexity : O(n2)
//Space Complexity : O(1)
Hey, Join our TA Support Group on Discord, where we will help you out with all your technical queries:
?Discord