algorithms: cross tree that collects combinations of nodes

Summary: I have a tree that contains auto parts, from which I need to build all valid combinations of these parts.

Parts may be required; Each compilation must contain them.

The parts can be optional.

The parties may conflict with other parties.

The parties may have optional parts within them.

Example tree:

Car
| - Motor (required)
| - - V8
| - - V12
| - - - Colour (optional)
| - - - - Black
| - - - - Chrome
| - Transmission (required)
| - - Mechanical
| - - Automatic
| - Wheels (optional)
| - - Basic
| - - Fancy
| - - - Colour (optional)
| - - - - Red
| - - - - Blue
| - BodyStyle (optional)
| - - Hatchback (conflicts with Motor.V12)
| - - Buggy (conflicts with Motor.V8)

Valid constructions for this tree:

Car | Motor.V8 | Transmission.Automatic
Car | Motor.V8 | Transmission.Automatic | Wheels.Basic
Car | Motor.V12.Colour.Black | Transmission.Automatic | Wheels.Basic
Car | Motor.V8 | Transmission.Automatic | BodyStyle.Hatchback
Car | Motor.V12 | Transmission.Mechanical | Wheels.Fancy | BodyStyle.Buggy
Car | Motor.V12 | Transmission.Mechanical | Wheels.Fancy.Colour.Red | BodyStyle.Buggy

What algorithm should I look for to solve this task?

Algorithms – What is the right, root, left order path in a binary search tree called?

In a Binary Search Tree, you have the following travel orders:

Left, Root, Right is called Inorder (or ascending order).

Root, left, right is called preorder.

Left, right, root is called PostOrder.

But what is it called Right, Root, Left (or descending order)?

algorithms: what are the next steps to express the recurrence relationship $ c + nT (n ^ { frac {1} {2}}) $ in the form $ T (n) in O (n ^ x log ^ yn PS

I have an algorithm that solves a problem with $ n $ subproblems of each size $ sqrt {n} $ with $ O (1) $ Combining time.

I understand that I can express the above as $ c + nT (n ^ { frac {1} {2}}) $ where $ c $ It is the time of constant combination.

By telescoping I get the following:
$ T (n) = c + nT (n ^ { frac {1} {2}}) $
$ T (n) = c + n (c + nT (n ^ { frac {1} {4}})) $
$ T (n) = c + nc + n2 T (n ^ { frac {1} {4}}) $
$ T (n) = c + nc + n2 (c + nT (n ^ { frac {1} {8}})) $
$ T (n) = … $

I am supposed to express this recurrence relationship in the form $ T (n) in O (n ^ x log ^ y n) $ where $ x $ Y $ and $ I must determine it, but I am not really sure what are the next steps I should take.

Any pointer would be much appreciated.

algorithms: search for closed forms for return values


int coffee(int n) {
   int s = n * n;
   for (int q = 0; q < n; q++)
      s = s - q;
   for (int q = n; q > 0; q--)
      s = s - q;
   return s + 2;
}

int tea(int n) {
    int r = 0;
    for (int i = 1; i < n*n*n; i = i * 2)
        r++;
    return r * r;
}

int mocha(int n) {
    int r = 0;
    for (int i=0; i<=n; i = i+16)
        for (int j=0; j

I am trying to find the return value in terms of $ n $ for coffee, tea, mocha, but I'm stuck right now.

I know coffee will return 2 as follows the code:

$ s = n ^ 2 $

$ s = n ^ 2 - displaystyle sum_ {q = 0} ^ {n-1} q = n ^ 2 - dfrac {n (n-1)} {2} $

$ s = n ^ 2 - dfrac {n (n-1)} {2} - displaystyle sum_ {q = 1} ^ nq = n ^ 2 - dfrac {n (n-1)} {2} - dfrac {n (n + 1)} {2} = 0 $

So, $ s = 0 + 2 $.

However, I can't seem to understand tea, mochaY espresso, because they do not follow +1 increments. Could someone help me calculate the return value in terms of $ n $?

Algorithms – Find the return value in terms of $ n $


int coffee(int n) {
   int s = n * n;
   for (int q = 0; q < n; q++)
      s = s - q;
   for (int q = n; q > 0; q--)
      s = s - q;
   return s + 2;
}

int tea(int n) {
    int r = 0;
    for (int i = 1; i < n*n*n; i = i * 2)
        r++;
    return r * r;
}

int mocha(int n) {
    int r = 0;
    for (int i=0; i<=n; i = i+16)
        for (int j=0; j

I am trying to find the return value in terms of $ n $ for coffee, tea, mocha, but I'm stuck right now.

I know that coffee will return 2 as the code follows:

$ s = n ^ 2 $

$ s = n ^ 2 - displaystyle sum_ {q = 0} ^ {n-1} q = n ^ 2 - dfrac {n (n-1)} {2} $

$ s = n ^ 2 - dfrac {n (n-1)} {2} - displaystyle sum_ {q = 1} ^ nq = n ^ 2 - dfrac {n (n-1)} {2} - dfrac {n (n + 1)} {2} = 0 $

So, $ s = 0 + 2 $

, but I can't seem to understand tea, mocha and espresso because they don't follow +1 increments. Could someone help me calculate the return value in terms of $ n $?

algorithms – Doubt about possible attack based on "phishing" of routers

My question is whether there is a kind of cyberattack based on redirecting a packet in route from one point to another in a network making it believe that it is going to a "benign" router when it is actually going to ours, copying the identity of the real router in order to trick the routing algorithm to divert packets and access them.

If it does not exist, I would appreciate arguments for which this would not be feasible in practice. Thanks in advance.

Algorithms – Temporary complexity of simple functions related to bits

I wonder about Right Answer this task from a test yesterday:

A function Pow that calculates $ y = a ^ k $ it occurs where $ k $ is a
integer length $ n $ bits:

function Pow(a, k)     { k >= 0 }
    z := a;
    y := 1;
    m := k;
    while m != 0 do
        if m mod 2 = 1 then
            y := y * z;
        end if
        m := m div 2;
        z := z * z;
    end while
    return y;
end function

Calculate the complexity of the weather in the worst case and the average time
complexity of this function. The dominant operation is a comparison
operation performed on line 6. Briefly describe the value of $ k $ when
The worst case occurs.

So, I think the number of comparisons depends on the length of $ k $ in terms of its bits.

Leave $ k = 0 $: (binary $ 0 $ also what is $ 1 $ little bit):

$ Rightarrow 0 $ comparisons

Leave $ k = 1 $: (binary $ 1 $ also what is $ 1 $ little bit):

$ Rightarrow 1 $ comparison

Leave $ k = 8 $: (binary $ 1000 $ which $ 4 $ bits)

$ Rightarrow 4 $ comparisons

Leave $ k = $ 15: (binary $ 1111 $ which $ 4 $ bits)

$ Rightarrow 4 $ comparisons

Leave $ k = $ 16: (binary $ 10,000 which $ 5 $ bits)

$ Rightarrow 5 $ comparisons

I think you can see a pattern.


Any set number 2 h, 2 ^ h + 1, cdots, 2 ^ h + 1} – 2, 2 h + 1} – 1 } quad land quad h> 0 $ $, is $ h + $ 1 long pieces and therefore $ h + $ 1 comparison.


Then i think $ T_ {avg} (n) = T_ {worse} (n) = n in O (n) $

But $ n $ is the number of bits of $ k $ number. Take function $ k $ as a parameter, no $ n $. So, my solution is not the desired one, I think.


In terms of $ k $ I think it would look like this:

$ T_ {worse} (k) = lfloor log_ {2} (2k) rfloor in O ( log k) $

$ T_ {avg} (k) = lfloor log_ {2} (2k) rfloor in O ( log k) $


Questions:

  1. It is the solution in terms of $ k $ Right?
  2. The solution in terms of $ n $: How would you rate that, personally? Know the task description of the above.

I have published a similar thread in the mathematical stack exchange, but I would like to get more opinions on this from the CS experts themselves.

What machine learning algorithms are used to detect zero-day attacks by firewall companies such as Fortinet?

  • How are firewall companies like fortinet using AI algorithms to detect malicious traffic and zero-day attacks?
  • What machine / deep learning algorithms are being used for this purpose?

algorithms: integer solutions for $ xy> c ^ 2 $ where x e y are linked

How to efficiently calculate all integer solutions for $ xy> c ^ 2 $ where

$ 0 <x <X $ Y $ 0 <and <Y $ Y $ X $, $ Y $Y $ C $ are some positive integers

I am looking for an algorithmic solution.

I tried to force it as follows:

  1. 1 to c loop
  2. Calculate when x and y are both greater than c
  3. Calculate when x = c and solutions for y and then vice versa
  4. This is the part that slows the entire process. Calculate the possible solutions when one of them is less than c.

I am mainly interested in the number of points that are valid solutions.

I think if I turn this rectangular hyperbola by $ 45o $, would solve the problem, but this did not go anywhere.

Algorithms: minimum route coverage in a directed acyclic graph

Given a weighted directed acyclic graph G = (V, D, W) and a set of arches RE & # 39; of rewhere the weights of W They are at the vertices. The problem is partitioning Sun on a minimum number of paths separated from vertices that cover all vertices of Sun subject to restrictions that:

  1. the weight of each route is maximum k.
  2. each route must include at least one edge of D & # 39;

What is the complexity of this problem?