8.summing components of a vector of numbers
Components of a vector sum is calculated as any amount is zero-sum leave, then at each step i (i from 1 to n), the amount increases with the current item, which is x [i].
sum: = 0;
for i: = 1 to n do
sum: = sum + x [i];
9.display elements seems a vectored integers.
to consider var x: = array (1 .. 20] of integer, and var n, i: integer. Through vector we can show only even numbers:
for i: = 1 to n do
Note: if odd (x [i]) Then
writeln (x [i])
10.displaying odd elements of the even positions of a vector of integers
Vector has full components. We consider same variables as the first problem . If we think at this we should indicate position and say whether we should think the item element and position, so the x [i]. So we will have to Note odd) i) and oddx [s]
for i: = 1 to ndo
if (note odd [i]) and odd (x [i])
writeln (x [i])
11.counting negative and the positive elements of an array of numbers.
Whether the two numbers. This NN and NP behave as two meters, the initial void Whenever we find in the string of numbers is a negative element NN NN: NN = 1, otherwise NP.
NN = 0, NP = 0;
for i: = 1to n do
if x [i] <0 then Inc (NN)
else inc (NP);
writeln (‘There’, NN, ‘negative elements’);
writeln (‘There,’ NP ‘positive elements’);
This problem needs to be a solved vector and a scroll position to finish first or to find items. Finding searched item is found marked by a logical variable, initially positioned falsified x vector and the element search
found: = false;
i: = 1
while (i: = n) and (not found) do 
if x [i]: = a Then
found: = true
else
inc (i)
12.inserting an element of a vector.
to insert on position p in a vector, a new element m. For this it will move items on the positions of the p to n, where n is the number of elements of vector prescriptions with you later position to be right. Moving the position towards the position last item I will put the final p. in position p. Elements of vector number will increase by one: n: = n +1
for i: = n +1 downto 1 do p
x [i] = x [i-1];
x [i]: = m;
n: = n = 1;
Order delivery
Direct selection method.
We believe that we have an array of comparable items between them, ascending ordered vector elements. Method is following you put on the forward, then do the same with the remaining elements. This method is implemented as follows: we compare the x [1] with all elements after it. If you find an element x [j] which is smaller than x [1], then swapped the x [1] x [j]. When I reached the last item means that the first position will be secure at the lowest part of array (new x [1]) still, we do only two elements of the position vector on, and will travel up to x [n] as in the first case. These crossings of the vector, together with possible interchange take place until the penultimate position, the place has only one comparison between x [n-1] and x [n]
Bubble-sort method
Compare each element x [i] element of the position of successor, so the element x [i +1]. If the items are not classified in increasing order will be exchanged. The process is repeated until a crossing of x no longer occurs no interchange
Sort by counting
For each item in the array is less than count how many elements it exists in the array.
alphabetical ordering scheme;
var x: array [1 .. 20] of string;
i, j, n: integer; aux: string;
begin
write (‘How many students are ?=’);
readln (n);
for i: = 1 to n do;
begin
write (“student name x ‘, and ,’:');
readln (x [i]);
end;
for i: = 1 to n-1 do
for j: = i +1 to n do
if x [i] <x [j] Then
begin
aux: = x [i], x [i] = x [j], x [j] = aux;
end;
writeln (‘alphabetical order is:’);
for i: = 1 to n do writeln (i,”, x [i]);
readln;
end.
Mixing the two vectors
Suppose we have two vectors (possibly different sizes) ordered, obtain vector ordered meeting. And b be two vectors and the vector c to put the result. We do the following:
1 we compare the first element of the vector of the first element of vector b and the less we will put in C, removing it from the vector of origin;
2. process is repeated until one of the vectors are exhausted;
3. copies at the end that all elements of unfinished vector, which of course are already ordered and higher than the last element of the vector is exhausted first.
Binary search 
Binary search is used to determine the existence of an element in an array. If array elements are already ordered in ascending or descending, then the process can become faster search if binary search is applied.
Compare the middle element item search, and if they do not coincide, the search will go only half that of the vector that logically, the item sought could find on the left or right, as the element of means is greater or less than the item looked so until the area where you have to look over.


