[algogeeks] Find the number of islands/connected components

2013-04-10 Thread rahul sharma
{*1*,* 1*, 0, 0, 0}, {0, *1*, 0, 0, *1*}, {*1*, 0, 0, *1*, *1*}, {0, 0, 0, 0, 0}, {*1*, 0, *1*, 0, *1*} Can anybody eplain how there are 5 islands in above matrix..thnx in advan

Re: [algogeeks] Find the number of occurences of maximum sum in given array.

2011-08-15 Thread Bharat Kul Ratan
I appreciate your efforts but for the data set {0,0,0,0} {0,0,-3,0} {0,0,0,1} the number of counts should be 10, 4, 4 respectively but code outputs 15, 7, 8. Also it would be a little helpful if you explain your code a little bit. -- You received this message because you are subscribed to the

Re: [algogeeks] Find the number of occurences of maximum sum in given array.

2011-08-15 Thread sandeep pandey
i think this wl work. #include long long int myread() { char str[20]; long long int sum,i; scanf("%s",str); for(i=0,sum=0;str[i];i++) sum =(sum*10)+str[i]-'0'; return sum; } long long

Re: [algogeeks] Find the number of occurences of maximum sum in given array.

2011-08-15 Thread sukran dhawan
u can keep a counter for the number of max values.not sure whether the algo works for zero.u can extend the algo i guess.correct me if i m wrong On Mon, Aug 15, 2011 at 9:34 PM, Bharat Kul Ratan wrote: > @sukran: I've gone through Kadane's algo but I was looking for the number > of times the sum

Re: [algogeeks] Find the number of occurences of maximum sum in given array.

2011-08-15 Thread Bharat Kul Ratan
@sukran: I've gone through Kadane's algo but I was looking for the number of times the sum appears especially cases involving zeros. -- 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.goo

Re: [algogeeks] Find the number of occurences of maximum sum in given array.

2011-08-15 Thread Adi Srikanth
u can use count sort or bucket sort, hashing Regards, Adi Srikanth. Mob No 9887233349 Personal Pages: adisrikanth.co.nr On Mon, Aug 15, 2011 at 8:54 PM, sukran dhawan wrote: > use kadane 's algorithm > > > On Mon, Aug 15, 2011 at 8:46 PM, Bharat Kul Ratan > wrote: > >> We've to count how many t

Re: [algogeeks] Find the number of occurences of maximum sum in given array.

2011-08-15 Thread sukran dhawan
use kadane 's algorithm On Mon, Aug 15, 2011 at 8:46 PM, Bharat Kul Ratan wrote: > We've to count how many the times the maximum sum occurs in an array. Value > of maximum sum includes only contiguous elements and is defined as addition > of elements. > For example, if given array is: > > 0 1 1 2

[algogeeks] Find the number of occurences of maximum sum in given array.

2011-08-15 Thread Bharat Kul Ratan
We've to count how many the times the maximum sum occurs in an array. Value of maximum sum includes only contiguous elements and is defined as addition of elements. For example, if given array is: 0 1 1 2 ; maxsum is 4 and count is 2 1 0 1 ; maxsum is 2 and count is 1 1 0 -1 -1 1 0 ; maxsum is

Re: [algogeeks] Find the number of solutions.

2011-07-28 Thread Kunal Patil
x^(x^x) - (x^x)^x = 0 Thus, x^(x^x) = (x^x)^x Let's open it up by taking log on both sides... (x^x)*log(x) = x* log(x^x) (x^x)*log(x) = x*x*log(x) If x==1 equation is satisfied as log(x) becomes 0.. so x=1 is definitely a solution. what if when x != 1 cancelling log(x) on both the sides.. x^x = x^

Re: [algogeeks] Find the number of solutions.

2011-07-28 Thread AASHISH SUMAN
this question is from http://www.facebook.com/groups/150933398312351/?ap=1 -- *WITH BEST REGARDS : AASHISH SUMAN MCA FINAL YEAR * *NIT DURGAPUR* *+91-9547969906* -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, s

Re: [algogeeks] Find the number of solutions.

2011-07-28 Thread sunny agrawal
2 solutions - > {1,2} On Fri, Jul 29, 2011 at 11:10 AM, vaibhav_iiit wrote: > how many values of x are possible in the following equation. > > x^(x^x) - (x^x)^x = 0 > > where a^b =power(a,b). > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" g

[algogeeks] Find the number of solutions.

2011-07-28 Thread vaibhav_iiit
how many values of x are possible in the following equation. x^(x^x) - (x^x)^x = 0 where a^b =power(a,b). -- 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 t

[algogeeks] find the number.

2010-12-11 Thread Naresh A
Given range of numbers between A and B (A<= B) Find the number within given range which has more number of iterations as per the following n { stop ; return iteration number } if n=1; n = 3n+1 if n is odd n = n/2 if n is ev

Re: [algogeeks] Find the number with maximum frequency in an array. Better than O(nlogn + n) time complexity

2010-06-01 Thread Terence
This is a different problem, where the requested number with maximum frequency is not necessary majority. On 2010-6-1 13:19, harit agarwal wrote: see this .vote majority algorithm.. http://userweb.cs.utexas.edu/~moore/best-ideas/mjrty/index.html

Re: [algogeeks] Find the number with maximum frequency in an array. Better than O(nlogn + n) time complexity

2010-05-31 Thread harit agarwal
see this .vote majority algorithm.. http://userweb.cs.utexas.edu/~moore/best-ideas/mjrty/index.html -- 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] Find the number with maximum frequency in an array. Better than O(nlogn + n) time complexity

2010-05-31 Thread Nikhil Agarwal
This question has already been discussed here.There are 4-5 methods to do this ,best is 'Moore voting algorithm' . refer: http://geeksforgeeks.org/?p=503 On Mon, May 31, 2010 at 10:01 PM, souravsain wrote: > Hi All > > This is my first post to this community and so am exited. The problem > i

Re: [algogeeks] Find the number with maximum frequency in an array. Better than O(nlogn + n) time complexity

2010-05-31 Thread janak chandarana
On Mon, May 31, 2010 at 10:01 PM, souravsain wrote: > Hi All > > This is my first post to this community and so am exited. The problem > is to find the no. that has maximum frequency in an array (size n) of > integers. > > The approach to use a hash table, itereate through array (O(n)) and > keep

[algogeeks] Find the number with maximum frequency in an array. Better than O(nlogn + n) time complexity

2010-05-31 Thread souravsain
Hi All This is my first post to this community and so am exited. The problem is to find the no. that has maximum frequency in an array (size n) of integers. The approach to use a hash table, itereate through array (O(n)) and keep inserting into hash table (O(1)) and then scan the hash table (O(n)

[algogeeks] Find the number of paths between two points on a grid

2006-04-04 Thread vasudevank
There are nodes as determined by given points, and you have to find the number of paths between two given points by going on the nodes, and you can't repeat a node for a path. You have to horizontal and vertical (no diagonal in a path) --~--~-~--~~~---~--~~ You re