Please login


Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

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.

Find Minimum Scalar Product of Two Vectors in an Array


  • 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.
  1. Initialize sumVariable variable with value 0
  2. Traverse each index from 0 to n
  3. Multiply array of same index element and add this with sumVariable and store it in the same variable
  4. return sumVariable


Python Code

#function to calculate minimum scalar value
def minScalar(arr1,arr2n):
    for i in range(0,n):
    return sumVariable
n=int(input(“Enter the size of Array: “))
print(“Enter the elements of First Array”)
print(“Enter the elements of Second Array”)
#sort arrays in ascending and descending order respectively
#print minimum scalar value of two arrays
print(“Minimum scalar product of two vectors :”, minScalar(arr1,arr2,n))

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