Re: [algogeeks] Re: perfect square condition checking....

2013-01-07 Thread bala bharath
@Don, Can u explain with an Example...? With regards, Balasubramanian Naagarajan, Chettinad College of Engg Tech. On Sat, Jan 5, 2013 at 1:48 PM, Malathi malu@gmail.com wrote: Check this. It might help.

Re: [algogeeks] direct i online test

2012-08-24 Thread bala bharath
Can u please explain ur code..!!! -- 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

Re: [algogeeks] Re: candies - interviewstreet -- how to go about solving this problem

2012-07-10 Thread bala bharath
can u explain ur algorithm for the sequence * 5 4 3 2 1* -- 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

Re: [algogeeks] Re: determine if a string if of form pZq

2012-04-29 Thread bala bharath
why am i getting run time error.? problem=https://www.spoj.pl/problems/DCEPC206/ my code: #includestdio.h int main() { short t; long n,i,c,prev; long a; scanf(%d,t); while(t--) { c=0; scanf(%ld,n); scanf(%ld,prev); c=prev; for(i=1;in;i++) { scanf(%ld,a); if(a==prev);

Re: [algogeeks] how to solve

2012-04-09 Thread bharath kannan
I dont know if it can be solved in O(n). But O(nlogn) can be done using BIT. Refer topcoder tutorial for Binary indexed trees. On Mon, Apr 9, 2012 at 10:56 AM, tarun chabarwal admin20...@gmail.comwrote: how should i approach this problem https://www.spoj.pl/problems/DCEPC206/ can it be

Re: [algogeeks] google

2012-04-03 Thread bharath chowdary
sorry dude it came to ITBHU with tag of marketing so i could not be helpful to u in this case. On 4/1/12, Deepak Garg deepakgarg...@gmail.com wrote: hey guys! google is coming to our college, their main requirements is from operating systems and computer networks. can some one post the

[algogeeks] Cliched 'k' largest elements in billion numbers: Heaps or median-of-medians?

2011-12-11 Thread bharath sriram
Hey group, This is kind of a cliched question but given a file with billion numbers and the task is to compute 'k' largest numbers from this file, what approach is preferred? 1) Using heaps 2) Using Median-of-median algorithm. Have read few links which prefer heaps but clearly median of median

Re: [algogeeks] Re: Linear time Binary tree re-construction

2011-11-27 Thread bharath sriram
The in-order and pre-order traversal are already given. So, there is no way to do what you are saying if I understand you completely. On Sun, Nov 27, 2011 at 8:19 AM, Ankuj Gupta ankuj2...@gmail.com wrote: Hint : try with prestoring the preorder traversal element position in inorder traversal

Re: [algogeeks] Finding the repeated element

2011-11-26 Thread bharath sriram
*Assumptions*: - All positive elements in the array - All elements in array are in range 0 to (n-1) [ n - # of elements] 1) Scan the array. For every element A[i], negate the value stored in A[A[i]]. 2) If you encounter an element already negated, then that represents the duplicate element. On

[algogeeks] Problem

2011-10-31 Thread Bharath 2009503507 CSE
Given a set of values..in which there are some dependencies.. Eg.. x y z a b Dependencies: x,y a,z Note that dependency is not transitive..Is it possible to separate these elements into sets such that no two elements in the same set are dependant and we should end up with the least number of

Re: [algogeeks] Amazon - Coding Round-2 Qn

2011-09-04 Thread Bharath Sriram
Can anyone please explain the logic instead of the actual code? Sent from iPhone. On Aug 31, 2011, at 4:16 AM, aditya kumar aditya.kumar130...@gmail.com wrote: @rohit : else return (check(tree-left) || check(tree-right)); should be else return (check(tree-left) check(tree-right));

Re: [algogeeks]

2011-08-30 Thread bharath sriram
Sukran, There's a thread I started recently which asks about binary tree isomorphism. But to sum it all up here, isomorphism refers to same structure. Though isomorphism is used pretty flexibly w.r.t to binary trees, here's what I have read from different sources. - 2 binary trees are isomorphic

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

2011-08-29 Thread bharath sriram
not require any transformation themselves. See below link: http://www.cs.duke.edu/courses/spring00/cps100/assign/trees/ Bharath. On Aug 28, 11:53 pm, muthu raj muthura...@gmail.com wrote: In Amazon written test Isomorphic trees were defined as those in which a series

[algogeeks] Re: 100th Fibonacci number using LL

2011-07-31 Thread bharath
@Amit: Thanks for the solution but I have seen this approach. I was wondering how this can be solved using linked lists without using bignum libraries. Bharath On Jul 31, 12:38 pm, amit karmakar amit.codenam...@gmail.com wrote: Since long long cannot store the 100th Fibonacci number, you need

[algogeeks] Re: 100th Fibonacci number using LL

2011-07-31 Thread bharath
not come into picture when 2 big numbers are added, there is no problem. As an optimization, one can use linked lists for addition only when values get close to max integer value. Bharath. On Jul 31, 8:38 pm, saurabh singh saurab...@gmail.com wrote: By creating a bugnum library using link list

[algogeeks] Recursive version of reversing linked list

2011-07-30 Thread bharath sriram
Can anyone give the recursive version of reversing a linked list. Please post the reverse function code snippet and not the entire .c file since it just hampers readability. Bharath. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

[algogeeks] Word count using linked lists

2011-07-30 Thread bharath sriram
The subject has the problem description. What are some efficient ways of doing this. As always, the approach description is more useful than the actual code itself. Thanks! Bharath. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

[algogeeks] Re: how to calculate the complexity

2011-07-28 Thread bharath
Master's theorem is for recursive programs only. In general, there is no golden rule to calculate time complexity. Few pointers are to identify the key operations (eg - loops) and analyze the estimated running time based on a input size. On Jul 27, 2:46 pm, rajeev bharshetty rajeevr...@gmail.com

[algogeeks] Re: interview ques

2011-07-28 Thread bharath
records are stored in a single chunk, bringing the chunk into memeory is good enough. An additional storage structure will not be required. On Jul 28, 1:27 am, Puneet Gautam puneet.nsi...@gmail.com wrote: @bharath: To store the bunch of records together also, we gonna need another useful ds like

[algogeeks] Re: interview ques

2011-07-27 Thread bharath
A B+ tree would have one pointer for every data record at the leaf level. You could additionally group a bunch of data records together and have a single pointer from leaf to the data block. The trade-off is that you will have to fetch the data block and sequentially parse it to search for an

[algogeeks] Re: interview ques

2011-07-27 Thread bharath
@Dumanshu: A B+ tree is a multi-level index. It indexes the index until the final level is small enough to fit into a data block that can fit in memory. On Jul 27, 10:11 pm, Dumanshu duman...@gmail.com wrote: Use multilevel indexing On Jul 27, 11:07 pm, himanshu kansal

[algogeeks] Redundant parentheses

2011-07-26 Thread bharath
Given an expression (A+(B*C)), remove redundant parentheses. Output in this case should be A+B*C. My initial solution: (1) Convert expression from infix to postfix (or prefix) [This way, all parentheses are removed] (2) Now, convert postfix (or prefix) expression back to infix. Is there a better

[algogeeks] Re: Redundant parentheses

2011-07-26 Thread bharath
information lost. So, it will eventually again return back (A+(B*C)). So, my approach will not work. Any solutions then? On Jul 26, 3:26 pm, bharath bharath.sri...@gmail.com wrote: Given an expression (A+(B*C)), remove redundant parentheses. Output in this case should be A+B*C. My initial solution: (1

[algogeeks] Re: Redundant parentheses

2011-07-26 Thread bharath
Well, the answer should still be in infix except without 'redundant' parantheses. So, just converting it to prefix/postfix will not do. If we were to scan the array and remove parentheses, you might end up deleting relevant ones. Eg: ((A+B)*C) should output (A+B)*C. So, the key point here is

[algogeeks] Re: AMAZON Q

2011-07-26 Thread bharath
We can use count sort to solve this. Assuming each element is the array is in range 1-k (k=O(n)). for (i=0 to n) C[A[i]]=C[A[i]]+1 for (i=1 to k) C[i]=C[i]+C[i-1] Array 'C' will have the resultant array. On Jul 26, 9:20 pm, Rajeev Kumar rajeevprasa...@gmail.com wrote: * Algorithm :

[algogeeks] Re: AMAZON Q

2011-07-26 Thread bharath
Oops, my bad. I missed that lowest in a[i+1...n] part. On Jul 26, 10:17 pm, ankit sambyal ankitsamb...@gmail.com wrote: @bharath :I think array C is not the resultant array. Take an example and explain -- You received this message because you are subscribed to the Google Groups Algorithm

[algogeeks] Re: Lucky numbers

2011-07-26 Thread bharath
This is the extended Josephus problem. More details and solution formulation here: http://www.cs.man.ac.uk/~shamsbaa/Josephus.pdf On Jul 26, 11:04 pm, Nikhil Gupta nikhilgupta2...@gmail.com wrote: Please suggest a good algo for this : You have numbers 1 to n (consider them arranged in a

[algogeeks] Re: Redundant parentheses

2011-07-26 Thread bharath
I think I figured out a solution. Please correct me if I missed anything. *Example:* Input: ((A+B)*C) Expected output: (A+B)*C *Assumptions:* - Peek (queue) just tells the element in front end of queue without deleting it. - precedence( ) is a function which looks a precedence table of

Re: [algogeeks] Reverse a List with Recursion

2011-07-17 Thread bharath kannan
node * reverse(node *head) { if(head-next) { node * temp=reverse(head-next); head-next-next=head; head-next=NULL; return temp; } return head; } On Sun, Jul 17, 2011 at 4:57 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: *node *reverse(node

Re: [algogeeks] given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Bharath Soma
. 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 Bharath -- You received this message

Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Bharath Soma
. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- ...Thanks Bharath -- 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

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-26 Thread bharath kannan
whole expression is not correct... i guess it explains all.. :) On Sat, Mar 26, 2011 at 6:32 PM, sukhmeet singh sukhmeet2...@gmail.comwrote: Bharath can u tell me how u came with the combine function ??? I can't understand the logic behind it ... do reply On Wed, Mar 16, 2011 at 10:24 PM

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-23 Thread bharath kannan
i found this good.. http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=lowestCommonAncestor On Mon, Mar 21, 2011 at 6:02 PM, Anurag atri anu.anurag@gmail.comwrote: yes , please suggest a nice tutorial for segment trees .. On Mon, Mar 21, 2011 at 5:48 PM, cegprakash

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-23 Thread bharath kannan
but..i read this oly after my senior taught me segment trees.. On Wed, Mar 23, 2011 at 4:43 PM, bharath kannan bharathgo...@gmail.comwrote: i found this good.. http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=lowestCommonAncestor On Mon, Mar 21, 2011 at 6:02 PM, Anurag atri

Re: [algogeeks] SPOJ NUMGUESS

2011-03-23 Thread bharath kannan
I guess you solve it using binary search.. On Wed, Mar 23, 2011 at 6:48 PM, Vishnutej mylavarapu.vishnu...@gmail.comwrote: Hello everyone, Im unable to understand the NUMGUESS problem in SPOJ.Can some one explain what the problem is about? Thanks in advance. -Vishnutej.Mylavarapu --

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-20 Thread bharath kannan
, 2011 at 10:40 AM, bharath kannan bharathgo...@gmail.comwrote: i thot tat i had some mistake in my code and typed it all over again.. finally i noticed this :) On Sat, Mar 19, 2011 at 12:12 AM, Kunal Patil kp101...@gmail.com wrote: Hey.. I also got into same trouble today... I submitted

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-19 Thread bharath kannan
http://www.spoj.pl/forum/viewtopic.php?f=3t=5240p=20667hilit=BRCKTS#p20667 if u know d basics of segment tree..then this thread will help for solving this prob :) On Sun, Mar 20, 2011 at 2:11 AM, murthy.krishn...@gmail.com murthy.krishn...@gmail.com wrote: can any 1 explain why we have 2 use

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-19 Thread bharath kannan
i thot tat i had some mistake in my code and typed it all over again.. finally i noticed this :) On Sat, Mar 19, 2011 at 12:12 AM, Kunal Patil kp101...@gmail.com wrote: Hey.. I also got into same trouble today... I submitted it 6 times..then got bored and de moralised cause i cudnt find

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-17 Thread bharath kannan
sorry guyz... Had to print YES n NO.. i printed as Yes n No... Got ac.. Sorry for the trouble.. On Wed, Mar 16, 2011 at 10:24 PM, Bharath 2009503507 CSE bharathgo...@gmail.com wrote: i am new to segment trees..i tried this problem in spoj.. http://www.spoj.pl/problems/BRCKTS am getting WA

[algogeeks] SPOJ problem-BRCKTS

2011-03-16 Thread Bharath 2009503507 CSE
) printf(Yes\n); else printf(No\n); } else update(1,0,str.size()-1,k-1); } } } Thanks in advace.. Bharath.. -- You

Re: [algogeeks] please help..

2011-02-24 Thread bharath kannan
a small modification in normal knapsack algo ll do :) On Thu, Feb 24, 2011 at 4:06 PM, Akshata Sharma akshatasharm...@gmail.comwrote: http://www.spoj.pl/problems/PIGBANK/ can anyone give me an idea how to solve this problem...?? I dont think the knapsack algo would be of help here as here we

[algogeeks] SPOJ PROBLEM-pour1

2011-01-11 Thread Bharath 2009503507 CSE
i tried solving this prob... http://www.spoj.pl/problems/POUR1/ i tried using BFS...getting TLE in judge.. pl suggest some optimisation or better solution.. Thanks in advance.. Code: http://ideone.com/qIgcU -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] help

2010-12-16 Thread bharath kannan
machi use this.. Define *m*[*i*,*w*] to be the maximum value that can be attained with weight less than or equal to *w* using items up to *i*. We can define *m*[*i*,*w*] recursively as follows: - [image: m[0,\,w]=0] - [image: m[i,\,0]=0] - [image: m[i,\,w]=m[i-1,\,w]] if [image:

Re: [algogeeks] coins

2010-12-15 Thread bharath kannan
refer topcoder tutorials..dp On Wed, Dec 15, 2010 at 12:12 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: how do we find the complexity of DP program ? i know it cn be done using DP states , but the gien complexity is n^2 . i am not sure how to compare that On Tue, Dec 14, 2010 at

Re: [algogeeks] Re: FINDSR in spoj

2010-12-06 Thread bharath kannan
I tried solving that prob..here's my code #includeiostream #includestring using namespace std; main() { string s; cins; while(1) { if(s.size()==1 s[0]=='*') break; int length=1,curr=0,start=0,count=1; for(int i=1;is.size();i++) { if(s[i]!=s[curr]

[algogeeks] Spoj problem-pigbank

2010-12-05 Thread Bharath 2009503507 CSE
i am a beginner.pl help me with this code.i submitted a solution.it s giving op for all given testcases.but the judge is giving me a TLE. code: #includeiostream #includemap #define inf 9 using namespace std; mapint,int m2; int func(mapint,int m1,int w) { if(m2[w]inf) return m2[w];

Re: [algogeeks] missing 2 nums in an array

2010-10-11 Thread bharath kannan
sum of n elements from 1=n(n+1)/2 product from 1 to n=n! calculate dis.. sum=calculated sum-orig sum prod=calculated prod-orig prod with dis form quadratic eq and solve... hope this works... On Tue, Oct 12, 2010 at 12:29 AM, Asquare anshika.sp...@gmail.com wrote: Given an array of size n. It

Re: [algogeeks] Re: Anyone know optimized solution to bytelandian gold coins problem

2010-09-23 Thread Bharath
://groups.google.com/group/algogeeks?hl=en. -- Bharath -- 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

Re: [algogeeks] Re: point lies inside or outside of triangle..

2010-09-21 Thread Bharath
at http://groups.google.com/group/algogeeks?hl=en. -- Bharath -- 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

Re: [algogeeks] Point lies inside or outside of triangle?

2010-09-21 Thread Bharath
://groups.google.com/group/algogeeks?hl=en. -- Bharath -- 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

Re: [algogeeks] Amazon Interview

2010-09-15 Thread BHARATH NITHIN N
-- One can store the binary equivalent of the number of zeros in each line... and carry on from there -- 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

Re: [algogeeks] Re: Amazon Question

2010-09-13 Thread Bharath
. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Bharath -- 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

Re: [algogeeks] unique number in an array

2010-06-15 Thread Bharath
=en. -- Bharath -- 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

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

2010-06-05 Thread Bharath
...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Bharath -- 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

Re: [algogeeks] Re: another google telephone interview question

2010-05-21 Thread Bharath
. -- Bharath -- 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

Re: [algogeeks] Search in a sorted NxN matrix

2009-11-25 Thread Bharath
Bsearch on diagonal elimanates all the submatrix under 9. You are left with only one column and a row.Do BinarySearch on these lists. On Wed, Nov 25, 2009 at 6:07 PM, chitta koushik koushik.infin...@gmail.comwrote: @Bharath I dont think BinSrch on diagnol and then on row works. Can u

Re: [algogeeks] Finding first and last k digits of n^n

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

[algogeeks] Re: Matrix Toggling

2009-09-19 Thread Bharath
! and if you made it, the minimal number if moves is equal to MIN (X, 2*N - X) you can also use this method for an M*N matrix ! Hope it helps ^-^ On Sep 19, 3:02 pm, Bharath Kumar bharath1...@gmail.com wrote: Given two square matrices(initial and final) consisting of elements either 1

[algogeeks] Re: selection from infinite tape

2009-09-17 Thread Bharath Kumar
store k numbers from that tape as the tape is progressing, so that you can present them when prompted. -- Try the new Yahoo! India Homepage. Click herehttp://in.rd.yahoo.com/tagline_metro_1/*http://in.yahoo.com/trynew . -- Bharath

[algogeeks] Re: N number apples needs to distribute across M num baskets of varying capacity in balanced way

2009-09-09 Thread Bharath Kumar
13 apples? What is the best approach to solution which is near to optimal balance? I request you to provide the idea to resolve this problem. Thanks Regards, Sandeep -- Bharath --~--~-~--~~~---~--~~ You received this message because you are subscribed

[algogeeks] Re: DS question

2009-09-08 Thread Bharath
You can use a hash map. What do u mean by preserving order? Keep inserting the characters into hash, whenever u find a duplicate, delete it. The order is maintained still. Can you please elaborate on what is mean by preserving order? On Sep 8, 10:47 am, yash yashpal.j...@gmail.com wrote: wap a

[algogeeks] Re: linked list questions

2009-09-08 Thread Bharath Kumar
, ankur aggarwal ankur.mast@gmail.comwrote: @barath u r using extra space.. wat is new about this sol change to array.. then do as simple using a[i]==a[n-i] ??? On Tue, Sep 8, 2009 at 8:04 PM, Bharath bharath1...@gmail.com wrote: Q: Check whether given singly linked list

[algogeeks] Re: minimum difference.

2009-09-02 Thread Bharath
If the range of numbers is known, sort the array using radix sort and compare difference of adjacent elements. On Sep 2, 2:33 pm, Varun S V varun...@gmail.com wrote: Sorry this doesnt work. The difference between any other two sets can be lesser than the difference between two min numbers.