Order complexity of a pairing function
0
I 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. Since I am new to computer science, I don't think this is a very efficient code in MATLAB, can I optimize this code. What is the order complexity of...