top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Can somebody help me out with this algo in PHP with their code.

+1 vote
277 views

loop for all S in this F
find each S highest value
keep this in a hashset1 (key=S, value= max value)
order each S value in increasing order
keep this in another hashsset2 (key = S, value = list of values)
end loop for all S

order hashset1 in increasing order

loop hashset1
pick up each S
loop hashset2

pick up each element (roll no, plies, values)
show that on screen

end loop hashset2

end loop hashset1

// Code is most welcome... Literally have worked with this but couldn't break the jinx with their key-value.

posted Mar 20, 2014 by Atiqur Rahman

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button
Too cyptic language, could not understand anything.
Can you be step by step what you are trying to achieve, what is the code, what is the output and what is expected.

Similar Questions
0 votes

where is the problem in this code???,,,,,

#include<stdio.h>
#define EOS '\0'
int islet(char c)
{

    if(c>='a'&& c<='c')return(1);
    else
    return(0);
}

int main()
{
    char c,inpstr[]="abbbbccccb";
    int q,i,j;
    int count=0;
    printf("%s",inpstr);
    q=1;
    i=0;

   c=inpstr[i];

    while(c!=EOS)
    {
        if(q==1 && (inpstr[0]=='a')){q=2;}
        else  if(q==2 && (inpstr[i>=1 ||i<=19]=='b')&& islet(c) )
            {q=2;}    
             else if(q==2 &&(inpstr[i]=='c') && islet(c)){
                count++;
                if(count>1){printf("%d",count);}

else
                {q=3;}
             }
            else if(q==3 && (inpstr[0]=='b')){q=4;}
                 else{
                    q=5;
                    break;
                 }
      c=inpstr[i++];
    }

  if(q==5){
    printf("illegal");}
  else{
        printf("legal");
    }

  return(0);
}
+4 votes

I have tried bruteforce method but it's complexity is of O(n^2) , i am interested in O(n) or O(nlon n)
enter image description here

for the tree given above common ancestor of node 1 and 7 is 4. I am much interested in function not the whole program,function shoud take three argument as root of the tree, node1 and node 2

...