# The order complexity of an algorithm [closed]

have a code that involves a 2 to 1 pairing of numbers. The code for this is

   function [ A ] = CantorPairing( B )
[~, b] =(size(B));
%b=sqrt(b);
k=1;
A=zeros(1,b/2);
for i=1:2:(b)
if( B(i)< B(i+1))
A(k)= B(i)+(B(i+1))^2;
else
A(k)= (B(i))^2+B(i)+B(i+1);
end
k=k+1;
end


This is a matlab code that i am implementing. What this code does is, it pairs the adjacent elements of an array B depending on which is greater. So for an n size array the number of elements it returns is n/2. I have a few questions for this code.

1. Since I am new to computer science, I don't think this is a very efficient code in MATLAB, can I optimize this code.
2. What is the order complexity of this code and it's optimized version?
3. What if I again run this function on the new set A to get an array C of size n/4?

## closed as off-topic by David Eppstein, domotorp, Gamow, Jan Johannsen, Emil JeřábekJan 14 at 8:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Your question does not appear to be a research-level question in theoretical computer science. For more information about the scope, please see help center. Your question might be suitable for Computer Science which has a broader scope." – David Eppstein, domotorp, Gamow, Jan Johannsen, Emil Jeřábek
If this question can be reworded to fit the rules in the help center, please edit the question.