list ={1, 2, 3, 4, 5, 4, 5}.

I would like to divid this group into 3 sub-list, where the sum of all entries of each sub-list is 8. We have list_1 = {1, 2, 5}, list_2 = {3, 5} and list_3 = {4, 4}.

Could anyone give me a bit hint of this? Thanks very much! ]]>

∑ is sum symbol. I can find a algorithm like search to satisfy the time complexity.

Anyone have some simple way to fix it? ]]>

Example 1

Code:

`9 9 9 9`

9 8 7 9

9 7 8 9

9 9 9 9

Code:

`9 9 9 9`

9 4 3 9

9 5 6 9

9 9 9 9

Code:

`9 9 9 9`

9 4 3 9

9 5 6 9

9 4 9 9

FindValley(k = 2, n = 1) should not find anything on the first example. (there is no number which is lower by 2 or more than all of its neightbours (consider 4-neighbourhood but it is not essential parameter).

On the second example it should return area: (allways we want to have biggest area which fullfil all conditions)

Code:

`4 3`

5 6

What algorithm can I use? Is this known named problem?

And advance version:

Finding valley where I dont mind "islands". So for FindValley(k = 2, n = 1) and:

Code:

`9 9 9 9 9`

9 5 5 5 9

9 5 9 5 9

9 5 5 5 9

9 9 9 9 9

Code:

`5 5 5`

5 5

5 5 5

I have this pseudocode:

Function(int n)

c=1

m=n*n

while (m>1) do

for j=1 to m do

c++

m=m/2

if (n>1) then Function(n/2)

and I have to solve the recurrence relation. The result is O(n^2) but I can't understand why and how.

I'm blocked to this point

T(n)=2+[∑ from m=n^2 to 1 of (m/2^i)] * [∑ from j=1 to m of 1] + T(n/2)

T(n/2)=O(log n)

so i=log n, but I don't know how to go on ]]>

(1,2,3,4,5,6)

this would give me an MSSD of (1^2+1^2+1^2+1^2+1^2+1^2)/5=5/5=1

This is obviously not the best order. The maximum is reached at

(3,5,1,6,2,4)

Here one has MSSD=(2^2+4^2+5^2+4^2+2^2)/5.

I have a simple heuristic in mind for this problem. Start with an empty set and then always add the elements that will enlarge the sum of squared differences the most. With this example it would give the following:

Start with ()

Then add 1 and 6 (this adds 5^2):

(1,6)

then add 5 (this adds 4^2)

(5,1,6)

then 2 (also adds 4^2):

(5,1,6,2)

and then 3 and 4 (both add 2^2):

(3,5,1,6,2,4)

Using simulations, this simple algorithm indeed always gives the best solution. Moreover this solution seems to be unique (except for the reverse order, (4,2,6,1,5,3), which obviously gives the same result). However, I can't proof this. Is this a known problem? Can somebody help me to proof that this heuristic gives indeed the optimal order?

Thanks! ]]>

Geography tree:

TotalGeo

| |

APAC Europe

| | |

CHN INDIA UK

BusinessSegment Tree:

TotalSeg

| |

Fin Economic

| | |

Loan E1 E2

I need to do a cartesian product these two trees and create a new tree. And then i shoud have a method using which i can find the all ancestors of a given node.

Please help. ]]>

Each node is connected to 8 direct nieghbors.

P.S. I am missing couple of lines there... the diagonal connections of the upper and lower nodes..

This is the best I could do drawing with SGI!

I created these two algorithms and I would like your opinion:

2° Lepore primality test and factorization

http://albericolepore.altervista.org...factorization/

and

How to decode the RSA

http://albericolepore.altervista.org/how-to-decode-rsa/

Thank You ]]>

I am pretty new to coding, but I am required to further my knowledge for a new project we are working on. So, I have a quick question about selecting the proper algorithm. So far, from what I have grasped, I believe I may need a "bucket sort" algorithm, but I will let you be the judge of that. I need to randomly populate a list of data, lets say "names" from multiple different lists (each list from which data will be pulled is considered a category or "family", if you will). Multiple categories may be selected and I need a random generation and a way to pull data or "names" from these different lists. In the end, I need a list of about 8-10 items. There are about 10 categories or "families" with anywhere from 5-30 "names" in each. Well, I hope I made some kind of sense. I'm sure someone will be able to understand and help me. I appreciate it!

Here's an image to better explain what I mean here:

https://drive.google.com/file/d/0B95...ew?usp=sharing ]]>

If for example element 0 wants to send a message to element 2, it knows it has to go 2 steps on the left. And if it is searching for -3, it knows it has to go 3 steps on the right.

Each element can perform a search for any other element.

Each element can forward the query to its adjacent neighbor.

IN that case, the worst case scenario would be for element 0 is to search for element 4 or -4, which is 4 steps either way.

Now, if I want to compare the search with this one: The same numbers are arranged in the same circle, however, the search has to go clockwise only, i.e., if I am at 0 and I want to search for 1, I have to walk through all elements clockwise.

Comparing to the first scenario, which one performs better? Should not the first one take half the time of the second one? ]]>

I have to make an algorithm that deletes at most n elements from an AVL tree of 2n size in O(n) time.

The elements which has to be deleted are contained in an array S of n size, not ordered.

I made my solution in this way:

algo tree(tree T, array S) {

S=arrayOrder(S)

stack p

push (p, T)

while(p not empty) {

a=pop(p)

if(inArrayS(a.key)) {

deleteNode(a)

restoreBalance(T)

}

else {

if(a.dx!=null)

push(p, a.dx)

if(a.sx!=null)

push(p, a.sx)

}

}//end while

}

arrayOrder() function performs the array S ordering in O(n log n) time.

inArrayS() searches the key in the node that it's being visiting in the array S, using a binary search in O(log n) time.

deleteNode() deletes the node if its key is in the array S.

restoreBalance() restore the balance after a node deleting operation.

The binary search is performed n times, could it be good for a solution?

thanks ]]>