Re: [algogeeks] Re: Finding closest double in a Btree

2012-02-21 Thread atul anand
ignore my post...its working fine , there are no bugs On Tue, Feb 21, 2012 at 11:34 AM, atul anand atul.87fri...@gmail.comwrote: @above : typo mistake : in the given example inorder of BST = 10 20 30 40 50 key = 27 output: floor= 20 -- You received this

[algogeeks] Re: Finding closest double in a Btree

2012-02-21 Thread Don
I was fairly certain that the poster was asking about binary search trees. I realized that he did not say that, but I also realized that there is nothing to the problem if it is not a binary search tree. So I answered the problem which I believed the poster was asking. That might not fly in

[algogeeks] Re: Finding closest double in a Btree

2012-02-21 Thread Don
Supraja, You asked for feedback on your solution. First of all, difference is a static class member which is set to zero. There is nothing to reset difference for each time you call your function. Therefore, if you call the function more than once, the old value will still be there. Second, you

[algogeeks] MODULUS

2012-02-21 Thread Anurag Gupta
how can we take mod by a very large number for example 100283 int mod = 100283; ans % mod is not working Please Help -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: MODULUS

2012-02-21 Thread Don
A 32-bit integer can not store numbers that large, so you need to use something with more than 32 bits. For your example, a 64-bit integer should work. Try using type long long int. Some compilers call it __int64. If you need something larger than your compiler provides, you can use an extended

Re: [algogeeks] MODULUS

2012-02-21 Thread Prakhar Jain
Why you expect it should work...? the constant you assigned to mod is not within int range declare it as long long mod = 100283LL; and it would work. On Tue, Feb 21, 2012 at 8:10 PM, Anurag Gupta anurag.gupta...@gmail.comwrote: how can we take mod by a very large number for example

[algogeeks] Re : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread shady
Problem link http://www.spoj.pl/ABACUS12/status/ABA12E/ -- 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 : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread sunny agrawal
i dont know if a better solution exists but here is one with complexity O(N*logS)... N = no of elements in array S = max sum of a subarray that is sum of all the elements as all are positive algo goes as follows do a binary search in range 0-S, for each such candidate sum find how many sums are

[algogeeks] use of sentinel in linked list

2012-02-21 Thread karthikeya s
How to implement a linked list using sentineli mean sentinel will be having some non-null address.then how would u identify it except remembering the address. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] Re : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread shady
didn't get you, how to check for subsequences which doesn't start from the beginning ? can you explain for that same example... should we check for all contiguous subsequences of some particular length? On Tue, Feb 21, 2012 at 11:15 PM, sunny agrawal sunny816.i...@gmail.comwrote: i dont know

Re: [algogeeks] Re : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread atul anand
if i am getting it right input has only positive number then if k = N (number of elements) , then it would similar to finding kth smallest element in the array. because we can consider each element in the input as a sub array. now if k N , then we need to find (k-N)th smallest element

[algogeeks] Re: use of sentinel in linked list

2012-02-21 Thread Don
What are you using the sentinel for? A marker for the end of the list? A common way to implement a linked list is to use a sentinal as the head of a circularly linked list. Thus, an empty list is a pointer to the sentinal which is linked to itsself. The advantage is that there are fewer special

Re: [algogeeks] Re : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread shady
can you do it for some example where k N... i am confused On Wed, Feb 22, 2012 at 12:22 AM, atul anand atul.87fri...@gmail.comwrote: if i am getting it right input has only positive number then if k = N (number of elements) , then it would similar to finding kth smallest element in

Re: [algogeeks] Re : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread sunny agrawal
we need to find how many sums are less than candidate Sum chosen in one iteration of binary search in range 0-S To count this, for each i we try to find how many sums ending at i are lesser than candidate sum !! lets say for some i-1 sum[0 - i-1] candidate sum then we can say that i*(i-1)/2 sums

Re: [algogeeks] Re : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread shady
great solution :D thanks. On Wed, Feb 22, 2012 at 12:41 AM, sunny agrawal sunny816.i...@gmail.comwrote: we need to find how many sums are less than candidate Sum chosen in one iteration of binary search in range 0-S To count this, for each i we try to find how many sums ending at i are

[algogeeks] Re: Re : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread Don
Here is a possible approach: Use a heap in which each element contains a range and the sum for that range. Initially the heap contains n ranges of size one, one per balloon, where the sum is the score for that one balloon. Then k times you extend the smallest range by one by adding the smaller of

[algogeeks] Re: use of sentinel in linked list

2012-02-21 Thread Gene
Exactly. The other trick is when maintaining a list in ascending sorted order, to give the sentinel a key of infinite. This way you need not check for the end of list at all. The key comparison will always stop before the last element. I vaguely recall Wirth uses this example in his book

Re: [algogeeks] Re : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread atul anand
@sunny : before moving to your algorithm , i can see wrong output in your example:- in you example dere are 8 sums less than 7. but for given input contiguous sum less than 7 are 1,2,3,4,5 = 4 contiguous sum (1,2) , (2,3) -- these contiguous sum has already been counted so output is 4. correct

Re: [algogeeks] Re : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread sunny agrawal
@atul there are 8 sums less than 7 sum[0 - 0] = 1 sum[1-1] = 2 sum[2 - 2] = 3 sum[3-3] = 4 sum[4-4] = 5 sum[0-1] = 3 sum[0-2] = 6 sum[1-2] = 5 contiguous sum (1,2) , (2,3) -- these contiguous sum has already been counted ??? where ? Read problem statement carefully !! On Wed, Feb 22, 2012 at

Re: [algogeeks] Re : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread atul anand
sum[0-1] = 3 -- (1,2) sum[0-2] = 6 -- (1,2,3) sum[1-2] = 5 -- (2,3) ok...so we can consider 3 , (1,2) as different contiguous. how did you choose candidate sum for the given input ?? will it not add to the complexity On Wed, Feb 22, 2012 at 9:59 AM, sunny agrawal sunny816.i...@gmail.comwrote:

Re: [algogeeks] Re : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread sunny agrawal
Yes, read my first post On Wed, Feb 22, 2012 at 10:19 AM, atul anand atul.87fri...@gmail.comwrote: sum[0-1] = 3 -- (1,2) sum[0-2] = 6 -- (1,2,3) sum[1-2] = 5 -- (2,3) ok...so we can consider 3 , (1,2) as different contiguous. how did you choose candidate sum for the given input ?? will

[algogeeks] Microsoft IT-Operations Interview

2012-02-21 Thread Mihir Kulkarni
Hello, Please let me know if anyone knows anything about Microsoft IT- Operations Interview procedure or the type of questions asked.. Also which areas one should focus on. Any help will be highly appreciated. Thank you all. cheers, Mihir Kulkarni Graduate Student University of California, Irvine

Re: [algogeeks] ARICENT PATTERN

2012-02-21 Thread abhinav gupta
Aricent will not conduct test by itself. They'll have other organization who will conduct the exams. There are many test to be conducted in the time period of 2 or more. i just forgot the time limit limit. But the exams on apptitute, c language/java language either of one, technical test, verbal

Re: [algogeeks] ARICENT PATTERN

2012-02-21 Thread atul anand
written exam - will contain aptitude question + c question (focus on pointers) basic data structure tree , stach ,queue ,linked list. memory layout of a given program some basic question abt how to add elements node to the middle of the linked list. what are big and small endien , write Fibonacci

[algogeeks] Re: ARICENT PATTERN

2012-02-21 Thread vivek kumar
is it aspiring minds?? can u tell me the level of resning and apptitude -- 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] Re: ARICENT PATTERN

2012-02-21 Thread vivek kumar
thanks bro ... plz tell me no of question in each section -- 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 : Any hints[kth smallest contiguous sum] ?

2012-02-21 Thread sunny agrawal
*NO, u r getting it wrong* *given a value x, we can find how many contiguous sums are lesser than x using the above mentioned algorithm in O(N)* *so we are searching a x in range 0-S such that, x has exactly k-1 sums lesser than x and x is kth* * * *Algorithm: * *for * On Wed, Feb 22, 2012 at

[algogeeks] Re: use of sentinel in linked list

2012-02-21 Thread karthikeya s
@don,@gene: i know the pros of using it.but pbm occurs when we see pbm LIST-SEARCH(l,k) x - next[nil[l]] //nil[l] denotes the sentinel node while x != nil[l] and key[x] != k x - next[x] return x here to eliminate extra comparison (x != nil[l] ) in while loop ,