vector important functions Algorithm

infinite-dimensional vector spaces arise naturally in mathematical analysis, as function spaces, whose vectors are functions. vector in vector spaces do not inevitably have to be arrow-like objects as they look in the noted examples: vectors are regarded as abstract mathematical objects with particular property, which in some cases can be visualized as arrows. Italian mathematician Peano was the first to give the modern definition of vector spaces and linear maps in 1888.

An important development of vector spaces is due to the construction of function spaces by Henri Lebesgue. At that time, algebra and the new field of functional analysis begin to interact, notably with key concepts such as spaces of p-integrable functions and Hilbert spaces. vector spaces stem from affine geometry, via the introduction of coordinates in the airplane or three-dimensional space.
// A C++ program to demonstrate working of sort(),
// reverse()
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric> //For accumulate operation
using namespace std;

int main()
{
	// Initializing vector with array values
	int arr[] = {10, 20, 5, 23 ,42 , 15};
	int n = sizeof(arr)/sizeof(arr[0]);
	vector<int> vect(arr, arr+n);

	cout << "Vector is: ";
	for (int i=0; i<n; i++)
		cout << vect[i] << " ";

	// Sorting the Vector in Ascending order
	sort(vect.begin(), vect.end());

	cout << "\nVector after sorting is: ";
	for (int i=0; i<n; i++)
	cout << vect[i] << " ";

	// Reversing the Vector
	reverse(vect.begin(), vect.end());

	cout << "\nVector after reversing is: ";
	for (int i=0; i<6; i++)
		cout << vect[i] << " ";

	cout << "\nMaximum element of vector is: ";
	cout << *max_element(vect.begin(), vect.end());

	cout << "\nMinimum element of vector is: ";
	cout << *min_element(vect.begin(), vect.end());

	// Starting the summation from 0
	cout << "\nThe summation of vector elements is: ";
	cout << accumulate(vect.begin(), vect.end(), 0);

	return 0;
}

LANGUAGE:

DARK MODE: