Video courses for company/skill based Preparation
Purchase mock tests for company/skill building
Python Program to Find Minimum Scalar Product of Two Vectors in an Array
Minimum Scalar Product of two Vectors
In this section we learn how to Find minimum scalar product of two arrays using Python.
There we have two arrays i.e. array 1 and array 2, we need to find the dot product of the two array. Dot product is also known as the scalar product of two vector.
For finding the minimum scalar product of arrays we need to multiply the minimum value of array to the maximum value of array and add these all multiplied value. So here we need to sort the array 1 and array 2 in ascending order and descending order respectively.
- Step 1 : Take size of array, array 1 elements, array 2 elements as an input
- Step 2 : Sort both the arrays one in ascending and other in descending.
- Step 3 : Print the minimum scalar product by calling minScalar(arr1,arr2,n) function.
- Initialize sumVariable variable with value 0
- Traverse each index from 0 to n
- Multiply array of same index element and add this with sumVariable and store it in the same variable
- return sumVariable
Output: Enter the size of Array: 4 Enter the elements of First Array 3 7 5 2 Enter the elements of Second Array 1 2 1 5 Minimum scalar product of two vectors : 28