Minimum Cost Tree From Leaf Values solution explanation needed

I’m trying to understand the solution for the question posted here:

One of the solutions is to find the minimum leaf node, add the product with its smaller neighbor and remove it from the array and continue the same way until array size is one.

here is the link for the solution:

What is the result binary tree? why is it working..


How to plot a graphic with solution of some inequality?

I defined the function $ z(n)$ by

z[n_] := Catch[Do[i; If[Mod[Fibonacci[i], n] == 0, Throw[i]], {i, 100000}]]

and now, I would like to plot the graphic (n,z(n)) for points such that $ z(n)/n<\epsilon$ , for some given value of $ \epsilon>0$ . For instance, for $ \epsilon=0.05$ , I used the command

Catch[Do[n; If[z[n] < 0.05*n, Print[n]], {n,1, 3000}]]

which provides me many values of $ n$ , but I do not know how to make a graphic with them (they appear in some collumn). Thanks in advance.

Solution for password spraying on my app

We have a web application where the input fields for login are: username and password. In order to prevent brute force attacks, we have implemented a lockout function for 5 invalid tries of valid username but the incorrect password.

What the penetration testers did was use the same password but enumerated usernames until a valid one was found. No lockout can prevent that since the username field is always changed. They did enumeration at a rate just below the minimum threshold for the firewall to categorize this as an automated attack and block it.

It seems the only way to handle this is programmatically. I have some solutions in mind but I don’t want to reinvent the wheel. Are there are solutions on how to handle this programmatically?

Iterative-substitution method yields different solution for T(n)=3T(n/8)+n than expected by using master theorem

I’s like to guess the running time of recurrence $ T(n)=3T(n/8)+n$ using iterative-substitution method. Using master theorem, I can verify the running time is $ O(n).$ Using subtitution method however, I arrive at a different answer than expected..

$ T(n)=3T(n/8)+n\ =3T(3T(n/8^2)+n)+n=3^2T(n/8^2)+3n+n\ =3^2(3T(n/8^3)+n)+3n+n=3^3T(n/8^3)+3^2n+3n+n$

We can see the pattern: $ 3^iT(n/8^i)+n*\frac{3^i -1}{2}$

The recursion finishes when $ i=log_8 n$ .

Substituting i into the discovered pattern, $ 3^{log_8 n}T(1)+n*\frac{3^{log_8 n} -1}{2} =\ n^{log_8 3}*c+0.5n*n^{log_8 3} – 0.5n =n^{log_8 3}*c+ 0.5n^{log_8 3+1}-0.5n \in O(n^{1.52})$ .

What am I doing wrong? why is my answer not $ O(n)$ ?

Time Complexity of a Naive Solution to Merge K Sorted Arrays

There is a leetcode question about merging k sorted arrays. I would like to be able to explain the time complexity of the following naive solution:

function mergexsSortedArrays(xs) {   if (xs === null || xs.length === 0) {     return [];   }    let l1 = xs[0];    for (let i = 1; i < xs.length; i++) {     let l2 = xs[i];      l1 = merge(l1, l2);   }    return l1; }   /* This is simply for completeness; the relevant code is above /* function merge(l1, l2) {   const ans = [];    let l1HeadIdx = 0;   let l2HeadIdx = 0;    while (l1HeadIdx < l1.length && l2HeadIdx < l2.length) {     if (l1[l1HeadIdx] < l2[l2HeadIdx]) {       ans.push(l1[l1HeadIdx]);       l1HeadIdx++;     } else {       ans.push(l2[l2HeadIdx]);       l2HeadIdx++;     }   }    while (l1HeadIdx < l1.length) {     ans.push(l1[l1HeadIdx]);     l1HeadIdx++;   }    while (l2HeadIdx < l2.length) {     ans.push(l2[l2HeadIdx]);     l2HeadIdx++;   }    return ans; }   

Let’s say that k is the number of elements in the input array. To simplify the math, we will assume that each sorted array has length n.

Within the for loop, we are running the merge algorithm. On the first iteration, l1 will have length n and l2 will have length n, so the merge algorithm will be do 2n work. In the second iteration, l1 will be 2n and l2 will be n, so merge will do 3n work. As our result, the amount of work that is being done in our for loop will be 2n + 3n + 4n ... (k - 1) n. If we expand this work a bit, it would be n + 2n + 3n ... k(n), and this can be re-written as n * (1 + 2 + 3 ... k); the inner sum has a closed-form formula of [k * (k + 1)] / 2, which is essentially an O(k^2), and then we add the n to get a final time complexity of O(n(k^2)).

Is this correct? Or have I gone off the rails?

Sharing VPN over wifi Solution

Currently have an issue at the office, where the dev team(in Europe) needs to be able to work from home.

Now the company has a corporate vpn which we access via Cisco any-connect.

in europe they can only access the corp network from the office, but at home only their laptops can access the corp network since it carries anyconeect, but they essential need AP to be able to test their set top boxes, apple tv boxes and so forth.

So i’ve connected a home router directly to the laptop and then started anyconnect which is fine but once i try to share the hotspot from windows the option isn’t allowed.

Is this due to a policy from Cisco annyconnect and is there a workaround as this is urgent.


Soundcloud Player Problem. Is There A Solution?

Hi everybody. I am working on a website and trying to incorporate soundcloud into the design. The Flash version of the soundcloud mp3 player is absolutely perfect for the design of my site. Unfortunately, people on ipods/pads can't see/play the music on that player…

The HTML5 player is nice, but is almost double the size of the Flash player. It's way too big for the design of my site. It moves the products "below the fold" on the page.

Is there any way to cut off a bottom portion…

Soundcloud Player Problem. Is There A Solution?