Re: [algogeeks]

2011-11-27 Thread kartik sachan
simply find max in o(n) by liner search then remove max then again find max that will be second max:P :P -- 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 f

Re: [algogeeks] Networking Question

2011-11-27 Thread Bhavesh agrawal
A baud rate is the number of times a signal in a communications channel changes state or varies. For example, a 9600 baud rate means that the channel can change states up to 9600 times per second. The term “change state” means that it can change from 0 to 1 or from 1 to 0 up to X (in this case, 960

Re: [algogeeks]

2011-11-27 Thread Bhavesh agrawal
down vote You can, this is the pseudo algorithm: max = 2max = SMALLEST_INT_VALUE; for element in v: if element > max: 2max = max; max = element; else if element > 2max: 2max = element; 2max is the value you are looking for. -- You received this message because you a

Re: [algogeeks]

2011-11-27 Thread tech coder
loop through the elements of array. keep two vales firstlargest and 2ndlargest and update accordingly. loop i=1 to n { if(a[i]>1stlargest) { 2ndlargest=1stlargest; 1stlargest=a[i]; continue; } if(A[i]>2ndlargest) 2ndlargest=a[i]; }// loop c

[algogeeks]

2011-11-27 Thread KARTHIKEYAN V.B.
Hi, Find the highest and second highest element in an array in O(n) time Input : arr[]={1,4,0,7,8,9} Output : 9 and 8 Thanx in advance Regards, Karthikeyan -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send em

Re: [algogeeks] Re: Google Question--Suggest Algo

2011-11-27 Thread Ankur Garg
Cool Solution...I was thinking of DP but wasnt clear on the recurrence... Nice thinking man and thanks :) On Mon, Nov 28, 2011 at 2:47 AM, sourabh wrote: > Consider the example that you have given: > [0,0,1,1,0,0,1,1,0,1,1,0] , here n = 12 and k=3 > > Now we need to partition the array into 3

[algogeeks] Re: Google Question--Suggest Algo

2011-11-27 Thread sourabh
Consider the example that you have given: [0,0,1,1,0,0,1,1,0,1,1,0] , here n = 12 and k=3 Now we need to partition the array into 3 contiguous sub arrays such that : a) The expected sum value is maximum b) and the size of each sub array should be between 2 and 6, both inclusive. In case, this cons

Re: [algogeeks] Re: Google Question--Suggest Algo

2011-11-27 Thread Ankur Garg
Hey Sourabh Could you please explain the solution in a bit detail perhaps using an example or so..It wud be really helpful ..Just logic not code On Mon, Nov 28, 2011 at 1:03 AM, sourabh wrote: > Looks like a dynamic programming problem > > Say F(n,k) denotes the maximum expected sum value f

Re: [algogeeks] Re: Finding the repeated element

2011-11-27 Thread Ankur Garg
Yup Gene ..rightly said and very well pointed out :) ..My Mistake :( On Sun, Nov 27, 2011 at 12:49 AM, Gene wrote: > Isn't this overkill? If you're already using a set, just check the set > before you insert each new element, and you'll discover the > duplicates: > > S = empty > while i = input

[algogeeks] Re: Google Question--Suggest Algo

2011-11-27 Thread sourabh
Looks like a dynamic programming problem Say F(n,k) denotes the maximum expected sum value for an array of n elements and partition k , then F(n,k) = MAX for all r such that ceil(n/2k) <= r <= floor(3n/2k) { (expected value of array elems from A[n] to A[n-r+1]) + F(n-r, k-1) } Base conditio

[algogeeks] Re: Google Question--Suggest Algo

2011-11-27 Thread sourabh
Because in the previous example k = 3. On Nov 27, 10:46 pm, Piyush Grover wrote: > Optimal split: [0,0][1,1][0,0][1,1][0,1][1,0] > Expected value of optimal split: 0 + 1 + 0 + 1 + 1/2 + 1/2 = 3 > why this is not the optimal split??? > > > > > > > > On Sun, Nov 27, 2011 at 6:58 PM, Ankur Garg wro

Re: [algogeeks] What is the difference between portability and Platform Independence??

2011-11-27 Thread Karthikeyan V.B
Hi, Portability focuses on *adaptation of software* in various OS, by recompiling the source to make the binary compatible with the target OS and not necessarily modifying the source. If the source code strictly follows POSIX standard less likely one end up modifying it. Platform independence foc

[algogeeks] Re: Any one

2011-11-27 Thread vikas
the idea is always keep one distance word as next node so your tree will be something like this dict : rat cat bat fat mat tat eat oat . bal given ekt ans eat : 1 down given pats bats aats cats.pts ats pas pat pat> bat : ans 2 iteration now recur

Re: [algogeeks] Google Question--Suggest Algo

2011-11-27 Thread Piyush Grover
Optimal split: [0,0][1,1][0,0][1,1][0,1][1,0] Expected value of optimal split: 0 + 1 + 0 + 1 + 1/2 + 1/2 = 3 why this is not the optimal split??? On Sun, Nov 27, 2011 at 6:58 PM, Ankur Garg wrote: > You have an array with *n* elements. The elements are either 0 or 1. You > want to *split the a

[algogeeks] What is the difference between portability and Platform Independence??

2011-11-27 Thread kumar raja
-- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in -- 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: [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 wrote: > Hint : try with prestoring the preorder traversal element position in > inorder traversal before constructin

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

2011-11-27 Thread Ankuj Gupta
Hint : try with prestoring the preorder traversal element position in inorder traversal before constructing the tree -- 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 unsubscri

[algogeeks] Google Question--Suggest Algo

2011-11-27 Thread Ankur Garg
You have an array with *n* elements. The elements are either 0 or 1. You want to *split the array into kcontiguous subarrays*. The size of each subarray can vary between ceil(n/2k) and floor(3n/2k). You can assume that k << n. After you split the array into k subarrays. One element of each subarray

Re: [algogeeks] One small doubt??

2011-11-27 Thread saurabh singh
@kumar raja rightInfact many languages call the array a list only... @rahul any specific reason why? On Sun, Nov 27, 2011 at 3:35 PM, rahul sharma wrote: > plz dnt post these type of questions . > > > On Sun, Nov 27, 2011 at 11:40 AM, kumar raja wrote: > >> So does list can be a

[algogeeks] Re: Any one

2011-11-27 Thread alexsolo
Here is the idea and the python code: http://stevehanov.ca/blog/index.php?id=114 -- 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 a

Re: [algogeeks] One small doubt??

2011-11-27 Thread rahul sharma
plz dnt post these type of questions . On Sun, Nov 27, 2011 at 11:40 AM, kumar raja wrote: > So does list can be a linked list or similar data structure , right?? > > > On 27 November 2011 11:17, saurabh singh wrote: > >> ans 1) Array is a *contigous elements.*The elements of a list need not