Re: [algogeeks] Re: Static variable

2011-08-31 Thread muthu raj
can u tell y negative values are gettin printed? when recursive  calls
return y is condition checking done again?
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Wed, Aug 31, 2011 at 9:14 AM, Sanjay Rajpal  wrote:

> Thank u swathi for making me clear about static variables.
>
>
> Sanju
> :)
>
>
>
> On Wed, Aug 31, 2011 at 9:10 AM, Swathi  wrote:
>
>> Google it.. you will find the answer,
>>
>> http://www.velocityreviews.com/forums/t443436-where-is-a-static-variable-stored.html
>>
>>
>>
>> On Wed, Aug 31, 2011 at 9:35 PM, Sanjay Rajpal  wrote:
>>
>>>  Static variables are always stored in the data section.
>>>
>>>
>>> Sanju
>>> :)
>>>
>>>
>>>
>>> On Wed, Aug 31, 2011 at 9:04 AM, Swathi  wrote:
>>>
 C standard doesn't define where static variables has to be stored. All
 it says is to persist the data across the multiple function calls. So I
 think the answer varies based on the compiler implementation but printing
 all zeros makes more logical.


 On Wed, Aug 31, 2011 at 9:25 PM, rohit  wrote:

> +1 to chris
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/fzTBEIWLGcAJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>   --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: 2 Binary trees are isomorphic?

2011-08-28 Thread muthu raj
In Amazon written test Isomorphic trees were defined as those in which a
series of flips can transform one tree to another.
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sun, Aug 28, 2011 at 11:52 AM, bugaboo  wrote:

> @Navneet,
>
> What you are talking about are "quasi-isomorphic" trees where trees
> can be changed a bit (flip right/left sub-trees to be precise) to make
> them isomorphic. An "isomorphic" tree does not need any
> transformation, they are similar in structure by themselves.
>
> On Aug 28, 1:44 pm, Navneet  wrote:
> > @Dave,
> >
> > From the definition of isomorphic trees(not in ques given), what i
> > know of is that one can be transformed into another. The above three
> > are then isomorphic to each other.
> >
> > @Bugaboo, can you clarify what exactly do you mean by isomorphic
> > here?
> >
> > On Aug 28, 9:25 pm, Dave  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > @Naveet: So we have a question of semantics. Do these three trees have
> > > the same structure:
> >
> > >  a
> > > /
> > >   b
> > >  /
> > > c
> >
> > > and
> >
> > > a
> > >  \
> > >   b
> > >\
> > > c
> >
> > > and
> >
> > > a
> > >  \
> > >   b
> > >  /
> > > c
> >
> > > I say "no," but perhaps you say "yes."
> >
> > > Dave
> >
> > > On Aug 28, 9:35 am, Navneet  wrote:
> >
> > > > Dave, that is why i have an OR condition between. Each side of OR has
> > > > two calls with AND in between.
> >
> > > > Basically at any node, you will have to invoke with two combinations
> > > > ((left,left) AND (right,right) OR (left,right) AND (right,left))
> >
> > > > Let me know if you think that's not required.
> >
> > > > On Aug 28, 6:02 pm, Dave  wrote:
> >
> > > > > @Navneet: Don't we want both subtrees to be isomorphic?
> >
> > > > > Dave
> >
> > > > > On Aug 28, 6:40 am, Navneet  wrote:
> >
> > > > > > Dave,
> >
> > > > > > I think the last condition should be
> >
> > > > > > return (AreIsomorphic(tree1->left, tree2->left) &&
> AreIsomorphic(tree1->right,tree2->right)) ||
> >
> > > > > >(AreIsomorphic(tree1->left, tree2->right) &&
> > > > > > AreIsomorphic(tree1->right,tree2->left))
> >
> > > > > > On Aug 28, 3:39 pm, Ankur Garg  wrote:
> >
> > > > > > > Daves solution looks cool to me...shud work :)
> >
> > > > > > > Nice one Dave :)
> >
> > > > > > > Regards
> > > > > > > Ankur
> >
> > > > > > > On Sun, Aug 28, 2011 at 4:08 PM, Ankur Garg <
> ankurga...@gmail.com> wrote:
> > > > > > > > cant we just count the no of nodes in each level and compare
> them with the
> > > > > > > > second one..
> >
> > > > > > > > if the numbers are same trees can be said to be isomorphic
> >
> > > > > > > > On Sun, Aug 28, 2011 at 3:54 AM, Dave <
> dave_and_da...@juno.com> wrote:
> >
> > > > > > > >> @Bugaboo: Use recursion. Assuming
> >
> > > > > > > >> struct tree_node {
> > > > > > > >>tree_node *left;
> > > > > > > >>tree_node *right;
> > > > > > > >>int data;
> > > > > > > >> };
> >
> > > > > > > >> int AreIsomorphic(tree_node tree1, tree_node tree2)
> > > > > > > >> {
> > > > > > > >>if( tree1 == NULL && tree2 == NULL )
> > > > > > > >>return TRUE; // both trees are null
> > > > > > > >>if( tree1 == NULL || tree2 == NULL)
> > > > > > > >>return FALSE; // one tree is null, the other is not
> > > > > > > >>return AreIsomorphic(tree1->left,tree2->left) &&
> > > > > > > >> AreIsomorphic(tree1->right,tree2->right);
> > > > > > > >> }
> >
> > > > > > > >> Dave
> >
> > > > > > > >> On Aug 27, 12:05 pm, bugaboo 
> wrote:
> > > > > > > >> > Considering the definition of binary tree isomorphism is
> the
> > > > > > > >> > following:
> > > > > > > >> > - 2 binary trees are isomorphic if they have the same
> structure but
> > > > > > > >> > differ just by values.
> >
> > > > > > > >> > What is the logic (or pseudo code) for checking if two
> binary trees
> > > > > > > >> > are isomorphic?
> >
> > > > > > > >> --
> > > > > > > >> You received this message because you are subscribed to the
> Google Groups
> > > > > > > >> "Algorithm Geeks" group.
> > > > > > > >> To post to this group, send email to
> algogeeks@googlegroups.com.
> > > > > > > >> To unsubscribe from this group, send email to
> > > > > > > >> algogeeks+unsubscr...@googlegroups.com.
> > > > > > > >> For more options, visit this group at
> > > > > > > >>
> http://groups.google.com/group/algogeeks?hl=en.-Hidequotedtext-
> >
> > > > > > - Show quoted text -- Hide quoted text -
> >
> > > > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googleg

Re: [algogeeks] Re: inorder predecessor

2011-08-28 Thread muthu raj
here is my approach.
flag=0;
void inorder(node *root , int value , node *predecessor)
{

   if(root)
{
   inorder(root->left,value , predecessor);

   if(root->value!=value)  // store the last node traversed as predessor
until you get the node we are searching
{
  predecessor = root;
 }
else  // once the node we search is found then set a global flag and
exit.predessor will be pointing the previous node in this case
{
  flag=1;
exit();
}
inorder(root->right,value,predessor);

}

main()
{
   node *p;
 inorder(root,value,p);
if(flag)
{
printf("predessor is %d",p->data);
}
else
{
printf("no predessor\n"):
}
}

*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sun, Aug 28, 2011 at 12:38 PM, vikas  wrote:

> no corner cases .. :D
>
> On Aug 26, 5:43 pm, Vikram Singh  wrote:
> > i m writing just a pseudocode...
> > // root is the root of treeand   node is the node whose
> > predecessor is to be found
> >
> > predecessor(root, node)
> > {
> > parent=NULL;
> > if(root==NULL)
> > return ;
> >
> > if(node->left!=NULL)
> >  {
> >  // find max value in left subtree...
> >  }
> >
> > else
> > {
> > while(root!=NULL && root->data!=node->data)
> > {
> > if(root->data >node->data)
> >{
> >root=root->left;
> >}
> > else if(root->data< node->data)
> >{
> > parent=root;
> > root=root->right;
> >}
> > }
> > return parent;
> > }
> >
> > }
> >
> > i hope it makes u understand@sanjay...
> > On Aug 26, 5:27 pm, Sanjay Rajpal  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Vikram : will u plz elaborate more on ur solution ?
> >
> > > Sanju
> > > :)
> >
> > > On Fri, Aug 26, 2011 at 5:24 AM, Vikram Singh <
> singhvikram...@gmail.com>wrote:
> >
> > > > ya thats one option but that gives ans in O(n), requires additional
> > > > memory... and unnecessarily finds for all which is not required...
> > > > my sol doesnt require any extra space i.e. in O(1) space... and also
> > > > in O(log n) time...
> >
> > > > tell if dere is any missing case
> >
> > > > On Aug 26, 4:58 pm, sukran dhawan  wrote:
> > > > > is it not possible to traverse tree in order and store in array.
> then
> > > > figure
> > > > > out the element and print the previous element?
> >
> > > > > On Fri, Aug 26, 2011 at 2:04 PM, Vikram Singh <
> singhvikram...@gmail.com
> > > > >wrote:
> >
> > > > > > i figured out algo to find the inorder predecessor of a bst
> without
> > > > > > using parent pointer... just wanna confirm if its missing any
> case
> >
> > > > > > if the left child(subtree) of node exist, then predecessor ll be
> the
> > > > > > max value in the left subtree.
> >
> > > > > > else predecessor ll be one of the ancestor in this case,
> starting
> > > > > > from the given node, we hv to find a closest ancestrous node
> which is
> > > > > > right child of its parent... the parent ll be the predecessor...
> >
> > > > > > and i made the parent implementation without changing the
> structure of
> > > > > > the node... using while loop...
> >
> > > > > > let me know if i m missing ant case...
> >
> > > > > > --
> > > > > > You received this message because you are subscribed to the
> Google
> > > > Groups
> > > > > > "Algorithm Geeks" group.
> > > > > > To post to this group, send email to algogeeks@googlegroups.com.
> > > > > > To unsubscribe from this group, send email to
> > > > > > algogeeks+unsubscr...@googlegroups.com.
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/algogeeks?hl=en.
> >
> > > > --
> > > > You received this message because you are subscribed to the Google
> Groups
> > > > "Algorithm Geeks" group.
> > > > To post to this group, send email to algogeeks@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > algogeeks+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Some bit manipulation help

2011-08-28 Thread muthu raj
Can anyone explain logic of  the above code ?
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sun, Aug 28, 2011 at 2:16 AM, Dheeraj Sharma  wrote:

> yeah..dat we all know..bt wat actually this code is doing..this is wat am
> thinking!!!
>
>
> On Sun, Aug 28, 2011 at 2:12 AM, Debabrata Das <
> debabrata.barunhal...@gmail.com> wrote:
>
>> Another approach!!
>>
>> while(x)
>> {
>> x=x&(x-1);
>> count++;
>>
>> }
>>
>> On Sun, Aug 28, 2011 at 2:26 PM, Nikhil Gupta 
>> wrote:
>>
>>> Here is a small piece of program which counts the number of bits set in a
>>> number. I found it online somewhere.
>>>  InputOutput00(000)52(101)73(111)
>>>
>>>   *int* CountBits (*unsigned* *int* x )
>>>
>>>
>>>
>>>
>>>   {
>>>   *static* *unsigned* *int* mask[] *=* { 0x,
>>>
>>>
>>>
>>>
>>>   0x,
>>>   0x0F0F0F0F,
>>>   0x00FF00FF,
>>>
>>>
>>>
>>>
>>>   0x  } ;
>>>   *int* i ;
>>>   *int* shift ; /* Number of positions to shift to right*/  
>>> *for* ( i *=*0, shift *=*1; i *<* 5; i *++*, shift **=* 2)
>>>
>>>
>>>
>>>
>>>   x *=* (x *&* mask[i ])*+* ( ( x *>>* shift) *&* mask[i]);
>>>
>>>
>>>
>>>
>>>   *return* x;
>>>   }
>>>
>>> Can anyone explain how this is working?
>>>
>>> --
>>> Nikhil Gupta
>>> Senior Co-ordinator, Publicity
>>> CSI, NSIT Students' Branch
>>> NSIT, New Delhi, India
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> *Dheeraj Sharma*
> Comp Engg.
> NIT Kurukshetra
> +91 8950264227
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Given an array A[] and a integer num. Find four no.s in the array whose sum is equal to given num.

2011-08-27 Thread muthu raj
@Dave: Explain your O(n3) solution please
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sat, Aug 27, 2011 at 11:10 PM, Mohit Goel wrote:

> This code may also work .give any counter examples...
>
>
> #include
> using namespace std;
> void  find_sum(int num,int k,int j,int b);
>  void display(int i,int j);
> #define MAX 8
>
> int res[4];   //array to store
> 4 numbers..
> int arr[MAX] ={2,3,4,1,6,9,8,10};
> int main()
> {
> int b,k,j,num;
> cout<<"enter desired number"<<"\n";
> cin>>num;
> k=0;
> j=b=0;
> find_sum(num,k,j,b);
>
>
> return 0;
> }
> void  find_sum(int num,int k,int j,int b)
> {
> int p,i;
> if(k< MAX)
> {
> if(j==3 && arr[k]== num )
> {
> res[b]=arr[k];
> display(0,b);  //FOUND 4 NUMBER ,PRINT THEM
>
> }
> else if(j == 3 && arr[k]!=num)
> {
> for(p=k+1;p {
> if(arr[p] == num)
> {
> res[b] =arr[p];
>  display(0,b); //FOUND 4 NUMBER ,PRINT THEM
>
> break;
>
>
> }
> }
>
>
> }
> else
> {
> for(i=k;i {
> res[b] =arr[i];
> find_sum(num-arr[i],i+1,j+1,b+1);
>
> }
> }
> }
> }
>
> void display(int i,int j)
> {
> cout<<"\n";
> int k;
> for(k=0;k<=j;k++)
> cout<<" "< }
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon Ques

2011-08-22 Thread muthu raj
Sorry i dint read the question properly :)
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Mon, Aug 22, 2011 at 7:24 AM, sukran dhawan wrote:

> count is required since its not implemented as LL
>
>
> On Mon, Aug 22, 2011 at 7:47 PM, shady  wrote:
>
>> i wish u had read the question... it is simple.. push to new stack and
>> then pop back... number of elements count need to be there
>>
>>
>> On Mon, Aug 22, 2011 at 7:44 PM, muthu raj  wrote:
>>
>>> No need to count the number of nodes. Since its implemented as a linked
>>> list traverse the list with two two pointers one incremented one node next
>>> and other incremented two nodes next simultaneously.
>>>
>>> void delete_MiddleStack(node **h)
>>> {
>>>
>>>  if(*h==NULL)
>>>  return;
>>>  node *p,*q;
>>> p=*h;
>>>   q=*h;
>>>  while(q->next!=NULL)
>>> {
>>> p=p->next;
>>> if(q->next==NULL)
>>> q=q->next;
>>>   else q=q->next->next;
>>> }
>>> p->ele=p->next->ele;
>>> q=p->next;
>>> p->next=p->next->next;
>>> free(q);
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *Muthuraj R
>>> IV th Year , ISE
>>> PESIT , Bangalore*
>>>
>>>
>>>
>>>
>>> On Mon, Aug 22, 2011 at 5:08 AM, vikas wrote:
>>>
>>>> why to bother this much...? just count the elements when popping and
>>>> output the middle one .
>>>> while(!s.empty()){
>>>> e= s.pop()
>>>> count++
>>>> q.enq(e);
>>>> }
>>>>
>>>> count <<= 2;
>>>>
>>>> while(count){
>>>> e = q.deq();
>>>> s.push(e);
>>>> count --;
>>>> }
>>>> output s.top()
>>>>
>>>> while(!q.empty()){
>>>> e = q.deq();
>>>> s.push(e);
>>>> }
>>>>
>>>>
>>>> On Aug 22, 4:27 pm, Shravan Kumar  wrote:
>>>> > Pop each element and en-queue it twice and de-queue it once. When
>>>> stack is
>>>> > empty the front of the queue will be middle element.
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> > On Mon, Aug 22, 2011 at 4:01 PM, Ankur Garg 
>>>> wrote:
>>>> > > Find the middle of the stack..(Time complexity should be minimum)
>>>> >
>>>> > > Stack is not implemented as Linked List ...u have normal stack with
>>>> > > push,pop and top
>>>> >
>>>> > > How to do this ??
>>>> >
>>>> > > --
>>>> > > You received this message because you are subscribed to the Google
>>>> Groups
>>>> > > "Algorithm Geeks" group.
>>>> > > To post to this group, send email to algogeeks@googlegroups.com.
>>>> > > To unsubscribe from this group, send email to
>>>> > > algogeeks+unsubscr...@googlegroups.com.
>>>> > > For more options, visit this group at
>>>> > >http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon Ques

2011-08-22 Thread muthu raj
No need to count the number of nodes. Since its implemented as a linked list
traverse the list with two two pointers one incremented one node next and
other incremented two nodes next simultaneously.

void delete_MiddleStack(node **h)
{

 if(*h==NULL)
 return;
 node *p,*q;
p=*h;
  q=*h;
 while(q->next!=NULL)
{
p=p->next;
if(q->next==NULL)
q=q->next;
  else q=q->next->next;
}
p->ele=p->next->ele;
q=p->next;
p->next=p->next->next;
free(q);
}







*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Mon, Aug 22, 2011 at 5:08 AM, vikas  wrote:

> why to bother this much...? just count the elements when popping and
> output the middle one .
> while(!s.empty()){
> e= s.pop()
> count++
> q.enq(e);
> }
>
> count <<= 2;
>
> while(count){
> e = q.deq();
> s.push(e);
> count --;
> }
> output s.top()
>
> while(!q.empty()){
> e = q.deq();
> s.push(e);
> }
>
>
> On Aug 22, 4:27 pm, Shravan Kumar  wrote:
> > Pop each element and en-queue it twice and de-queue it once. When stack
> is
> > empty the front of the queue will be middle element.
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Aug 22, 2011 at 4:01 PM, Ankur Garg 
> wrote:
> > > Find the middle of the stack..(Time complexity should be minimum)
> >
> > > Stack is not implemented as Linked List ...u have normal stack with
> > > push,pop and top
> >
> > > How to do this ??
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to algogeeks@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks]

2011-08-20 Thread muthu raj
Segregate the Odd and even nodes in the list by traversing in O(n). Then
print the resulting list in O(n). So no additional space required and
solution in O(n) time also :)
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Fri, Aug 19, 2011 at 9:48 AM, priya ramesh <
love.for.programm...@gmail.com> wrote:

> +1 sagar! i too have the same answer :)
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] GS apti ques!

2011-08-17 Thread muthu raj
Even i got 0.212



*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Wed, Aug 17, 2011 at 4:42 PM, Romil ...  wrote:

> Kumar's approach would not do perhaps. I simply eliminated the undesired
> cases. Those include the one when none of them is active and when only one
> of them is active.
> @Kumar: You should have also added the term abc.
>
>
> On Wed, Aug 17, 2011 at 4:39 PM, priya ramesh <
> love.for.programm...@gmail.com> wrote:
>
>> @romil: how did you solve this??
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Romil
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] GS apti ques!

2011-08-17 Thread muthu raj
Sorry The probability of machine being active is 1-0.212=0.788



*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Wed, Aug 17, 2011 at 5:10 PM, muthu raj  wrote:

> Even i got 0.212
>
>
>
> *Muthuraj R
> IV th Year , ISE
> PESIT , Bangalore*
>
>
>
> On Wed, Aug 17, 2011 at 4:42 PM, Romil ... wrote:
>
>> Kumar's approach would not do perhaps. I simply eliminated the undesired
>> cases. Those include the one when none of them is active and when only one
>> of them is active.
>> @Kumar: You should have also added the term abc.
>>
>>
>> On Wed, Aug 17, 2011 at 4:39 PM, priya ramesh <
>> love.for.programm...@gmail.com> wrote:
>>
>>> @romil: how did you solve this??
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Romil
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Assignment!!

2011-08-14 Thread muthu raj
What is the difference between the following statements.

int a=1,2,3 ;
 and

int a;
a=1,2,3;


first one is an error while second one is not.

 Can Any one  tell  me y ?







*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c question

2011-08-14 Thread muthu raj
The problem is because of \n in the prnintf statement. When new line is
there in first printf it flushes the standard buffer and so in child the
output of printf is not present in second program.
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sat, Aug 13, 2011 at 9:29 PM, Ankur Khurana wrote:

>
> aren't two programs same ? and scheduling of two forked and parent process
> is prcoessor dependent. You dont have a say in it.
>
> On Sun, Aug 14, 2011 at 1:21 AM, thanu moorthy wrote:
>
>> #include
>> #include
>> int main()
>> {
>>   int return_value;
>>   printf("forking process");
>>   fork();
>> printf("hello\n");
>> return 0;
>>
>>  }
>>
>> in the above program the output is
>>
>> forking processhello
>> forking processhello
>>
>> but in the below prog
>>
>>
>>   include
>> #include
>> int main()
>> {
>>   int return_value;
>>   printf("forking process\n");
>>   fork();
>> printf("hello\n");
>> return 0;
>>
>>  }
>> the output is
>> forking process
>> hello
>> hello
>>
>> why its so ??
>>
>> --
>> by $THANU$
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Ankur Khurana
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Microsoft written!!!

2011-08-10 Thread muthu raj
Tell me if this Pseudo code Works.

Initial conditions tp be checked are:

node * leftmostRightCousin(node *root,node *p)
{
if(root==p || root->left==p || root->right==p)  // in dis
case der cant be any cousins for any node at first level.
return NULL;

  while(root)
{
 //   perform level order traversal the tree and at each
level check if the node *p exists at each level.
// If it exists then check all sucessive nodes in that level
after node *p are having same parent as node *p.
  // If same parent dey r brothers.proceed to next node at same
leve.
  // continue dis until u find a node in dat level in which p is
present and u get a node which does nt have same parent as that of p. that
is the leftmost right cousin of p.

}

}

correct me if i am wrong :)


*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Wed, Aug 10, 2011 at 3:28 PM, muthu raj  wrote:

> @Mohit : in ur code u are breaking out when there parent reaches root. But
> not every time will we have to reach root. For example:  Leftmost right
> cousin of 1 is 9...in dat case parent should stop at 4. which is not the
> root.
>
> *Muthuraj R
> IV th Year , ISE
> PESIT , Bangalore*
>
>
>
> On Wed, Aug 10, 2011 at 3:26 PM, muthu raj  wrote:
>
>> @coder dumca: If u apply DFS  u will get a brother and not cousin. And yes
>> it works only for some cases.
>>
>> *Muthuraj R
>> IV th Year , ISE
>> PESIT , Bangalore*
>>
>>
>>
>> On Wed, Aug 10, 2011 at 2:24 PM, coder dumca wrote:
>>
>>> apply BFS
>>> the node after the particular node(whode cousin to be find) will be the
>>> required node
>>>
>>> On Wed, Aug 10, 2011 at 2:15 PM, Puneet Chawla <
>>> puneetchawla...@gmail.com> wrote:
>>>
>>>>
>>>> Agree with mohit goel..
>>>>
>>>> On Wed, Aug 10, 2011 at 11:22 AM, Mohit Goel >>> > wrote:
>>>>
>>>>>10
>>>>>  4  5
>>>>>2  7  6 11
>>>>>1 39   8 12  13   14   15
>>>>>
>>>>>
>>>>> i think we should first  find the parent of the particular node ..then
>>>>> apply the concept as told by Brijesh on it 
>>>>>
>>>>> p =parent(q);
>>>>> r = parent(p);
>>>>> count =1;
>>>>> while(p ==isright(r))
>>>>> {
>>>>> p=r;
>>>>> r=parent(r);
>>>>> count++;
>>>>> if(r==root)
>>>>> break;
>>>>>
>>>>> }
>>>>>
>>>>> if(d =right(r))
>>>>> {
>>>>> while(count!=0)
>>>>> {
>>>>> if(d->left)
>>>>> d=d->left;
>>>>> else d=d->right;
>>>>> count--;
>>>>> }
>>>>> }
>>>>> else return NULL;
>>>>> o/p=d->value;
>>>>>
>>>>>
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> With regards
>>>>   
>>>> Puneet Chawla
>>>> Computer Engineering Student
>>>> NIT Kurukshetra
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Microsoft written!!!

2011-08-10 Thread muthu raj
@Mohit : in ur code u are breaking out when there parent reaches root. But
not every time will we have to reach root. For example:  Leftmost right
cousin of 1 is 9...in dat case parent should stop at 4. which is not the
root.
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Wed, Aug 10, 2011 at 3:26 PM, muthu raj  wrote:

> @coder dumca: If u apply DFS  u will get a brother and not cousin. And yes
> it works only for some cases.
>
> *Muthuraj R
> IV th Year , ISE
> PESIT , Bangalore*
>
>
>
> On Wed, Aug 10, 2011 at 2:24 PM, coder dumca wrote:
>
>> apply BFS
>> the node after the particular node(whode cousin to be find) will be the
>> required node
>>
>> On Wed, Aug 10, 2011 at 2:15 PM, Puneet Chawla > > wrote:
>>
>>>
>>> Agree with mohit goel..
>>>
>>> On Wed, Aug 10, 2011 at 11:22 AM, Mohit Goel 
>>> wrote:
>>>
>>>>10
>>>>  4  5
>>>>2  7  6 11
>>>>1 39   8 12  13   14   15
>>>>
>>>>
>>>> i think we should first  find the parent of the particular node ..then
>>>> apply the concept as told by Brijesh on it 
>>>>
>>>> p =parent(q);
>>>> r = parent(p);
>>>> count =1;
>>>> while(p ==isright(r))
>>>> {
>>>> p=r;
>>>> r=parent(r);
>>>> count++;
>>>> if(r==root)
>>>> break;
>>>>
>>>> }
>>>>
>>>> if(d =right(r))
>>>> {
>>>> while(count!=0)
>>>> {
>>>> if(d->left)
>>>> d=d->left;
>>>> else d=d->right;
>>>> count--;
>>>> }
>>>> }
>>>> else return NULL;
>>>> o/p=d->value;
>>>>
>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>>
>>> --
>>> With regards
>>>   
>>> Puneet Chawla
>>> Computer Engineering Student
>>> NIT Kurukshetra
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Microsoft written!!!

2011-08-10 Thread muthu raj
@coder dumca: If u apply DFS  u will get a brother and not cousin. And yes
it works only for some cases.
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Wed, Aug 10, 2011 at 2:24 PM, coder dumca  wrote:

> apply BFS
> the node after the particular node(whode cousin to be find) will be the
> required node
>
> On Wed, Aug 10, 2011 at 2:15 PM, Puneet Chawla 
> wrote:
>
>>
>> Agree with mohit goel..
>>
>> On Wed, Aug 10, 2011 at 11:22 AM, Mohit Goel 
>> wrote:
>>
>>>10
>>>  4  5
>>>2  7  6 11
>>>1 39   8 12  13   14   15
>>>
>>>
>>> i think we should first  find the parent of the particular node ..then
>>> apply the concept as told by Brijesh on it 
>>>
>>> p =parent(q);
>>> r = parent(p);
>>> count =1;
>>> while(p ==isright(r))
>>> {
>>> p=r;
>>> r=parent(r);
>>> count++;
>>> if(r==root)
>>> break;
>>>
>>> }
>>>
>>> if(d =right(r))
>>> {
>>> while(count!=0)
>>> {
>>> if(d->left)
>>> d=d->left;
>>> else d=d->right;
>>> count--;
>>> }
>>> }
>>> else return NULL;
>>> o/p=d->value;
>>>
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> With regards
>>   
>> Puneet Chawla
>> Computer Engineering Student
>> NIT Kurukshetra
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] pls help

2011-08-09 Thread muthu raj
pls explain how u got 27?
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Wed, Aug 10, 2011 at 1:13 AM, sagar pareek  wrote:

> in ques 1 i considered leaves as nodes... if we consider only internal
> nodes then it have 27
>
>
> On Wed, Aug 10, 2011 at 1:12 AM, sagar pareek wrote:
>
>> 1.28+27
>> 2.2pow(d)
>>
>>
>> On Wed, Aug 10, 2011 at 12:07 AM, NIKHIL 
>> wrote:
>>
>>> In a ternary Tree No of leaves 28. How many nodes it have?
>>> An AVL tree with height d. How many children it have?
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> **Regards
>> SAGAR PAREEK
>> COMPUTER SCIENCE AND ENGINEERING
>> NIT ALLAHABAD
>>
>>
>
>
> --
> **Regards
> SAGAR PAREEK
> COMPUTER SCIENCE AND ENGINEERING
> NIT ALLAHABAD
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Microsoft written!!!

2011-08-09 Thread muthu raj
Write a C code to find Leftmost right cousin at the same level.

For ex:
   10
/\
   2 3
   /\ /\

  8 56 9

Leftmost right cousin of 5 is 6. Leftmost right cousin of 3 is NULL

*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Directi Question

2011-08-06 Thread muthu raj
Microsoft written:

What is the probability of getting atleast one 6 in  3 attempts of a dice?


*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sat, Aug 6, 2011 at 7:34 AM, shady  wrote:

> Hi,
>
> A fair dice is rolled. Each time the value is noted and running sum is
> maintained. What is the expected number of runs needed so that the sum is
> even ?
> Can anyone tell how to solve this problem ? as well as other related
> problems of such sort
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS

2011-08-05 Thread muthu raj
Yeah Kadanes algorithm. It can be done in O(n);

*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Fri, Aug 5, 2011 at 6:49 PM, Naren s  wrote:

> http://people.csail.mit.edu/bdean/6.046/dp/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Printf

2011-08-05 Thread muthu raj
physical adress is never acessible.Those who claim physical adress pls
support ur answers.
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Fri, Aug 5, 2011 at 4:57 PM, Kamakshii Aggarwal wrote:

> logical address
>
>
> On Fri, Aug 5, 2011 at 2:20 PM, Amol Sharma wrote:
>
>> physical address i think
>> --
>>
>>
>> Amol Sharma
>> Third Year Student
>> Computer Science and Engineering
>> MNNIT Allahabad
>>
>>
>>
>>
>> On Fri, Aug 5, 2011 at 1:01 AM, amit karmakar 
>> wrote:
>>
>>> Some discussions here,
>>> http://ubuntuforums.org/showthread.php?t=316081
>>> and some here,
>>> http://groups.google.com/group/comp.lang.c/msg/21250e8fe083e4f8
>>>
>>> On Aug 5, 12:51 pm, Anurag Narain  wrote:
>>> > i think logical address...physical address is never accessible to user
>>> > program
>>> >
>>> > @amit-can u explain why??
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards,
> Kamakshi
> kamakshi...@gmail.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package

2011-08-04 Thread muthu raj
@poised: Since it is read only memory junk will be the output if and only if
we enter any string containing characters not inside []. If we try
entering something present within [] i am getting segmentation fault.



*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Thu, Aug 4, 2011 at 6:21 PM, Poised~  wrote:

> If you guys see the question properly it says,
>
> char *str = "junk";
>
> str points to a read only memory and can't be written over with any method.
> Since there is no change in str. Hence the output will be "junk",
> irrespective of any input.
>
> regex has been properly explained as above.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/GLn4nI896ZkJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package

2011-08-04 Thread muthu raj
Can any one explain the  working of %[A telephonnic girl]
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Thu, Aug 4, 2011 at 12:25 PM, Nitish Garg wrote:

> The input for the above code was hello world. So the output would be hello.
> As the input will stop on reading 'w'.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/oX1YmZcDR2MJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon Aptitude questions

2011-08-03 Thread muthu raj
5)
Sample space=24C2= 276
N(S) = 12 C 2 + 12 C 2 =132

Probability= 132/276= 11/23


*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Wed, Aug 3, 2011 at 10:36 PM, Prakash D  wrote:

> assume there are 6 1's and 6 0's
>
> if two are selected together randomly%
> the possible outcomes are 00, 11, 01, 10
>
> 00- 30 possibilities
> 11 - 30 possibilities
>
> 10 - 36 possibilities
> 01 - 36 possibilities
>
>
> probability of 10  or 01 =  (36+36)/(30+30+36+36)
>
> =18/31
>
>  is it one of the options?
>
>
> On Wed, Aug 3, 2011 at 10:28 PM, JAIDEV YADAV  wrote:
>
>> there is no error in first question ... u thik so.. correct me if wrong
>> ...
>>
>>
>> On Wed, Aug 3, 2011 at 10:26 PM, Kamakshii Aggarwal <
>> kamakshi...@gmail.com> wrote:
>>
>>> i think dere is nothing wrong in ques 1.is there any error?
>>>
>>>
>>> On Wed, Aug 3, 2011 at 9:46 PM, cegprakash  wrote:
>>>
 2 is pretty easy..

 3: both

 5: 6/12 * 6/11  = 3/11

 am i right?

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


>>>
>>>
>>> --
>>> Regards,
>>> Kamakshi
>>> kamakshi...@gmail.com
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> JaiDev Yadav
>> (National Yoga Champion)
>> Computer Engg. Dept.
>> National Institute of Technology
>> Kurukshetra,Haryana
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Malloc()

2011-08-03 Thread muthu raj
Malloc implementation isnt simple as above. It involves system call sbrk()
to request memory to operating system and a suitable data structure to
allocate and deallocate memory from available memory blocks. Proper
implementation  of malloc is given in Kerningha ritchie text book :)
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Tue, Aug 2, 2011 at 11:03 PM, ghsjgl k  wrote:

> #include
> int size 1000
> void *a;
> static int freeindex;
> void *malloc(int n)
> {t
>if( n<(1000-freeindex) )
>   {
>   p=freeindex;
>   freeindex=freeindex+n;
> }
>   else
>printf(" insufficient memory");
> return a+p;
> }
>
> i dont think it exactly correct but you have to use the concept of the
> static variable here because it will remember the value of variable during
> recalling of function
>
>i presented here it because by seeing atleast one of you will get the
> idea.
> so friends try to understand it write even i want the correct code for it
>
> i think my code wont work
>
>
>
> On Tue, Aug 2, 2011 at 10:10 PM, rShetty  wrote:
>
>> Could anyone provide an algorithm/code and explanation for
>> implementation of malloc() in C .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Microsoft Internship

2011-08-03 Thread muthu raj
@saurabh : i got the complete idea. Can u explain how will bit represenation
be if a character is repeated 3 times? its set as 1 ryt?
*Muthuraj
IV th Year , ISE
PESIT , Bangalore*



On Tue, Aug 2, 2011 at 10:27 PM, saurabh singh  wrote:

> my hash table was my bitsread againI have posted this soln. earlier
> post too,,,posting again..
> 1.scan string.
> let the ascii value of each char visited be i
> if ith bit set
>then check visited region(last 4 ints) for ith bit
>if ith bit set do nothing
>else set it
> 2.if not set set the ith bit in the count region(first four ints) set it.
> 3.Now you done with scanning scan again checking the visited region for the
> ith bit.If set continue.
> else return the char,
> 4.If out of loop return -1
>
> Hope I am clear nowIf I am still not clear sorry I can't be more clear
> than this..
> On Tue, Aug 2, 2011 at 7:31 PM, muthu raj  wrote:
>
>> 1) subjective question:
>>
>> To find the first repetitive character how can you use bits because you
>> cannot keep track of first repeated character and also if a character is
>> present more than twice for ex thrice its mask shows 1 indicating it has
>> occured once. So  please tell how to implement in O(1) space. If we use Hash
>> table we can do it in O(n) space and time.
>>
>>
>>
>> *Muthuraj R
>> IV th Year , ISE
>> PESIT , Bangalore*
>>
>>
>>
>> On Tue, Aug 2, 2011 at 7:24 PM, saurabh singh wrote:
>>
>>> and optimize as much as you can...even if the interviewer says that he is
>>> satisfied
>>> I was asked Q.1 mentioned above.I  first used bitset.He asked me if I
>>> could do in pure c without using *any other function.*While I was
>>> working on my  code he said he will be ok if I use an int array of 256.I
>>> kept telling him I could do better,he need not worry.I ended up with just 8
>>> int variables(and an internship with MS) :)* *
>>>
>>>
>>> On Tue, Aug 2, 2011 at 6:55 PM, sourabh jakhar 
>>> wrote:
>>>
>>>> abe dce se kitne leke gaye ms final year se aur package kya offer kiya
>>>>
>>>>
>>>> On Tue, Aug 2, 2011 at 6:21 PM, Anurag atri 
>>>> wrote:
>>>>
>>>>> you have to be in formals for sure !
>>>>> yes , people who clear the written will have 3 interviews .
>>>>>
>>>>>
>>>>> On Tue, Aug 2, 2011 at 2:15 PM, saurabh modi <
>>>>> saurabhmodi102...@gmail.com> wrote:
>>>>>
>>>>>> hey man,could you tell something abt the attire and all.?
>>>>>> we dont need to go in formals,right?
>>>>>> plus,koi interview and all hoga?
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Regards
>>>>> Anurag Atri
>>>>> III year
>>>>> Computer Engineering
>>>>> Delhi College Of Engineering
>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> SOURABH JAKHAR,(CSE)(Final year)
>>>> ROOM NO 167 ,
>>>> TILAK,HOSTEL
>>>> 'MNNIT ALLAHABAD
>>>>
>>>>  The Law of Win says, "Let's not do it your way or my way; let's do it
>>>> the best way."
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks"

Re: [algogeeks] Microsoft Internship

2011-08-02 Thread muthu raj
1) subjective question:

To find the first repetitive character how can you use bits because you
cannot keep track of first repeated character and also if a character is
present more than twice for ex thrice its mask shows 1 indicating it has
occured once. So  please tell how to implement in O(1) space. If we use Hash
table we can do it in O(n) space and time.



*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Tue, Aug 2, 2011 at 7:24 PM, saurabh singh  wrote:

> and optimize as much as you can...even if the interviewer says that he is
> satisfied
> I was asked Q.1 mentioned above.I  first used bitset.He asked me if I could
> do in pure c without using *any other function.*While I was working on my
>  code he said he will be ok if I use an int array of 256.I kept telling him
> I could do better,he need not worry.I ended up with just 8 int variables(and
> an internship with MS) :)* *
>
>
> On Tue, Aug 2, 2011 at 6:55 PM, sourabh jakhar wrote:
>
>> abe dce se kitne leke gaye ms final year se aur package kya offer kiya
>>
>>
>> On Tue, Aug 2, 2011 at 6:21 PM, Anurag atri wrote:
>>
>>> you have to be in formals for sure !
>>> yes , people who clear the written will have 3 interviews .
>>>
>>>
>>> On Tue, Aug 2, 2011 at 2:15 PM, saurabh modi <
>>> saurabhmodi102...@gmail.com> wrote:
>>>
 hey man,could you tell something abt the attire and all.?
 we dont need to go in formals,right?
 plus,koi interview and all hoga?

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>
>>>
>>> --
>>> Regards
>>> Anurag Atri
>>> III year
>>> Computer Engineering
>>> Delhi College Of Engineering
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> SOURABH JAKHAR,(CSE)(Final year)
>> ROOM NO 167 ,
>> TILAK,HOSTEL
>> 'MNNIT ALLAHABAD
>>
>>  The Law of Win says, "Let's not do it your way or my way; let's do it
>> the best way."
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Saurabh Singh
> B.Tech (Computer Science)
> MNNIT ALLAHABAD
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Interview ques

2011-07-31 Thread muthu raj
Function overriding gains significance only when functions are declared
virtual. Otherwise Overriding does not serve any purpose. the main idea
behind virtual functions and method overloading is to implement Dynamic
Polymorphism i.e decide which version of function(base or derived)  to be
invoked during runtime.
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sun, Jul 31, 2011 at 10:22 AM, Sandeep Jain wrote:

> @Pandharinath: Please consider the following e.g.
> class A
> {
> public:
> void func(){ /* A'simplementation */}
> };
>
> class B:public A
> {
> public:
> void func(){/* B's implementation*/ }
> };
>
> What is B's func() doing?
>
>
>
>
> Regards,
> Sandeep Jain
>
>
>
>
> On Sun, Jul 31, 2011 at 10:36 PM, pandharinath gorde <
> pandharinath.go...@gmail.com> wrote:
>
>>
>> sandeep ur misguiding all things are,.
>>
>> for overriding virtual keyword is used that means virtual functions only
>> overriden.
>> In c++ u require to add virtual keyword.
>> and in java every non static function is by default virtual.
>>
>>
>>
>> On Sun, Jul 31, 2011 at 10:23 PM, Sandeep Jain wrote:
>>
>>> Overridden functions and virtual functions are two different concepts...
>>> 1) Two functions in the same scope having same but different signatures =
>>> Over Loading
>>> 2) Two functions having same signatures but one defined in parent class
>>> and the other defined in child class == Overriding
>>> 3) Virtual functions, allow for run time polymorphism among overridden
>>> functions.(only when invoked using pointer)
>>>
>>> btw I'm still trying to think if preventing function over-riding is
>>> possible...
>>>
>>>
>>> Regards,
>>> Sandeep Jain
>>>
>>>
>>>
>>>
>>> On Sun, Jul 31, 2011 at 10:13 PM, Ankit Minglani <
>>> ankit.mingl...@gmail.com> wrote:
>>>
>>>> @aditi : in C++ you define a function virtual to let the derived class
>>>> give its own definition for the same. and in that case the functions are
>>>> overridden. unlike in JAVA where no virtual keyword is needed .. so if you
>>>> write the same code as above in java .. that may be referred to as Method
>>>> overriding .. but not in cpp.
>>>>
>>>>
>>>> On Sun, Jul 31, 2011 at 9:34 AM, aditi garg 
>>>> wrote:
>>>>
>>>>> @ Ankit: Wat is overriding actually thn?
>>>>>
>>>>>
>>>>> On Sun, Jul 31, 2011 at 9:58 PM, Anika Jain wrote:
>>>>>
>>>>>> ohkk.. m so sorry
>>>>>>
>>>>>>
>>>>>> On Sun, Jul 31, 2011 at 9:41 PM, Ankit Minglani <
>>>>>> ankit.mingl...@gmail.com> wrote:
>>>>>>
>>>>>>> @anika: This is not function overriding i think .. you cannot call
>>>>>>> the f() function of the base class from the derived class object .. 
>>>>>>> what you
>>>>>>> are doing is creating a object of the derived class and calling the 
>>>>>>> version
>>>>>>> of f() that belong to derived class B .. ie is the same class object is
>>>>>>> calling the same class function .
>>>>>>>
>>>>>>> correct me if i m wrong .
>>>>>>>
>>>>>>>
>>>>>>> On Sun, Jul 31, 2011 at 8:42 AM, Anika Jain 
>>>>>>> wrote:
>>>>>>>
>>>>>>>> @ muthu : not declaring tht function as virtual wont save overriding
>>>>>>>>
>>>>>>>> class A
>>>>>>>> {
>>>>>>>> int a;
>>>>>>>>
>>>>>>>> public:
>>>>>>>> void f()
>>>>>>>> {}
>>>>>>>> int f2(){}
>>>>>>>> };
>>>>>>>>
>>>>>>>> class B:public A
>>>>>>>> {
>>>>>>>> public:
>>>>>>>> void f()
>>>>>>>> {
>>>>>>>> cout<<"abc\n";
>>>>>>>> }
>>>>>>>> };
>>>>>>>>
>>>>>>>> int main()
>>>>>>>> {
>>>>>>>

Re: [algogeeks] Re: Interview ques

2011-07-31 Thread muthu raj
Using friend functions we can only invoke already defined private functions.
We cannot override or prevent overriding using friend functions. The problem
here is how to prevent base class function from being overridden in derived
class.
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sun, Jul 31, 2011 at 8:04 AM, Anika Jain  wrote:

> what if we write that function as private of base class.. and make a
> function in derived class that is friend function of the base class do that
> it can call tht private function of base.??
>
>
> On Sun, Jul 31, 2011 at 8:25 PM, muthu raj  wrote:
>
>> Yeah but there is no equivalent of final keyword in c++.So to prevent
>> member function from overriding in derived class in c++ dont declare the
>> member function as virtual. Then it cannot be overridden in derived class.
>> There is no other way of preventing a member function of base class from
>> being overridden.
>>
>> *Muthuraj R
>> IV th Year , ISE
>> PESIT , Bangalore*
>>
>>
>>
>> On Sun, Jul 31, 2011 at 7:38 AM, himanshu kansal <
>> himanshukansal...@gmail.com> wrote:
>>
>>> i think there is no keyword known as final in c++.maybe u are talking
>>> with respect to java
>>>
>>>
>>> On Sun, Jul 31, 2011 at 8:03 PM, muthu raj  wrote:
>>>
>>>> By  declaring the function a static final f().
>>>> *Muthuraj R
>>>> IV th Year , ISE
>>>> PESIT , Bangalore*
>>>>
>>>>
>>>>
>>>> On Sun, Jul 31, 2011 at 7:28 AM, himanshu kansal <
>>>> himanshukansal...@gmail.com> wrote:
>>>>
>>>>> sry i thinki misspelled d ques
>>>>> d ques was
>>>>>
>>>>>
>>>>> how will you protect a derived class to override base class's member
>>>>> function in c++
>>>>>
>>>>> say if there is a function f() in base class then derived should not be
>>>>> able to
>>>>> override f() to provide its own definition.
>>>>> but The function must be accessible in derived class.
>>>>>
>>>>>
>>>>> PS:dont try to make the function private in base class( it will be
>>>>> become inaccessible in derived class).
>>>>>
>>>>> On Sun, Jul 31, 2011 at 7:49 PM, himanshu kansal <
>>>>> himanshukansal...@gmail.com> wrote:
>>>>>
>>>>>> how will you protect a base class to override its member function in
>>>>>> derived class
>>>>>>
>>>>>> say if there is a function f() in base class then derived cannot
>>>>>> override f() to provide its own definition.
>>>>>> The function must be accessible in derived class.
>>>>>>
>>>>>> PS:dont try to make the function private in base class( it will be
>>>>>> become inaccessible in derived class).
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>>   Regards
>>>>> Himanshu Kansal
>>>>>   Msc Comp. sc.
>>>>> (University of Delhi)
>>>>>
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>>
>>> --
>>>
>>>   Regards
>>> Himanshu Kansal
>>>   Msc Comp. sc.
>>> (University of Delhi)
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
&g

Re: [algogeeks] Re: Interview ques

2011-07-31 Thread muthu raj
Yeah but there is no equivalent of final keyword in c++.So to prevent
member function from overriding in derived class in c++ dont declare the
member function as virtual. Then it cannot be overridden in derived class.
There is no other way of preventing a member function of base class from
being overridden.
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sun, Jul 31, 2011 at 7:38 AM, himanshu kansal <
himanshukansal...@gmail.com> wrote:

> i think there is no keyword known as final in c++.maybe u are talking
> with respect to java
>
>
> On Sun, Jul 31, 2011 at 8:03 PM, muthu raj  wrote:
>
>> By  declaring the function a static final f().
>> *Muthuraj R
>> IV th Year , ISE
>> PESIT , Bangalore*
>>
>>
>>
>> On Sun, Jul 31, 2011 at 7:28 AM, himanshu kansal <
>> himanshukansal...@gmail.com> wrote:
>>
>>> sry i thinki misspelled d ques
>>> d ques was
>>>
>>>
>>> how will you protect a derived class to override base class's member
>>> function in c++
>>>
>>> say if there is a function f() in base class then derived should not be
>>> able to
>>> override f() to provide its own definition.
>>> but The function must be accessible in derived class.
>>>
>>>
>>> PS:dont try to make the function private in base class( it will be
>>> become inaccessible in derived class).
>>>
>>> On Sun, Jul 31, 2011 at 7:49 PM, himanshu kansal <
>>> himanshukansal...@gmail.com> wrote:
>>>
>>>> how will you protect a base class to override its member function in
>>>> derived class
>>>>
>>>> say if there is a function f() in base class then derived cannot
>>>> override f() to provide its own definition.
>>>> The function must be accessible in derived class.
>>>>
>>>> PS:dont try to make the function private in base class( it will be
>>>> become inaccessible in derived class).
>>>
>>>
>>>
>>>
>>> --
>>>
>>>   Regards
>>> Himanshu Kansal
>>>   Msc Comp. sc.
>>> (University of Delhi)
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
>
>   Regards
> Himanshu Kansal
>   Msc Comp. sc.
> (University of Delhi)
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Interview ques

2011-07-31 Thread muthu raj
By  declaring the function a static final f().
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sun, Jul 31, 2011 at 7:28 AM, himanshu kansal <
himanshukansal...@gmail.com> wrote:

> sry i thinki misspelled d ques
> d ques was
>
>
> how will you protect a derived class to override base class's member
> function in c++
>
> say if there is a function f() in base class then derived should not be
> able to
> override f() to provide its own definition.
> but The function must be accessible in derived class.
>
>
> PS:dont try to make the function private in base class( it will be
> become inaccessible in derived class).
>
> On Sun, Jul 31, 2011 at 7:49 PM, himanshu kansal <
> himanshukansal...@gmail.com> wrote:
>
>> how will you protect a base class to override its member function in
>> derived class
>>
>> say if there is a function f() in base class then derived cannot
>> override f() to provide its own definition.
>> The function must be accessible in derived class.
>>
>> PS:dont try to make the function private in base class( it will be
>> become inaccessible in derived class).
>
>
>
>
> --
>
>   Regards
> Himanshu Kansal
>   Msc Comp. sc.
> (University of Delhi)
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread muthu raj
Use a circular linked list with elements being inserted in sorted order.

Inserting minimum element :

struct node *p;
p is a pointer to last node in the circular singly linked list.
newmin->next=p->next;
p->next=newmin;


Deleting minimum element:

struct node *temp;
temp=p->next;
p->next=p->next->next;
free(temp);


Retrieving minimum element :

return (p->next->ele);








*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sun, Jul 31, 2011 at 2:08 AM, naveen ms  wrote:

> @shubham...i have a doubt.can't the same be done with singly linked list??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Facebook Intern F2F Interview

2011-07-28 Thread Muthu Raj
ya me toowas readin % as modulus :)
*Muthuraj R.
4TH Year BE.**
Information Science Dept*
*PESIT, Bengaluru .
*




On Thu, Jul 28, 2011 at 9:13 PM, sunny agrawal wrote:

> Okay... i was reading % as Modulus operator :(
>
> did u gave the solution Nikhil posted , i think that should be the answer.
>
>
> On Thu, Jul 28, 2011 at 9:10 PM, KK  wrote:
>
>> @Nikhil: ya true but i dont know wht else was he expecting.
>>
>> @sunny and Muthu: like suppose u pass 20 then func should return true
>> with 20% probabily and false otherwise...
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] [offtopic] Something to share for those preparing for Amazon Campus Interviews!

2011-07-28 Thread Muthu Raj
Thnks a lot  neha :)
*Muthuraj R.
4TH Year BE.**
Information Science Dept*
*PESIT, Bengaluru .
*




On Thu, Jul 28, 2011 at 6:01 PM, Neha Sharan  wrote:

> @rahul:what kind of questons were asked in aptitude test?
>
> On Thu, Jul 28, 2011 at 5:54 PM, Rahul Menon wrote:
>
>> Hello friends,
>>
>> Recently I appeared for placement interviews for Amazon in my
>> campus.Unfortunately though I couldn't make it, still want to share
>> something for others here preparing for amazon interviews!
>>
>> First of all though it is very hard to crack, here are a few things
>> which can make your preparation easier and effective!
>>
>> In the interview, I have found that most of the questions asked are
>> repeated questions which are available online rather than any new
>> questions they have made. A few examples are loop in a linked list,
>> print all permuations of a string, binary search in a rotated array
>> etc.. These all questions are very commonly found in websites like
>> careercup.com and also in this google group. Instead of just going
>> through hundreds of question be sure that you can perform the best of
>> 100% if you are given from these frequently asked questions.
>>
>> Just to add, if you are very good in coding it's fine , else make sure
>> that you can also code these above questions very well rather than
>> just explaining the algos!. They will definitely ask you to code
>> these!
>>
>> In " Cracking the coding interview" all the questions are very very
>> important. To my astonishment most of the questions in the sections
>> like Linked LIsts, Arrays, Trees and Graph, Recursion from the
>> aforesaid book were asked in our interview!  So never miss reading and
>> coding these questions before going to your interview.
>>
>> Though it's very weird to say, I would say that if you are very very
>> good with these around 40 most frequently repeated questions, which
>> can be collected through googling, your performance is almost 80%
>> guaranteed in the interview. It's sure that you will have to face only
>> a very few question outside from this. And if you are somewhat more
>> good enough , you can easily make through to the AMAZON!
>>
>> All the best for all :)
>> Repeating once again, rather than just reading through hundreds of
>> questions it would be best if you practice coding and studying the few
>> 30 interview questions! Else you will have to regret like me :|
>>
>>
>> #We will be having Google on our campus soon! I'm totally strange to
>> their selection process,tests and intreview, so if anyone have any
>> idea please do share here! Thanks!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Facebook Intern F2F Interview

2011-07-28 Thread Muthu Raj
Please elaborate upon the question a little more :)
*Muthuraj R.
4TH Year BE.**
Information Science Dept*
*PESIT, Bengaluru .
*




On Thu, Jul 28, 2011 at 4:21 PM, KK  wrote:

> bool foo(int x)
>
> // Implement this function where 0 <= x <= 100
> It should return true x% of times n false otherwise
>
> first i told him to have a static int s then increment it each time
> the func is called...
> and if  s % (100 - x ) == 0 then true else false.
>
> then he told me to have some different approach..
>
> I told him like this:
>
> bool foo(int x)
> {
>// checking if x is btw 0 & 100
>
>if(x == 0)
>  return false;
>if(x == 100)
>  return true;
>
> srand(time(0));
> int rno = rand();
>
> if(rno % (100 - x) == 0)
>return True;
> else
>   return False;
> }
>
> He was like okk but i think he was not completely satisfied
> Any other Approach...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C-question

2011-07-27 Thread Muthu Raj
I am getting the proper output :) 1 0 1 0 1 1 0 1




*Muthuraj R.
4TH Year BE.**
Information Science Dept*
*PESIT, Bengaluru .
*




On Wed, Jul 27, 2011 at 11:19 PM, Vijay Khandar wrote:

> #include
> #include
> int f(int n)
> {
> if(n<=1)
> {
> printf(" %d",n);
> }
> else
> {
> f(n/2);
> printf(" %d",n%2);
> }
> }
>
> void main()
> {
> clrscr();
> f(173);
> getch();
> }
>
> o/p-1 0 1 0 1 1 0 1
> but i m getting  1 0 1 1 0 1 0 1
>
> plz explain me...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.