## Efficiently find "unfounded edges" on a strongly connected graph

I have encountered an issue that I need to resolve regarding dependency charts. I have simplified it as follows:

Consider a strongly connected graph G = (V, E).

• We define a subset of vertices S ⊆ V as origin vertices.
• We call an edge me = (a,yes) unfounded if there is not simple way from any vertex of origin to yes that includes me. In other words, all paths from a source vertex that include edge me, must include vertex yes at least twice.

The problem:

• Find all unsubstantiated edges in G.

There are some obvious ways of ineffectively solving this (for example, a depth run first for each edge in G), but I was wondering if there was any O (| E |) Getting closer. I have been struggling with this for a while and I continue to "almost" solve it in linear time. Maybe that is impossible? I have no idea what the lower limit of efficiency is, and I was hoping that some readers here could help me discover some efficient approaches.

## architecture – How do I connect these four entities together efficiently?

I have four entities at the moment and can't find a good way to design this. Maybe some of you can help me with this? The scenario is as follows:

We have 4 entities that somehow relate to each other. (Product, Cart, Discount and Coupon). In the image provided you can see how they are related:
https://imgur.com/tLjkaKr

• A product may have a discount.
• A cart may have a discount.
• A coupon can have a discount (or activate a discount).

• Only one discount can be applied to the product and cart, however, with the use of a coupon code, a second discount can be applied (only one coupon can be activated at a time).

• There may also be many coupons that can activate the same product (for example, a coupon with the code 1234, ABCD and! @ # \$ They can activate a discount on Product A)

Now, in database terms (specifically a MongoDB NoSQL database), I'm stuck with creating an entity diagram for this, because many of these scenarios clog up my designs. I'm curious and wondering how you could establish these relationships and I'd appreciate your inspiration.

## optimization: take school courses efficiently

I want a design algorithm that allows a student to take important courses quickly until graduation. no time, room number, teachers are needed here. Only my selected courses that I know will allow me to graduate, but the best way to take them based on the prerequisites.

any suggestions and how to do it. Trees, graphic adjacency list

## c ++ – How to efficiently copy data from device to host if transfer size is not available on host

I'm looking for a way to copy data from the device to the anchored host memory, where the number of items to copy is only present in the memory of the device. A maximum number of items to copy is known (batch size). The number of items to copy is generally 5% to 15% of that maximum.

I think there are two possibilities:
1. Copy the number to the host, then run cudaMemcpyAsync using that number.
2. Use a copy core that writes directly to the tethered memory.

Here is the example program that implements both.

``````#include
#include
#include
#include

#define CUERR {
cudaError_t err = cudaGetLastError();
if (err != cudaSuccess) {
std::cout << "CUDA error: " << cudaGetErrorString(err) << " : "
<< __FILE__ << ", line " << __LINE__ << std::endl;
exit(1);
}
}

#define starttimer(label)
std::chrono::time_point a##label, b##label;
a##label = std::chrono::system_clock::now();

#define stoptimer(label)
b##label = std::chrono::system_clock::now();
std::chrono::duration delta##label = b##label-a##label;
std::cout << ""<< #label <<": "
<< delta##label.count()  << " s" << std::endl;

template
__global__
void memcpyKernel(
T* __restrict__  output,
const T* __restrict__ input,
const int* __restrict__ d_numElements){

const int tid = threadIdx.x + blockIdx.x * blockDim.x;

if(tid < *d_numElements){
output(tid) = input(tid);
}
}

template
void callMemcpyKernel(
T* output,
const T* input,
const int* d_numElements,
int maxNumElements,
cudaStream_t stream){

dim3 block(512,1,1);
dim3 grid((maxNumElements + block.x - 1) / block.x, 1, 1);

memcpyKernel<<>>(output, input, d_numElements); CUERR;
}

int main(){

cudaSetDevice(0); CUERR;

int* d_numElements;
int* h_numElements;
int* d_elements;
int* h_elements;

//setup
int maxNumElements = 1 << 25;
int numElements = 1 << 20;

cudaMalloc(&d_numElements, sizeof(int)); CUERR;
cudaMemcpy(d_numElements, &numElements, sizeof(int), cudaMemcpyHostToDevice); CUERR;
cudaMallocHost(&h_numElements, sizeof(int)); CUERR;

std::vector elements(numElements);
std::iota(elements.begin(), elements.end(), 0);

cudaMalloc(&d_elements, sizeof(int) * numElements); CUERR;
cudaMemcpy(d_elements, elements.data(), sizeof(int) * numElements, cudaMemcpyHostToDevice); CUERR;
cudaMallocHost(&h_elements, sizeof(int) * numElements);

cudaStream_t stream;
cudaStreamCreate(&stream); CUERR;

//now, copy the first *d_numElements from d_elements to h_elements
//1. possibility
starttimer(first);
cudaMemcpyAsync(h_numElements, d_numElements, sizeof(int), cudaMemcpyDeviceToHost, stream); CUERR;
cudaStreamSynchronize(stream); CUERR;
cudaMemcpyAsync(h_elements, d_elements, sizeof(int) * (*h_numElements), cudaMemcpyDeviceToHost, stream); CUERR;
cudaStreamSynchronize(stream); CUERR;
stoptimer(first);

//2. possibility
starttimer(second);
callMemcpyKernel(h_elements, d_elements, d_numElements, maxNumElements, stream); CUERR;
cudaStreamSynchronize(stream); CUERR;
stoptimer(second);

}
``````

The output produced on a Pascal card:

``````first: 0.000339691 s
second: 0.000484351 s
``````

I was surprised since the amount of memory transferred should be the same and both transfers use PCIe.
The profiler shows that not only is 4 MB transferred to the host, but 1.5 MB is transferred to the device, causing the difference in runtime compared to the memory solution.

``````    dram__read_bytes  Mbyte 4,20
dram__write_bytes Mbyte 1,64
dram__write_bytes_per_sec Gbyte/second 3,57
``````

Where do these 1.5 MB come from?

Is there a better way to solve the above problem without requiring more than one sync step?

## Galaksion.com: test our engine to efficiently monetize your presence on the web | Proxies123.com

Galaksion at Affiliate Summit East 2017: Special Offers for Visitors

Galaksion is a European network that collaborates with publishers around the world. Our mission is to make your monetization efforts as smooth, transparent and successful as possible. Join Galaksion to test our features and benefits in practice.

For Webmasters
– high eCPM rates
– detailed statistics in real time
– our wide range of offers, there are more than 9k campaigns in progress at any time
– a variety of formats to match your site or blog, such as banners and ibanners, push-ups, tabunders, popups, popunders and video for sure
– daily, weekly and monthly payments, as well as Net 0, Net 15 and Net 30
– numerous payment methods available, such as Payoneer, Paxum, PayPal, Skrill, WebMoney and bank transfer

– both CPA and CPM
– Advanced targeting to reach your audience: cities and geographies, devices and operating systems, WiFi and operators, source categories and frequency limitation
– fraud and bot protection
– transparency and optimization assistance

Finally, it is worth mentioning that today we work with all high-demand verticals: dating, gambling, gaming, app installs, mobile content, e-commerce, and finance.

Galaksion is a European network that collaborates with publishers around the world. Our mission is to make your monetization efforts as smooth, transparent and successful as possible. Join Galaksion to test our features and benefits in practice.

For Webmasters
– high eCPM rates
– detailed statistics in real time
– our wide range of offers, there are more than 9k campaigns in progress at any time
– a variety of formats to match your site or blog, such as banners and ibanners, push-ups, tabunders, popups, popunders and video for sure
– daily, weekly and monthly payments, as well as Net 0, Net 15 and Net 30
– numerous payment methods available, such as Payoneer, Paxum, PayPal, Skrill, WebMoney and bank transfer

– both CPA and CPM
– Advanced targeting to reach your audience: cities and geographies, devices and operating systems, WiFi and operators, source categories and frequency limitation
– fraud and bot protection
– transparency and optimization assistance

Finally, it's worth mentioning that today we work with all high-demand verticals: dating, gambling, gaming, app installs, mobile content, e-commerce, and finance.

__________________

This post is for those who will attend the 2017 Affiliate Summit East Conference and Trade Show at New Your in one week.

We are pleased to announce that our team will participate in this event as professional visitors.

If you are interested in trying Galaksion as your advertising engine, Kamran, our product owner, will be happy to meet you in person in New York to introduce you to our new solution, the Galaksion self-service platform for publishers, advertisers and affiliates. . You will also be happy to offer some special conditions and benefits that we are going to provide to the first users of our updated solution.

Please don't hesitate to contact him!

Kamran
Product owner
kamran [at] galaksion.com
Skype: kamran_Galaksion

## apps – How to find apps more efficiently on Android 9

I am running Android 9 on a Samsung Galaxy S8 edge. Ever since I updated the phones, searching for apps has been … well it's really not something I can understand. After moving to the "All apps" screen, I try to use the search bar of the search engine, but it is not doing what I want it to do. I want to search for an app on my phone, but instead, search multiple apps on my phone for instances of my text input.

Is there another way to find an app on my phone without making folders for everything or scroll to it in "All apps" every time?

## How to use PowerShell variables efficiently in a function?

I know the differences they call variable `\$var` vs `\$script:var` within a function I like this:

``````function test()
{
\$var = 1
\$script:var = 2
}

test

if (\$script:var -eq \$var)
{
Write-Host "\$var = \$script:var"
}
``````

But I have to write everywhere `\$script:var` not make mistakes? Is there another good way to achieve the same result? Thank you!

## ios appstore: what are some ways to copy and paste more efficiently in iOS?

If I am going to do a Google research on a question I have, I would like to copy a lot of links that I find and have everyone enter some sort of list somewhere. Then, when I have gathered enough links, I can paste them into a document somewhere. That way, I don't have to change tediously between two applications, constantly.

Ideally, beyond the links, there would be web page titles, and some descriptions of them as well.

What are some ways to do this? The Copied application has decent functionality related to this, but limited. Could you take it out with shortcuts?

## Algorithms – Efficiently find the minimum cost path of an AVL tree

It seems that in a full AVL tree, the left edge is always the path of minimum cost. For example, take the following complete AVL tree:

The minimum cost route would be `8-6-5`. However, this is not the case with other AVL trees. Take the previous tree with an additional `4` inserted:

Here the minimum cost route would be `8-6-7` rather than `8-6-5-4`.

What is the most efficient algorithm to find the minimum cost path in any AVL tree? Given the characteristics of AVL trees, is this algorithm faster than it would be for a standard BST?

## c ++ – Wanting to create Space Invaders as the Enemy movement. How to do it efficiently

Something @Krangogram has alluded to in its response is that individual invaders do not move alone, so one approach to efficiently move invaders is to treat them as a single invader formation and move the formation as a whole. I could define this in a similar way to:

``````class Invader {
// x,y offset within the formation. Each invader should have a unique offset from
// (0,0), the top left, to (FORMATION_WIDTH-1,FORMATION_HEIGHT-1), the bottom right.
int offsetX, offsetY;

// Whether this invader is alive.
bool isAlive;
};

// The location of the top left invader in the formation.
int x, y;
};
``````

Since the location of each invader is defined as a displacement of the formation as a whole, you can move each invader at the same time with `invaderFormation->x += DELTA` or `invaderFormation->y += DELTA`.

As to how to determine if invaders can continue moving in one direction or if they have reached the limit, with 50 invaders it is probably safe to list them all without encountering any performance problems. But maybe in the future the screen will be larger / displacement and there will be a million invaders, so let's see how you can optimize this verification.

The first thing you should notice about this problem is that the only invaders that really matter to you are the ones that are on the sides of the formation. Those in the middle will never touch an edge while there is an invader next to the formation. But wait, you don't even need to find a way to track and list those on the sides, because another thing to keep in mind about this problem is that no matter what invader is on the side, the only thing that matters is that there is minus one

Then you could define your invader formation closer to something like this:

``````class Invader {
int offsetY;
bool isAlive;

// The column of the formation this invader is in. The invader's offset within the
// formation can now be defined as (column.offsetX, offsetY). It's fine to keep offsetX
// in this class too though.
};
// offsetX is also in the index into InvaderFormation::columns
int offsetX;

// How many invaders are still alive in this column
int aliveCount;
};
// All of the columns...
std::vector columns;

// ...And more specifically, shortcuts to the leftmost and rightmost columns
// that have at least 1 living invader

int x, y;
};
``````

Now you can know if the invader training has reached the edge with a single check:

`invaderFormation->x + invaderFormation->leftmostColumn->offsetX == LEFT_EDGE` or

`invaderFormation->x + invaderFormation->rightmostColumn->offsetX == RIGHT_EDGE`.

But you will need to update these `leftmostColumn` Y `rightmostColumn` pointers every time an invader dies to keep it updated:

``````// When an invader is killed:

// Assuming there is still at least 1 living invader in the formation:
// All invaders are dead in this column, so check if the formation needs to point to
// a new leftmost/rightmost column
// Look for a new leftmost column, starting from the current one
// You can stop at the rightmost column because you know there's no invaders still
// alive in any columns past that.