Re: [algogeeks] Maximize the Time to see TV

2011-01-31 Thread Divya Jain
@ above ur code fails for following example channel 1 : prog1 8:00-9:00, prog 2 9:00-10:00 channel 2 : prog1 8:15-10:00 your code returns 8:15- 10 and the answer should be channel1/prog1 + channel1/prog2 On 21 January 2011 12:54, Anand anandut2...@gmail.com wrote: Sort all program with

Re: [algogeeks] Adobe Question

2011-01-21 Thread Divya Jain
if sorted then a tweak in merge sort will work On 20 January 2011 23:23, nishaanth nishaant...@gmail.com wrote: Ya as Ashish said hashing is the best solution :) On Fri, Jan 14, 2011 at 6:00 PM, Ashish Goel ashg...@gmail.com wrote: ideally, a hashMap would be preferred walk through one

Re: [algogeeks] merging 2 search trees

2011-01-21 Thread Divya Jain
@ above height will not be balanced then On 21 January 2011 19:15, nishaanth nishaant...@gmail.com wrote: Find the node in T which is the maximum(which is either the root or the rightmost in the right subtree). After finding this node, just make the right child of this node point to the root

Re: [algogeeks] Adobe Question

2011-01-21 Thread Divya Jain
if both arrray are sorted. take two ptrs, one pointing to a[0] other to b[0]. if elements are same then nt disjoint. else increment ptr pointing to smaller element until it becomes equal or greater than the element pointed by other. repeat until either ptr reaches end of array.. On 21 January

Re: [algogeeks] Re: difference x

2010-12-22 Thread Divya Jain
@ saurabh and i wanna ur solution to this prob i know O(nlogn) post ur O(n) solution,. i hv some idea bt i wanna knw ur ans b4 mine On 22 December 2010 22:32, Divya Jain sweetdivya@gmail.com wrote: its okk On 22 December 2010 22:28, Ankur Khurana ankur.kkhur...@gmail.com wrote

Re: [algogeeks] Re: difference x

2010-12-22 Thread Divya Jain
its okk On 22 December 2010 22:28, Ankur Khurana ankur.kkhur...@gmail.com wrote: saurabh , asking for a better sol. is not a crime. rest everybody is intelligent. On Wed, Dec 22, 2010 at 10:27 PM, Saurabh Koar saurabhkoar...@gmail.com wrote: @Snehal: I hv no problem wid ur doubts.Bt

Re: [algogeeks] linkd list

2010-12-15 Thread Divya Jain
no not sorted On 15 December 2010 11:37, Anand anandut2...@gmail.com wrote: @Divya, I think you ask this question before. Not sure of the answer though :) On Tue, Dec 14, 2010 at 9:06 PM, Soumya Prasad Ukil ukil.sou...@gmail.com wrote: Are the linked list sorted? On 14 December 2010

Re: [algogeeks] Re: how many bananas?

2010-12-14 Thread Divya Jain
nice solution:) On 14 December 2010 20:54, Prims topcode...@gmail.com wrote: total bananas=3000 ...max capacity=1000 ==3 trips needed to transport all for traveling 1 km 1st trip 998[eats 1 banana while coming and 1 banana while going back] 2nd trip 998 3rd trip 999[no need to go back]

Re: [algogeeks] Re: sorted array

2010-10-13 Thread Divya Jain
@above can u plz explain hw did u apply this formula? On 13 October 2010 16:14, Shiyam code_for_life mailshyamh...@gmail.comwrote: Lets say 8 integers are 1 to 8 So first way array can be split is 1,7 1st array can have one among 8 integers so in 8 ways and 2nd array has just one

Re: [algogeeks] Re: sorted array

2010-10-13 Thread Divya Jain
ignore the above post of mine @ shiyam u r doing wrong. we hv been the size of both array b and c which is 5 n 3 respectively @ AlgoSAu can u please explain ur method? On 13 October 2010 17:23, Divya Jain sweetdivya@gmail.com wrote: @above can u plz explain hw did u apply this formula

Re: [algogeeks] Maximum size binary search tree

2010-08-11 Thread Divya Jain
@ above ur soln ll fail in situation like 10 / \ 15 18 /\ / \ 22 7 17 77 the inorder is 22 15 7 10 17 18 77 so the longest increasing sequence is 7-77 but this

Re: [algogeeks] Array with 0 and 1

2010-07-05 Thread divya jain
i think u need to visit every element atleast once to see if its 1 or 0, nd so update the count. so i dont think it will be possible in less than O(n2) On 5 July 2010 15:41, amit amitjaspal...@gmail.com wrote: For a given matrix NxN having 0 or 1’s only. You have to find the count of rows

Re: [algogeeks] Re: isbst

2010-07-01 Thread divya jain
@ above here u r comparing node value with min and max only for eg if ur tree is 45 / \ 65 85 / 25 ur code will say that this is bst.

Re: [algogeeks] c

2010-06-26 Thread divya jain
ya it is giving error cz u r incrementing x. u cant increment x as it is const. but there is no prob with declaration. its valid. On 26 June 2010 11:09, sharad kumar aryansmit3...@gmail.com wrote: pls c thz On Sat, Jun 26, 2010 at 10:48 AM, sharad kumar aryansmit3...@gmail.comwrote: cos if

Re: [algogeeks] Re: There is an array of odd and even numbers. Now, sort them in such a way that the top portion of the array contains odd numbers, bottom portion contains even numbers

2010-06-25 Thread divya jain
@ gurav vivek i think u r only exchanging odd and even.. only putting even to end and odd in front and not doing descending sorting on odds and ascending on even.. plz correct me if i hv missed something.. On 24 June 2010 22:49, Vivek Sundararajan s.vivek.ra...@gmail.com wrote: Hi, how about

Re: [algogeeks] sum k in sub array

2010-06-24 Thread divya jain
@amir ur algo works only for positive elements array.. correct me if m wrong On 23 June 2010 00:28, Amir hossein Shahriari amir.hossein.shahri...@gmail.com wrote: for each element find sum[i] which is the summation of all elements with index less than or equal to i ( note that this array is

Re: [algogeeks] linked list

2010-06-23 Thread divya jain
if we dont want to change original list.. is there ny efficient method for that? On 23 June 2010 06:49, ANUJ KUMAR kumar.anuj...@gmail.com wrote: reverse one of the linked lists in O(n) time and then see if the resulting one is same as the other one On Wed, Jun 23, 2010 at 1:56 AM, divya

Re: [algogeeks] Re: no of bits

2010-06-22 Thread divya jain
@ dave how did u come to this formula... m nt getting the logic.. @ sathaiah yes u r rite On 22 June 2010 19:32, chitta koushik koushik.infin...@gmail.com wrote: For more such problems and solns

Re: [algogeeks] queue

2010-06-20 Thread divya jain
there is a linked list where each node of linked list points to queue.. for eg. 1st node points to queue 1 2nd to queue 2 nd so on.. hope m clear this time.. On 20 June 2010 18:30, Piyush Verma 114piy...@gmail.com wrote: @divya plzz explain little more. m not getting... -- You received this

Re: [algogeeks] doubly linked list

2010-06-16 Thread divya jain
u can xor linked list. such that every node link contains the xor of its prev nd next node address.. since for 1st node prev is null ( 0) so its link contains only next. now to calculate next of 2nd node xor its link with 1st node's link nd u ll get 3 rd node.s adddress nd so on.. u can also use

Re: [algogeeks] sum to 0

2010-06-16 Thread divya jain
sort array c only. now select every pair from array a nd b ( o(n2)) for every pair find the element from c which gives sum of the three element 0. ( search using binary search as c is sorted) so the algo is O (n^2 logn)) On 16 June 2010 13:47, Amir hossein Shahriari

Re: [algogeeks] doubly linked list

2010-06-16 Thread divya jain
? will i be able to traverse in any direction now? please let me know if im missing something :) Thank you, Vivek On 16 June 2010 15:37, divya jain sweetdivya@gmail.com wrote: u can xor linked list. such that every node link contains the xor of its prev nd next node address.. since

Re: [algogeeks] Mirroring Binary Tree Pattern Problem

2010-06-15 Thread divya jain
This C code will create a new mirror copy tree. mynode *copy(mynode *root) { mynode *temp; if(root==NULL)return(NULL); temp = (mynode *) malloc(sizeof(mynode)); temp-value = root-value; temp-left = copy(root-right); temp-right = copy(root-left); return(temp); } On 13 June 2010 17:07, BALARUKESH

Re: [algogeeks] trees

2010-06-15 Thread divya jain
reverse in order traversal till u reach kth node. reverse inorder means first visit right child then print data nd then left. On 14 June 2010 08:34, Lekha lek...@gmail.com wrote: Inorder traversal till u reach the kth element(If it is sorted in descending order, otherwise go till (n-k)th

Re: [algogeeks] Re: file handing

2010-06-15 Thread divya jain
() incorrectly in http://www.drpaulcarter.com/cs/common-c-errors.php On Jun 13, 8:36 pm, divya jain sweetdivya@gmail.com wrote: sorry i pasted wrong questn unser 2.. the real question is which file will get closed through fclose() #includestdio.h int main() { FILE *fp,*fs,*ft

Re: [algogeeks] Re: Array Problem

2010-06-15 Thread divya jain
]; } if(max_diff 0) max_diff = 0; return max_diff; } . Satya On Sat, Jun 12, 2010 at 3:18 PM, divya jain sweetdivya@gmail.comwrote: i think we need to maintain an array of index as well such that while subtracting smallest element from largest element of sorted

Re: [algogeeks] c- pointers

2010-06-13 Thread divya jain
Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Sun, Jun 13, 2010 at 11:07 AM, divya jain sweetdivya@gmail.comwrote: ptr is a pointer naaa...then why ptr-p=*((arr+1)-arr

Re: [algogeeks] c array

2010-06-13 Thread divya jain
i use tc On 13 June 2010 13:11, ram karthik.gin...@gmail.com wrote: @rohit bro http://www.mingw.org/ *MinGW*, a contraction of Minimalist GNU for Windows, is a port of the GNU Compiler Collection (GCC), and GNU Binutils, for use in the development of native Microsoft Windows applications.

Re: [algogeeks] union- c

2010-06-13 Thread divya jain
its an o/p questn.. conversion wen ur variable is long..nd u r printing using %f...i dont know how to perform conversion from float to int long nd vice versa.. pl help On 13 June 2010 12:12, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: what is this for... and which conversion are you

Re: [algogeeks] c- pointers

2010-06-13 Thread divya jain
of the variable type its point two... for example.. if you do .. p+1... where let say p is 200 and points to an int type variable then p+1 is 202...(assuming int is of size 2) so (p+1)-p..i.e 202-200 is 1 and not 2 On Sun, Jun 13, 2010 at 1:46 PM, divya jain sweetdivya@gmail.comwrote

Re: [algogeeks] union- c

2010-06-13 Thread divya jain
, divya jain sweetdivya@gmail.comwrote: its an o/p questn.. conversion wen ur variable is long..nd u r printing using %f...i dont know how to perform conversion from float to int long nd vice versa.. pl help On 13 June 2010 12:12, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: what

Re: [algogeeks] Re: bits

2010-06-13 Thread divya jain
thanks to all :) @ souravsain sorry for the inconvenience On 13 June 2010 20:01, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @Souravsain : Is there any serious problem in this. Anyone can just add a [C++] in the subject and uninterested people can make filters in gmail :)

Re: [algogeeks] file handing

2010-06-13 Thread divya jain
sorry i pasted wrong questn unser 2.. the real question is which file will get closed through fclose() #includestdio.h int main() { FILE *fp,*fs,*ft; fp=fopen(a.c,r); fs=fopen(b.c,r); ft=fopen(c.c,r); fclose(fp,fs,ft); return 0; } 3. yes it is feof..srry typed it wrong... nd fgets(str,80,fp) is

Re: [algogeeks] Re: Array Problem

2010-06-12 Thread divya jain
i think we need to maintain an array of index as well such that while subtracting smallest element from largest element of sorted array we need to check if index of largest is greater than index of smallest. if no..then this is not the solution.. On 12 June 2010 14:20, Modeling Expert

Re: [algogeeks] Re: identify the recurring part for a given decimal no

2010-06-12 Thread divya jain
= 210.11071104 decimal part zero? No. Now multiply the no. with 100. Which no? original x (= 23.34563456) or new no. temp (=210.11071104)? On Jun 9, 8:12 pm, divya jain sweetdivya@gmail.com wrote: multiply the no. with 10 nd store in temp. now subtract no from temp. check

Re: [algogeeks] Re: c output

2010-06-12 Thread divya jain
one of my frnd askd me this question... On 11 June 2010 21:34, Raj N rajn...@gmail.com wrote: @kirubakaran: How can it be 1,1 ? No of characters read in a is 5+ 1 for '\n' so its 6 and for the next one 1+1=2 On Fri, Jun 11, 2010 at 9:09 AM, kirubakaran kirubakaran1...@gmail.comwrote:

Re: [algogeeks] output

2010-06-12 Thread divya jain
sorry for the silly question i got rhe point.. @ rohit compiler is doing rite..read mahesh's explanatn On 13 June 2010 08:27, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: This is very bad. Change your compiler if it compiles this stuff :) btw.. which compiler is it? Output for me :

Re: [algogeeks] c array

2010-06-12 Thread divya jain
hmm..the prob is here wid my compiler...!! anyways thanks to all On 13 June 2010 10:28, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: oh.. yes.. my mistake (strings\0).length=8 :P -- Rohit Saraf Second Year Undergraduate, Dept. of Computer

Re: [algogeeks] c- pointers

2010-06-12 Thread divya jain
ptr is a pointer naaa...then why ptr-p=*((arr+1)-arr) ??? why not (arr+1)-arr ?? i knw m wrong somewhr...plz correct me On 13 June 2010 07:57, Mahesh_JNU mahesh.jnumc...@gmail.com wrote: agreed . On Sun, Jun 13, 2010 at 7:48 AM, sharad kumar aryansmit3...@gmail.comwrote: 111 222

Re: [algogeeks] Re: identify the recurring part for a given decimal no

2010-06-12 Thread divya jain
14 60 56 repeats hope its clear Anurag Sharma On Sat, Jun 12, 2010 at 4:02 PM, divya jain sweetdivya@gmail.comwrote: @anurag i dint get ur approach..which

Re: [algogeeks] Re: isomorphic trees

2010-06-10 Thread divya jain
is-isomorphic(t1ld, t2rd) return is-isomorphic(t1rd, t2ld) return false; } On Wed, Jun 9, 2010 at 8:29 PM, divya jain sweetdivya@gmail.com wrote: @vadivel and anand { 1,2,3 } is *isomorphic* to { 1,3,2 } { 1,2,3,4,5,6,7 } is *isomorphic* to { 1,3,2,7,6,4,5

Re: [algogeeks] identify the recurring part for a given decimal no

2010-06-09 Thread divya jain
multiply the no. with 10 nd store in temp. now subtract no from temp. check if the decimal part is zero if yes. then 1st digit after decimal is recurring. if no. multiply the no with 100 and repeat . if this time decimal part is zero then 2 digits after decimal r recurring nd so on.. On 8 June

Re: [algogeeks] isomorphic trees

2010-06-09 Thread divya jain
@vadivel and anand { 1,2,3 } is *isomorphic* to { 1,3,2 } { 1,2,3,4,5,6,7 } is *isomorphic* to { 1,3,2,7,6,4,5 } { 1,2,3,4,5,6,7 } is NOT *isomorphic* to { 1,3,2,4,5,6,7 } so its nt necessary that right and left will interchange. it may or may not. if all right and left are interchanged then it

Re: [algogeeks] min no of policemen

2010-06-08 Thread divya jain
@sharad.. sorry bt i dint get how to use bellman ford or topological sort here... can u plz explain... On 8 June 2010 05:53, sharad kumar aryansmit3...@gmail.com wrote: for placing police man we can use bellman ford bfs.or even make use of topological sort. On Mon, Jun 7, 2010 at 9:59 PM,

Re: [algogeeks] Puzzle:

2010-06-08 Thread divya jain
yes even i dont think its possible as there is no n-1th state..ie there is no state from whr u can come to 2 8 5..so plz check On 7 June 2010 20:23, mohit ranjan shoonya.mo...@gmail.com wrote: is it possible ? if we say nth state is [2, 8, 5] I could not find possible (n-1)th state Mohit

Re: [algogeeks] Pointer to a constant

2010-06-08 Thread divya jain
i think both statements shd give error. as u r trying to change int to const int in 2 and const int to int in 1.. On 7 June 2010 19:59, mohit ranjan shoonya.mo...@gmail.com wrote: @Raj, no they are not same case 1: i is const case 2: ptr is const and whatever is const cann't be modified

Re: [algogeeks] Number of sequences of n binary digits that don't contain two 1's in a row

2010-06-08 Thread divya jain
how do u come to this formula T(n)=fib(n+2).. plz explain On 7 June 2010 21:19, saurabh gupta sgup...@gmail.com wrote: it might be referring to no of sequences (say T(n) ) with no consecutive 1's for n = 3, ans would be 5 viz. 000, 001, 010, 100, 101 T(n) = fib(n+2) where fib = Fibonacci

Re: [algogeeks] Single ordered list

2010-06-08 Thread divya jain
merging as in merge sort. On 8 June 2010 19:59, Raj N rajn...@gmail.com wrote: What is the most efficient way of combining 2 separate ordered list into a single ordered list ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] min no of policemen

2010-06-08 Thread divya jain
edge is the link connecting two nodes of a tree On 8 June 2010 11:23, Anurag Sharma anuragvic...@gmail.com wrote: Can you expain edge of the tree. I could not get that. Anurag Sharma On Tue, Jun 8, 2010 at 5:53 AM, sharad kumar aryansmit3...@gmail.comwrote: for placing police man we

Re: [algogeeks] matix flipping

2010-06-07 Thread divya jain
let a[n][n] be the input array nd b[][] be the output for(i=0;in;i++) for(j=0;jn;j++) b[i][j]=a[n-j-1][n-i-1] On 7 June 2010 08:26, sharad sharad20073...@gmail.com wrote: write a c routine to flip an nXn matrix about its non major diagnol 3 4 5 6 7 9

Re: [algogeeks] array question

2010-06-06 Thread divya jain
@sharad while storing each element in hash by your approach u ll check if its already there in hash. so the complexity here will be O(n2). correct me if i m wrong. isnt there ny better algo..? On 6 June 2010 06:28, sharad kumar aryansmit3...@gmail.com wrote: @dhivya:keep storing the first

Re: [algogeeks] Re: array question

2010-06-06 Thread divya jain
output willl be 12 12 5 6 6 On 6 June 2010 18:27, souravsain souravs...@gmail.com wrote: @divya: Does your problem require the output to be sorted also? What will be the output required if inout is 12,5,6,12,6? Will it be 12,12,6,6,5 or 12,12,5,6,6,? Sain On Jun 6, 12:01 am, divya

Re: [algogeeks] o/p

2010-06-05 Thread divya jain
output on my compiler is 165535 as i=0 initialy ++i is true and so for loop condition is true and printf is executed. when i becomes 65535 then ++i is equal to 0 and so for loop condition becomes false. On 5 June 2010 13:44, sharad sharad20073...@gmail.com wrote: #includestdio.h int main()

Re: [algogeeks] Largest even length palindrome in a string!!

2010-06-05 Thread divya jain
1. first find two consecutive letters which are same. 2 point ptr1 to left character and ptr2 to right one 3. now increment ptr2 and decrement ptr1. compare if they are pointing to same characters. if yes repeat this step 4. if no then store in length ptr2-ptr1-2 5. go to step 1 untill all

[algogeeks] dynamic vs greedy aproach

2010-06-05 Thread divya jain
how can we make out whether to apply greedy approach or dynamic programming to a problem?? -- 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

Re: [algogeeks] o/p

2010-06-05 Thread divya jain
turbo c++ and my o/p is logical as well On 5 June 2010 17:58, sharad kumar sharad20073...@gmail.com wrote: @divya,which compiler u r using,i m getting this o/p on gcc compiler @mohit:loop stops at 4,294,967,295 in gcc -- You received this message because you are subscribed to the Google

Re: [algogeeks] Quick short stack space reduction

2010-06-04 Thread divya jain
if u sort the larger one first one then smaller one will be on stack for a long time on the other hand if u sort smaller one first then larger one will be in stack for long time. so more space is wasted is 2nd case so we shd sort larger first. correct me if i am wrong plzzz On 4 June 2010 18:08,

Re: [algogeeks] Check if 2 linked lists are identical

2010-06-03 Thread divya jain
construct bst from both list and check if the bst are equal by printing their inorder traversal. On 2 June 2010 22:47, Raj N rajn...@gmail.com wrote: @Antony: The 2 lists should have the same elements as well the number must be equal On Wed, Jun 2, 2010 at 5:38 PM, Antony Vincent Pandian.S.

Re: [algogeeks] Implementing 2 stacks within a single linear array

2010-06-03 Thread divya jain
for three stacks u can use indices 0 3 6 etc for stack1. 1 4 7 for stack 2 and 2 5 8 etc for stack 3. now if any of the stack overflows but there is still space in array as other stacks have few element then now u can grow ur stack in reverse direction as shown below : indices of array : 0

Re: [algogeeks] Re: partion of array

2010-06-03 Thread divya jain
u have not sorted the array . first sort the array nd then apply the approach. u ll get the ryt ans On 1 June 2010 21:32, Jitendra Kushwaha jitendra.th...@gmail.com wrote: Using subset sum method we can solve this. It actually DP check out Paybill question and its solution on topcoder website

Re: [algogeeks] Re: Can you solve this?

2010-06-03 Thread divya jain
same question as wat i asked in partioning of array such that the diff is min. On 31 May 2010 22:07, Senthilnathan Maadasamy senthilnathan.maadas...@gmail.com wrote: Same question with interesting answers in stackoverflow :

Re: [algogeeks] Removing extra parentheses in an infix string

2010-06-03 Thread divya jain
1.calculte the postfix of given expression. 2.now remove a particular parenthesis from expression and check if the postfix of this expression is equal to the postfix of original expression. if yes then the parenthesis we have removed were extra. if no then the parenthesis were not exta. 3 now

Re: [algogeeks] Re: partion of array

2010-06-03 Thread divya jain
oh...okay... good example... On 3 June 2010 13:23, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @divya: but still haven't you seen Jagadish's example? It is a counterexample to your greedy approach. -- Rohit Saraf Second Year

Re: [algogeeks] Re: partion of array

2010-05-17 Thread divya jain
to array which is 1. so the ans is A={2000,1} b={500,200} On 15 May 2010 19:10, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: so what will ur algo give for array 1,200,500,2000 On 5/15/10, divya jain sweetdivya@gmail.com wrote: my approach: 1. sort the array 2. take a variable diff

Re: [algogeeks] Re: string question

2010-05-17 Thread divya jain
the output shd be epo.. hint to the problem : PROBLEM DO NOT READ IF U WANT TO SOLVE THE URSELF it involves the concept of finding window u hv to 1st search for the window which contains all characters of string. then u have to alter window so as to get minmum length window.. On 17 May 2010

Re: [algogeeks] string question

2010-05-16 Thread divya jain
output ll be : e's On 16 May 2010 20:17, sharad kumar aryansmit3...@gmail.com wrote: suppose if i give Ssmall:es Sbig:he's a algogeek and he's rocking wat will be o/p? On Sun, May 16, 2010 at 8:12 PM, divya sweetdivya@gmail.com wrote: You r given a large string of characters

Re: [algogeeks] Re: question

2010-05-15 Thread divya jain
Very simple N^2*logN solution: sort the input array, then go through all pairs Ai, Aj (N^2 time), and for each pair check whether (S - Ai - Aj) is in array (logN time). On 12 May 2010 23:08, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote: @sateesh suppose after sorting the array is

Re: [algogeeks] Re: partion of array

2010-05-15 Thread divya jain
my approach: 1. sort the array 2. take a variable diff. intitialize it to 0. 3. take the 1st element from array nd place it in array A and 2nd element in array B. stoe in diff sum(A)-sum(B). 4. now place the next element in array A or B according to the condition if if sum(A+element)-sum(B)

Re: [algogeeks] frequency

2010-05-14 Thread divya jain
use binary tree and insert in it every character u come across. if the character is already present then increment its count. use this approach if u r nt sure that characters will be only 26 or no. if u r sure there r 26 char then u cn use hash.. plz correct me if i m wrong. thanks On 14 May 2010

Re: [algogeeks] compute kth smallest element from union of two lists

2010-05-14 Thread divya jain
sorry bt i dint get the approach. can u please explain a bit more by taking examples...thanks a lot in advance On 14 May 2010 10:12, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: This was also asked in my Yahoo! Interview this year. :) --

Re: [algogeeks] BST

2010-05-14 Thread divya jain
form a sorted array from inorder traversal of tree. now take to pointers one to the beginning of array and other at the end. now check if the sum of element is greater than reqd sum then increment 1st ptr. if their sum is less than reqd sum then decrement 2nd ptr. if their sum is equal to the

Re: [algogeeks] tree from linked list

2010-05-13 Thread divya jain
the best approach to it is to build a balanced tree from bottom to up rather than top to bottom. On 12 May 2010 22:47, divya jain sweetdivya@gmail.com wrote: thanks a lot to all for their replies.. On 9 May 2010 11:23, rahul rai raikra...@gmail.com wrote: can anyone give me links

Re: [algogeeks] tree from linked list

2010-05-12 Thread divya jain
thanks a lot to all for their replies.. On 9 May 2010 11:23, rahul rai raikra...@gmail.com wrote: can anyone give me links to more educative and active groups like algogeeks On Sun, May 9, 2010 at 2:11 AM, Arun prasath aruntendulkar2...@gmail.com wrote: This does not create a balanced tree

Re: [algogeeks] 400!

2010-05-12 Thread divya jain
.. On 5/2/10, divya jain sweetdivya@gmail.com wrote: wat is tail recursion plz explan in detail On 2 May 2010 08:15, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @divya use tail recursion and rest should be fine.. -- -- Rohit Saraf

Re: [algogeeks] 400!

2010-05-03 Thread divya jain
on mobile... cannot explain now.. On 5/2/10, divya jain sweetdivya@gmail.com wrote: wat is tail recursion plz explan in detail On 2 May 2010 08:15, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @divya use tail recursion and rest should be fine

Re: [algogeeks] Re: a google question

2010-05-03 Thread divya jain
@satish ur solution is of o(nlogn) complexty @ jitendra suppose p11 and p21 r pointing at index 0 and p12 at 4 and p22 at 1. now suppose at ths point d s greater than b and c. now u increment p11 and p21. but it can be a case that a[0] + b[2] is next greatest value bt t wont work for ur algo.

Re: [algogeeks] 400!

2010-05-02 Thread divya jain
wat is tail recursion plz explan in detail On 2 May 2010 08:15, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @divya use tail recursion and rest should be fine.. -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and

Re: [algogeeks] a google question

2010-05-02 Thread divya jain
the interviewer explicitly asked for an O(n) time algorithm? On Sun, May 2, 2010 at 1:48 PM, vignesh radhakrishnan rvignesh1...@gmail.com wrote: @divya You're rite. Post a solution if you have one. -- Regards, Vignesh On 2 May 2010 13:14, divya jain sweetdivya@gmail.com wrote