2 votes 2 votes time-complexity resilientknight asked Apr 10, 2016 resilientknight 2.1k views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply srestha commented Apr 11, 2016 i edited by srestha Apr 11, 2016 reply Follow Share 1 for loop required here.O(n) 0 votes 0 votes resilientknight commented Apr 11, 2016 reply Follow Share so what will be the ans to this? consider a carry look ahead adder for adding two n bit integers, built using gates of fan-in at most two. the time to perform addition using this adder is? 0 votes 0 votes srestha commented Apr 11, 2016 reply Follow Share sorry , it will be 1 for loop void add() { int i=7,A,B,a,b,cin,num; int n1[8],n2[8],cg[8],cp[8],sum[8]; for(i=0;i< =7;i++) { n1[i]=0; // Num 1 n2[i]=0; // Num 2 cg[i]=0; // Gi cp[i]=0; // Pi sum[i]=0; // Sum } A = a = get1(1); B = b = get1(0); i=7; do { n1[i]=a%2; a=a/2; n2[i]=b%2; b=b/2; i--; }while((a!=0)||(b!=0)); i=0; printf("\n\t\t Binary Form",A); printf("\n\t A = %d : ",A); for(i=0;i< =7;i++) printf("%d ",n1[i]); printf("\n\t B = %d : ",B); for(i=0;i< =7;i++) printf("%d ",n2[i]); cin=0; for(i=7;i>=0;i--) { sum[i]=exor(cin,exor(n1[i],n2[i])); // Sum Pi (+) Bi cg[i]=and(n1[i],n2[i]); // Gi = Ai . Bi cp[i]=or(n1[i],n2[i]); // Pi = Ai (+) Bi cin=or(cg[i],and(cp[i],cin)); // Cin =Gi + PiCi } http://cppgm.blogspot.in/2008/01/c-program-look-ahead-carry-adder.html 0 votes 0 votes Please log in or register to add a comment.