Re: [algogeeks] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-28 Thread Lomash Goyal
we can create linked list for the number where each node will store some k
digits (say 5) in the reverse order.then we just perform a normal addition
of the data of the nodes with the help of carry.
note that if the numbers are not positive then we need to maintain a sign
bit node also.if any of the number is negative then we have to find the
greater number among the both considering their absolute values only.
in this case for comparing the two numbers use doubly linked list so as to
compare the digits.

On Tue, Jun 26, 2012 at 7:33 PM, Ashish Goel ashg...@gmail.com wrote:

 the base is not given, so 10 can't be assumed

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Jun 26, 2012 at 4:38 PM, amrit harry dabbcomput...@gmail.comwrote:

 make size of both array by adding '0' in front of smaller array
 then
 int carry=0;
 for(i=array.size();i=0;i--)
 {
 sum[i]=carry+arrayA[i]+arrayB[i];
 carry=sum[i]/10;
 sum[i]=sum[i]%10;
 }
 then reverse and print sum
 On Tue, Jun 26, 2012 at 3:40 PM, Ashish Goel ashg...@gmail.com wrote:


 Best Regards

 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652

 --
 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.




 --
 Thanks  Regards
 Amritpal singh

  --
 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

Lomash Goyal
*
*

-- 
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] Fixing Up The Binary Search Tree

2012-06-28 Thread atul anand
we can go for bottom up approch .so go the leftmost leaf node and then
pass this node as a root to the function which implements AVL rotations.Do
the same as we move back in the recursion  i guess this will work as we
are balancing the the left and right subtree of node say X before we move
back.

On Wed, Jun 27, 2012 at 10:32 PM, Krishna Kishore
kknarenkris...@gmail.comwrote:

 Suppose a Binary Search Tree which is unbalanced.is given. Write a
 routine to balance the Binary Search Tree.
 Send the Root of the BST as an argument to that routine. It has to Return
 the Root of the Balanced BST.
 Thanks In Advance.

 --
 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/-/iYdbt5mI4BQJ.
 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] Inorder Iterative code for printing paths

2012-06-28 Thread Amitesh Singh
void printPath(node *p,node *child)
{
  if( p  child)
std::cout  Path:   p-data   =child-data 
std::endl;
}

use  this before you assign 'current' to its children.
e.g.

   printPath(p,p-left)
   or
   printPath(p,p-right);


-- 
Amitesh




On Mon, Jun 25, 2012 at 11:34 PM, Nishant Pandey 
nishant.bits.me...@gmail.com wrote:


 thiss is iterative inorder  code i am using for printing all the paths of
 the Btree .

 but i am not able to manipulate the lengths properly when its perform pop
 up so that i
 can print the paths properly ..

 Can any one help by modifying the changes in this code .



 void inorder(struct node *root)
 {
 stackstruct node*stack_temp;

 struct node *current,*temp;
 int path[20];
 int i =0 ,j=0;
 if(!root)return ;

 current=root;
 bool flag=false;
 //bool ctrl=false;
 while(!flag)
 {

 if(current)
 {
 //coutcurrent-dataendl;
 stack_temp.push(current);
 path[i++]=current-data;
 if(current-left == NULL  current-right == NULL)
 {
 for(j=0;ji;j++)
 coutpath[j] ;
 //i--;

 }

 coutendl;
 current=current-left;

 }
 else
 {
 if(stack_temp.empty())
 {
 flag=true;
 }
 else
 {
 current=stack_temp.top();
 stack_temp.pop();

 i--;


 //if(current-right)
 //coutcurrent-dataendl;
 current=current-right;
 if(current)
 i++;
 }

 }

 }


 }



 --
 Cheers,

 Nishant Pandey |Specialist Tools Development  |  
 npan...@google.comgvib...@google.com |
 +91-9911258345


  --
 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] trie display

2012-06-28 Thread deepikaanand
If there is a trie of following strings(say URLs)
abcde,abcegh,abcpqr,abcxyz,xyz

if input = abc
then output should be = de,egh,pqr,xyz

How can I code for 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.



Re: [algogeeks] trie display

2012-06-28 Thread Prem Krishna Chettri
Well it Seems like problem is the DS here.

if U have the DS of trie as

  struct trie {
  char letter;// Not being general
  boolean islast;
  int startindex;
  struct trie *next;
  };

I am sure  you won't have any issue. coz now what u have to do is to start
searching the code which matches the startindex with the given input and
search till the islast is not equal to true. Well thats how trie works if
ppls are unaware..

BR,
Prem

On Thu, Jun 28, 2012 at 12:23 PM, deepikaanand swinyanand...@gmail.comwrote:

 If there is a trie of following strings(say URLs)
 abcde,abcegh,abcpqr,abcxyz,xyz

 if input = abc
 then output should be = de,egh,pqr,xyz

 How can I code for 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.



[algogeeks] Re: trie display

2012-06-28 Thread deepikaanand
@Prem

I know the implementation of trie...But I have doubt that say I have
struct trie * current..
and input = abc...The last character matched with head-CHILDREN[i]-
letter will be 'c'... now current points to c

next step- there will be 4 branches from
'c'...de,xyz,efgh,pqr...

Now  if write
for(i=0;i26;i++)
{
if (current-CHILDREN[i]!=NULL  current-CHILDREN[i]-islast==0)
{
cout  current-CHILDREN[i]-letter; //d   e
current = current-CHILDREN[i];//head now points to 'e'
}
}



The problem I am facing is how to take back current pointer to 'c'
so that now I get efgh as output...and secondly how can I make sure
that this time 'd' node is not selected again???

-- 
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] trie display

2012-06-28 Thread raghavan M
tire will always contain the link to all its children.This problem is just 
printing out the children once the key is fully reached.

ie., search for abc in trie print all the children of c node.

Raghavan





 From: deepikaanand swinyanand...@gmail.com
To: Algorithm Geeks algogeeks@googlegroups.com 
Sent: Thursday, 28 June 2012 12:23 PM
Subject: [algogeeks] trie display
 
If there is a trie of following strings(say URLs)
abcde,abcegh,abcpqr,abcxyz,xyz

if input = abc
then output should be = de,egh,pqr,xyz

How can I code for 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.



Re: [algogeeks] Inorder Iterative code for printing paths

2012-06-28 Thread Amitesh Singh
and to count no. of paths, you can do this
void printPath(node *p,node *child)
{
  static int iCountPath = 0; // or pass it as an argument non-const ref.
  if( p  child)
  {
++iCountPath;
std::cout  Path:   p-data   =child-data 
std::endl;
  }
}

-- 
Amitesh




On Thu, Jun 28, 2012 at 11:01 AM, Amitesh Singh singh.amit...@gmail.comwrote:

 void printPath(node *p,node *child)
 {
   if( p  child)
 std::cout  Path:   p-data   =child-data 
 std::endl;
 }

 use  this before you assign 'current' to its children.
 e.g.

printPath(p,p-left)
or
printPath(p,p-right);


 --
 Amitesh




 On Mon, Jun 25, 2012 at 11:34 PM, Nishant Pandey 
 nishant.bits.me...@gmail.com wrote:


 thiss is iterative inorder  code i am using for printing all the paths of
 the Btree .

 but i am not able to manipulate the lengths properly when its perform pop
 up so that i
 can print the paths properly ..

 Can any one help by modifying the changes in this code .



 void inorder(struct node *root)
 {
 stackstruct node*stack_temp;

 struct node *current,*temp;
 int path[20];
 int i =0 ,j=0;
 if(!root)return ;

 current=root;
 bool flag=false;
 //bool ctrl=false;
 while(!flag)
 {

 if(current)
 {
 //coutcurrent-dataendl;
 stack_temp.push(current);
 path[i++]=current-data;
 if(current-left == NULL  current-right == NULL)
 {
 for(j=0;ji;j++)
 coutpath[j] ;
 //i--;

 }

 coutendl;
 current=current-left;

 }
 else
 {
 if(stack_temp.empty())
 {
 flag=true;
 }
 else
 {
 current=stack_temp.top();
 stack_temp.pop();

 i--;


 //if(current-right)
 //coutcurrent-dataendl;
 current=current-right;
 if(current)
 i++;
 }

 }

 }


 }



 --
 Cheers,

 Nishant Pandey |Specialist Tools Development  |  
 npan...@google.comgvib...@google.com |
 +91-9911258345


  --
 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] Re: trie display

2012-06-28 Thread deepikaanand
@Prem
I know the implementation of trie...But I have doubt that say I have
struct trie * current..
and input = abc...The last character matched with head-CHILDREN[i]-
letter will be 'c'... now current points to c




next step- there will be 4 branches from
'c'...de,xyz,efgh,pqr...
Now  if write
for(i=0;i26;i++)
{
if (current-CHILDREN[i]!=NULL  current-islast==0)
{
cout  current-CHILDREN[i]-letter; //d   e
current = current-CHILDREN[i];//head now points to 'e'
}
}




The problem I am facing is how to take back current pointer to
'c'
so that now I get efgh as output...and secondly how can I make sure
that this time 'd' node is not selected again???

-- 
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] Explain the output

2012-06-28 Thread Mad Coder
Please explain the output of following C code

#includestdio.hchar *str = char *str = %c%s%c; main(){ printf(str,
34, str, 34);};
int main()
{
printf(str, 34, str, 34);
return 0;
}

Output--
char *str = char *str = %c%s%c; main(){ printf(str, 34, str, 34);};
main(){ printf(str, 34, str, 34);}

-- 
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 interview qs

2012-06-28 Thread deepikaanand
//Taken from careercup.com

Design the autocomplete feature (ex:Google Suggest)

I assumed {abcde,abcegh,abcpqr,abcxyz,xyz ,abcmno} URLs
and stored them in trie...Such if the user enters abc ...the o/p will
be

abc is a prefix in 5 number of cases
  d e
  e g h
  m n o
  p q r
  x y z


Now say if I add more strings of the form abcdpqr,abcdprst..How can
I modify this code such that now thw o/p is

  d e
  e g h
  m n o
  p q r
  x y z
 d p q r
 d p r s t

code in c :-
http://ideone.com/rBvQb

-- 
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] Re: trie display

2012-06-28 Thread deepikaanand
It is not working..Even i tried to solve the problem using recursion
but it didnt work

code :-

http://ideone.com/UhTTx

-- 
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: trie display

2012-06-28 Thread Guruprasad Sridharan
You should do a dfs from the node which matches the prefix say abc. If
its a word then print it.

On Thu, Jun 28, 2012 at 3:55 PM, deepikaanand swinyanand...@gmail.comwrote:

 It is not working..Even i tried to solve the problem using recursion
 but it didnt work

 code :-

 http://ideone.com/UhTTx

 --
 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] Explain the output

2012-06-28 Thread vaibhav shukla
This might Help
http://en.wikipedia.org/wiki/Quine_(computing)

On Thu, Jun 28, 2012 at 2:01 PM, Mad Coder imamadco...@gmail.com wrote:

 Please explain the output of following C code

 #includestdio.hchar *str = char *str = %c%s%c; main(){ printf(str, 34, 
 str, 34);};
 int main()
 {
 printf(str, 34, str, 34);
 return 0;
 }

 Output--
 char *str = char *str = %c%s%c; main(){ printf(str, 34, str, 34);}; main(){ 
 printf(str, 34, str, 34);}


  --
 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.




-- 
best wishes!!
 Vaibhav

-- 
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] trie display

2012-06-28 Thread atul anand
do similar to inorder traversal after reaching at node 'c'..you will get
the desired output and in dictionary order .

On Thu, Jun 28, 2012 at 12:23 PM, deepikaanand swinyanand...@gmail.comwrote:

 If there is a trie of following strings(say URLs)
 abcde,abcegh,abcpqr,abcxyz,xyz

 if input = abc
 then output should be = de,egh,pqr,xyz

 How can I code for 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.



Re: [algogeeks] Explain the output

2012-06-28 Thread amrit harry
print statement become
printf(char *str= %c%s%c; main...,34,str,34);
now 34 is ascii value of double quote so first %c will get value
ascii_code_of(34) and %s will get same string and last %c again get
ascii_code_of(34) i.e   so total string is  char *str=+
asci(34)+str+ascii(34)+;main() { printf(str,34,str,34);}

On Thu, Jun 28, 2012 at 2:01 PM, Mad Coder imamadco...@gmail.com wrote:

 Please explain the output of following C code

 #includestdio.hchar *str = char *str = %c%s%c; main(){ printf(str, 34, 
 str, 34);};
 int main()
 {
 printf(str, 34, str, 34);
 return 0;
 }

 Output--
 char *str = char *str = %c%s%c; main(){ printf(str, 34, str, 34);}; main(){ 
 printf(str, 34, str, 34);}


  --
 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.




-- 
Thanks  Regards
Amritpal singh

-- 
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] Re: Question asked in Amazon online test

2012-06-28 Thread ANKIT BHARDWAJ

get the right most zero and left most one if index of right most zero is 
less than the index of left most one ,the problem is solved other wise swap 
0 and 1 and so on...
i argue this will give minimum swaps...

-- 
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/-/ELCan59xll4J.
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] MS Question :implement read write lock class

2012-06-28 Thread Ashish Goel
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652

-- 
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] Re: Microsoft Interview Question

2012-06-28 Thread ANKIT BHARDWAJ


keep swaping left most -ve and left most positive untill counter reaches at 
the end of array, can be done in o(n) no extra space required..


3rd year 
manit bhopal

-- 
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/-/5PTaaqy6FhMJ.
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] Re: Microsoft Interview Question

2012-06-28 Thread Navin Gupta
Keep two pointers - one at start of the array and other at end of the array 
Now current points to start of the array 
If current is negative , increment current
If current is positive , swap it with the element at end and decrement 
current and end both 
If current = end , then break.

Navin Kumar Gupta
Final Year, B.Tech (Hons.)
Computer Science  Engg.
National Institute of Technology,Jamshedpur
Mobile - 8285303045

-- 
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/-/j13jp_PBk44J.
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] Inorder Iterative code for printing paths

2012-06-28 Thread Nishant Pandey
thanx amitesh code is working fine .. i was displaying it in other way not
like this , but yea it can be shown in this way too ..

On Thu, Jun 28, 2012 at 1:08 PM, Amitesh Singh singh.amit...@gmail.comwrote:

 and to count no. of paths, you can do this
 void printPath(node *p,node *child)
 {
   static int iCountPath = 0; // or pass it as an argument non-const ref.
   if( p  child)
   {
 ++iCountPath;
 std::cout  Path:   p-data   =child-data 
 std::endl;
   }
 }

 --
 Amitesh




 On Thu, Jun 28, 2012 at 11:01 AM, Amitesh Singh 
 singh.amit...@gmail.comwrote:

 void printPath(node *p,node *child)
 {
   if( p  child)
 std::cout  Path:   p-data   =child-data 
 std::endl;
 }

 use  this before you assign 'current' to its children.
 e.g.

printPath(p,p-left)
or
printPath(p,p-right);


 --
 Amitesh




 On Mon, Jun 25, 2012 at 11:34 PM, Nishant Pandey 
 nishant.bits.me...@gmail.com wrote:


 thiss is iterative inorder  code i am using for printing all the paths
 of the Btree .

 but i am not able to manipulate the lengths properly when its perform
 pop up so that i
 can print the paths properly ..

 Can any one help by modifying the changes in this code .



 void inorder(struct node *root)
 {
 stackstruct node*stack_temp;

 struct node *current,*temp;
 int path[20];
 int i =0 ,j=0;
 if(!root)return ;

 current=root;
 bool flag=false;
 //bool ctrl=false;
 while(!flag)
 {

 if(current)
 {
 //coutcurrent-dataendl;
 stack_temp.push(current);
 path[i++]=current-data;
 if(current-left == NULL  current-right == NULL)
 {
 for(j=0;ji;j++)
 coutpath[j] ;
 //i--;

 }

 coutendl;
 current=current-left;

 }
 else
 {
 if(stack_temp.empty())
 {
 flag=true;
 }
 else
 {
 current=stack_temp.top();
 stack_temp.pop();

 i--;


 //if(current-right)
 //coutcurrent-dataendl;
 current=current-right;
 if(current)
 i++;
 }

 }

 }


 }



 --
 Cheers,

 Nishant Pandey |Specialist Tools Development  |  
 npan...@google.comgvib...@google.com |
 +91-9911258345


  --
 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.






-- 
Cheers,

Nishant Pandey |Specialist Tools Development  |
npan...@google.comgvib...@google.com |
+91-9911258345

-- 
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] can anyone tell me

2012-06-28 Thread Rahul verma
can anyone tell me how to prepare OS subject for placement and interview

which type of question interviewer will ask?

which website will i prefer ?

plzzz tell 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.



Re: [algogeeks] can anyone tell me

2012-06-28 Thread Abhishek Sharma
naa noone can tell you.. haha.. just kidding...

for OS refer the prescribed text. I studied from Silberschatz, Galvin,
Gagne: *Operating System Concepts.. *
amazing book.. just understand the basics.. like process shceduling
algorithms, page shceduling algorithms, threads, context switching, virtual
memory, paging, thrashing, deadlocks etc...

On Thu, Jun 28, 2012 at 10:49 PM, Rahul verma
laptan2...@gmail.com wrote:

 can anyone tell me how to prepare OS subject for placement and interview

 which type of question interviewer will ask?

 which website will i prefer ?

 plzzz tell 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.



[algogeeks] eight queens on lisp

2012-06-28 Thread Victor Manuel Grijalva Altamirano
Hi i need your help, i need to programm the problem eight queens in LISP.
I´m learning LISP, but i´m new...
Anybody can help me?
I have the idea of backtracking,  but i don´t know how to code it in
LISP...

-- 
Victor Manuel Grijalva Altamirano
Universidad Tecnologica de La Mixteca

-- 
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 Question :implement read write lock class

2012-06-28 Thread bharat b
class lock
{
 enum{read, write,free}status;
};
By default, make status value as free.
Based on the request, status value will be changed...
Based on the value of the status, we should decide whether another
read/write lock can be given.

Any suggestions ?
On Thu, Jun 28, 2012 at 4:46 PM, Ashish Goel ashg...@gmail.com wrote:


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652

 --
 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.