Re: [algogeeks] Recursive Function For insertion in BST

2011-01-15 Thread manoj lalavat
http://cslibrary.stanford.edu/110/


On Sat, Jan 15, 2011 at 6:36 PM, Logic King crazy.logic.k...@gmail.comwrote:

 hello all,
 i am a beginner to data structures.I have created a recursive function
 for insertion of a node in BST,but the function is not working
 properly.plz correct me,probably i am doing something wrong with
 the pointers
 help required :( .urgent !!
 the function is here---

void insert(struct node *head,int info)
{
struct node *temp=malloc(sizeof(struct node));
temp-data=info;
temp-rchild=NULL;
temp-lchild=NULL;
if(head==NULL)
head=temp;
else if(infohead-data)
{
insert(head-rchild,info);
}
else if(infohead-data)
{
insert(head-lchild,info);
}
}

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
--
Manoj Lalavat

-- 
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] No. of ways to Merge 2 arrays

2011-01-12 Thread manoj lalavat
one approch is very simple.


1. keep two index on arrays, lets say array1 and array2, which ever index
has small element put this element to   output array and move index of
smaller element to next position.

repeate above process untill one of the array index get exausted then append
remaining array to output.

corner cases when  one array is 1,2,3,4 and other is 5,6,7,8,...in this case
you just need to append them...take care of this...



On Wed, Jan 12, 2011 at 2:53 PM, Arindam Chatterjee 
arindam.chatterje...@gmail.com wrote:

 Can anyone help:

 *In how many ways can 2 sorted arrays of combined size N be merged?*

 --

 Thanks and regards,
 ARINDAM CHATTERJEE,
 Mtech Second Year,
 Department of Computer Science and Engineering,
 IIT Bombay,
 Powai,
 Mumbai-400076
 Contacts : +919022313724

 Living is about making tomorrow better than today !!

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




-- 
--
Manoj Lalavat

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Amazon Analytical Puzzle

2011-01-12 Thread manoj lalavat
check this...

Tournament Algorithm

Another method is tournament algorithm. The idea is to conduct a knockout
minimal round tournament to decide the ranks. It first organises the games
(comparisons) between adjacent pairs and moves the winners to next round
until championship (the first best) is decided. It also constructs the
tournament tree along the way. Now the second best element must be among the
direct losers to winner and these losers can be found out by walking in the
binary tree in O(log *n*) time. It organises another tournament to decide
the second best among these potential elements. The third best must be one
among the losers of the second best in either of the two tournament trees.
The approach continues until we find k elements. This algorithm takes O(n +
k log *n*) complexity, which for any fixed *k* independent of *n* is O(*n*).


On Wed, Jan 12, 2011 at 3:05 PM, bittu shashank7andr...@gmail.com wrote:

 if you had 5,623 participants in a tournament, how many games would
 need to be played to determine the winner

 Regards
 Shashank


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




-- 
--
Manoj Lalavat

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] No. of ways to Merge 2 arrays

2011-01-12 Thread manoj lalavat
merging is merging...you can use different methods to do this...

1. I have told you...

2. build BST and print inorder

3. find biggest element, create hash of that size, init table element to
zero (assume zero is not in input array)
 traverse each array and put that element into hash table

finally print hashtable for non-zero elements.

..I hope you get some idea...


On Wed, Jan 12, 2011 at 3:16 PM, Arindam Chatterjee 
arindam.chatterje...@gmail.com wrote:

 @Manoj: Thanks, but can u tell me the no. of ways in which merging can be
 done on 2 arrays.


 On Wed, Jan 12, 2011 at 3:06 PM, manoj lalavat manoj.lala...@gmail.comwrote:

 one approch is very simple.


 1. keep two index on arrays, lets say array1 and array2, which ever index
 has small element put this element to   output array and move index of
 smaller element to next position.

 repeate above process untill one of the array index get exausted then
 append remaining array to output.

 corner cases when  one array is 1,2,3,4 and other is 5,6,7,8,...in this
 case you just need to append them...take care of this...



 On Wed, Jan 12, 2011 at 2:53 PM, Arindam Chatterjee 
 arindam.chatterje...@gmail.com wrote:

 Can anyone help:

 *In how many ways can 2 sorted arrays of combined size N be merged?*

 --

 Thanks and regards,
 ARINDAM CHATTERJEE,
 Mtech Second Year,
 Department of Computer Science and Engineering,
 IIT Bombay,
 Powai,
 Mumbai-400076
 Contacts : +919022313724

 Living is about making tomorrow better than today !!

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




 --
 --
 Manoj Lalavat

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




 --

 Thanks and regards,
 ARINDAM CHATTERJEE,
 Mtech Second Year,
 Department of Computer Science and Engineering,
 IIT Bombay,
 Powai,
 Mumbai-400076
 Contacts : +919022313724

 Living is about making tomorrow better than today !!

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




-- 
--
Manoj Lalavat

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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: No. of ways to Merge 2 arrays

2011-01-12 Thread manoj lalavat
what?

On Wed, Jan 12, 2011 at 3:38 PM, juver++ avpostni...@gmail.com wrote:

 Explain problem using examples. When two merging are different?

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




-- 
--
Manoj Lalavat

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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 IDC

2011-01-12 Thread manoj lalavat
worst case...but in avrg cases its better and dont use sorting...

On Wed, Jan 12, 2011 at 3:41 PM, juver++ avpostni...@gmail.com wrote:

 it is better then pute brute force, but it is O(N^2)

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




-- 
--
Manoj Lalavat

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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 Analytical Puzzle

2011-01-12 Thread manoj lalavat
yes...but if you want to find second best and third best and so on...then
you need to consider all loser to first winner and so onthink on this
line..

On Wed, Jan 12, 2011 at 3:14 PM, bittu shashank7andr...@gmail.com wrote:

 @manoj..can u elaborate by making what exactly u mean...???

 According to me if Tournament strategy is is used  then i think its
 ok...


 After each round, you would have half the number that started the
 previous round; except if it were an odd number it would he half + 1.
 So 13 rounds.

 2812 1
 1406 2
 703 3
 352 4
 176 5
 88 6
 44 7
 22 8
 11 9
 6 10
 3 11
 2 12
 1 13


 Regrads
 Shashank Don't b  Evil U Can Earn while U Learn

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




-- 
--
Manoj Lalavat

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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 IDC

2011-01-12 Thread manoj lalavat
hahahahgood...givesome thing better without sorting...

On Wed, Jan 12, 2011 at 3:48 PM, juver++ avpostni...@gmail.com wrote:

 In average it is O(N^2) anyway but with a bit smaller constant.

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




-- 
--
Manoj Lalavat

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Interview Question

2011-01-11 Thread manoj lalavat
you can optimize BF

newspaper

first word you will search

n

then

ne

then

new

then news..and so onif at any point of time first word exist in
dictionary then only see whether the word with the remaining characters
exist in the dictionary or not.


On Tue, Jan 11, 2011 at 5:57 PM, Vikas Singh vikas.sing...@gmail.comwrote:

 Given a dictionary find out if given word can be made by two words in
 dictionary. For eg. given newspaper you have to find if it can be made by
 two words. (news and paper in this case). I cant think of anything but brute
 force.

 Thanks,
 Vikas

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




-- 
--
Manoj Lalavat

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Interview Question

2011-01-11 Thread manoj lalavat
how abt this..

Pass1 = look whether words like n,ne,new,news.exist or not...store
information in some array like n is not found so is ne but new is found and
news is found so array will be like

0,0,1,1.

Pass2 = do d same from from the end...

r,er,per,aper,paper

0,0,1,0,1

Pass3 on first array

whenever you find 1see index [len(newspaper) - (index of one in first
array)] in second array...if its one we have words n so on



On Tue, Jan 11, 2011 at 6:58 PM, Vikas Singh vikas.sing...@gmail.comwrote:

 Wouldn't that be O(n2) . what if n, ne, new, news, newsp etc all are valid
 words ? Cant it be optimized?

 On Tue, Jan 11, 2011 at 6:27 PM, juver++ avpostni...@gmail.com wrote:

 Use trie (or similar DS).
 For each word, try to find second part of the target in a linear time
 O(length).

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
--
Manoj Lalavat

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Interview Question

2011-01-11 Thread manoj lalavat
words and...so on...

on dictionaries lookup is O(1) now think abt complexity...

pass1
for (1 to N)  example here N=strlen(newspaper)

other passes are also same...


On Tue, Jan 11, 2011 at 8:07 PM, juver++ avpostni...@gmail.com wrote:

 What do you mean by N?
 If N - size of the dictionary. And L- maximum length of the words then
 above algo is O(N*L)

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




-- 
--
Manoj Lalavat

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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 interview question

2010-12-10 Thread manoj lalavat
it will give you an idea.

http://en.wikipedia.org/wiki/Full_text_search

On Fri, Dec 10, 2010 at 4:03 PM, ADITYA KUMAR aditya...@gmail.com wrote:

 @ankit
 u can'nt use TRIE
 becoz , input will be given in form of text
 so generating the TRIE will be much expensive than linear search

 On Fri, Dec 10, 2010 at 3:13 PM, GOBIND KUMAR gobind@gmail.comwrote:

 Help me in solving this problem...   Define a data struct for the search 
 engine which will represent whether

 given word is there in the document or not .It  should be fast.

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




 --
 Regards
 Aditya Kumar
 B-tech 3rd year
 Computer Science  Engg.
 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 algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
--
Manoj Lalavat

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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:

2009-06-02 Thread manoj lalavat
On Tue, Jun 2, 2009 at 3:00 PM, Aminooo~ amin...@gmail.com wrote:

 *Dear Friends,*

 * *

 *A question for the genius, the one who solve the problem will write the
 name in the attached file.*

 *IF; 2+3=10*
 * 7+2=63*
 * 6+5=66*
 * 8+4=96*
 *THEN;*

 *  9+7=???*


 *The answer is the password to open the file attached*

 * *

 * *

 *Best Regards*

 *Aminooo.com* http://www.aminooo.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
-~--~~~~--~~--~--~---



successor.xlsx
Description: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet