## IntwPrep

BAN USERLets see if we can re-phrase the question:

Divide the array into two EQUAL halves which has same AVERAGE

which means, the array is of even size, and the question can be rephrased as:

Divide the array into two EQUAL halves so that they have the same SUM

Algorithm:

1. compute the total sum of the array elements: lets say it is X

2. We need to find two subarrays of equal length which adds to X/2

3. Use subset sum algorithm to see if such subarrays exist

Probability of 1 slot having i elements P(1)=

`(1/M)^i * ((M-1)/M)^N-i`

Probability of 2 slots having i elements P(2)=

`(1/M)^2i * ((M-1)/M)^N-2i`

Probability of 3 slots having i elements P(3)=

`(1/M)^3i * ((M-1)/M)^N-3i`

...

and so on, so the probability of having A slot with i elements is: P(1)+P(2)+....+P(M)

but I am not sure of a formula to generalize this equation.

How about you have 26 trees, one for each alphabet,

Properties of the tree: It has a root, and n children

Root occurs before all its children.

In English tree for A has 25 children, B has 24 Children. Similarly keep building the trees and stop when the number of children in all the trees is 25*(25+1)/2=325. Now order the roots based on the number of children you have.

N - size of input

K - size of required set

M - size of memory

- build minheaps of size M, we will have K/M heaps.

- Within memory store the smallest value (say MIN), and a pointer to the minheap (say HP) with this smallest value

- When reading the input if you encounter a value less than MIN, then adjust HP to add the new element - Time complexity log M

- Search through K/M heaps to find new MIN and HP - time complexity log (K/M)

Time complexity will be N (log M + log (K/M))

Rep**juanitajboon**, Applications Developer at 247quickbookshelpHi everyone, I am from Pelham. I currently work in the Hechinger as Cashier.I like to do creative things ...

Rep**kristinedavila9**, Android Engineer at ABC TECH SUPPORTI am Kristine Davila Professor and director at Clinical Psychology. Having experience of 6 years in my career. I have ...

Rep**EdithJHarden**, Random at Axiom SourcesJe suis un professionnel de la gestion des soins de santé avec 2 ans d'expérience en supervision d'établissements ...

Rep**jenniferdray9**, Accountant at ABC TECH SUPPORTHi I am Jennifer D. Ray from san Diego.Currently i am working as a parts salesperson in Rite solution ...

Rep**loreleijhansen**, Aghori Mahakal Tantrik at ABC TECH SUPPORTI am Lorelei.I am working in a store as a Bonus clerk promoting the development, and implementation and solutions ...

Rep**kathyrnunez**, Area Sales Manager at AdventI am manager in a Star Bright Investment Group company. I like to solve puzzles for Has excellent problem-solving and ...

Rep**martinskrull**, Analyst at A9Hi everyone, I am from new york,USA. I currently work in the Affiliate Marketing industry. I love all things ...

Rep**waynebgrover**, AT&T Customer service email at ASAPInfosystemsPvtLtdI am 31 years old and live in San Jose with my family. I have all types of books and ...

Rep**markemorgan007**, Applications Developer at Big FishI am Mark From Fresno city in USA.I working as a tour guide and also help for make a ...

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

1) Find the number of ways the boards can be divided into K subsequent parts. Which is

2) Now for each combination, we get the minimum time by assigning the maximum sum subpart to the fastest painter. Using this condition compute the minimum time required for each division found in step 1

3) Keep track of the minimum value computed in step 2

Time complexity is:

- IntwPrep October 09, 2013