buttons – What icon intuitively represents making comparisons?

I want to make an app which involves repeatedly giving users two options and having them select the one they like better. Is there any icon or symbol which would intuitively represent this concept, which I could place next to the word “compare” on a navigation button? I’m wracking my brain and can’t come up with anything, which suggests that there may not be a natural icon choice…

plotting – ListPlot and comparisons between lists

Here is an example with made up data:

Clear(y, z, k)
x = Range(20);
{y, z, k} = RandomInteger({-10, 10}, {3, 20});

ListPlot(
  MapThread(Style({#1, #2}, If(#3 > #4, Red, Black)) &, {x, y, z, k}),
  PlotRange -> All,
  PlotStyle -> PointSize(0.02)
)

formatted points


For your second part (“Additional issue: for the first observations, the list k is empty, so I want to plot a red dot for such observations.”), you should really provide a sample of your data. Any answer would depend on its precise structure.

Algorithms – Why do we use the number of comparisons to measure time complexity when the comparison is fairly cheap?

For sure. In practice, however, this is rare: the sorting algorithms that we normally use or analyze in practice carry out at most a constant number of other operations per comparison. So this is not a problem for the sorting algorithms that actually interest us.

There are also situations in which we use sorting algorithms where each comparison is much slower than the other operations. When you sort integers, a comparison may be slower than the other operations because conditional branches are very slow on modern processors (they empty the pipeline). If you sort complex objects using a custom comparison function, many instructions may be required for each comparison.

Ultimately, asymptotic analysis is only a theoretical model. It is a simplified model in which many considerations are left out. Such a simplification will necessarily ignore many factors. As long as these factors are unimportant, this can be useful because you can simplify the problem so much that you can analyze it and gain insight. However, if, as always, it turns out that one of these factors is important and you have not included it in your model, the model will lead to misleading results – this applies to all models and is not limited to sorting or restricting algorithmic analysis.

User Behavior – Conjoint Analysis: Show all combinations except bad comparisons OR Show good comparisons but not all combinations?

For a project, I'm doing a collaborative analysis to determine which attributes users find more important for an ad-free subscription to a website. The analysis consists of 3 attributes with 3 levels. Some combinations are invalid (e.g. offering an ad-free website for free), leaving 12 combinations. To save costs, I did 3 surveys myself: Each survey contains 4 questions with 3 different combinations of attribute levels and the option "None of these". The idea behind this is that I can't randomize the combinations between questions without coding (just randomize within one question), but I think that a sufficiently large sample size of users who only fill out 1 in 3 should compensate for this.

The problem I'm encountering now is this: To show users all possible combinations, some of the comparisons within a question are not the same, e.g. Same price, but longer free trial period (this should be resolved by 3 surveys, but I'm not 100% sure if that's what I read online). However, to enable the same comparisons to be made across all questions and surveys, some of the attribute combinations are either not displayed or are only displayed in a survey. Both methods can lead to distorted data.

TL; DR: Should I give users all the combination options except for unequal comparisons or give them the same comparisons, but not show users all the combination options?

Proofing techniques – comparison tree to get a minimum number of comparisons to merge sorted lists

Accept A is a sorted list of length n and B is a sorted list of length 2. I'm asked to find the minimum number of comparisons that an algorithm has to perform to bring these lists together. I also get an analysis of it that does not use a comparison tree, but argues combinatorially that the number of leaves must be $ binom {n + 1} {2} $ and that the height $ h $ must satisfy $ 2 ^ h geq binom {n + 1} {2} $,

However, I get a different answer when I actually draw the comparison tree. In my view, the comparison tree has two branches, one of which corresponds a1 < b1 and one accordingly a1 > b1, If you follow the right branch again on the right, this corresponds to a1 > b1 and a1 > b2 and at that point the tree ends in a leaf. No further comparisons are required, since the comparison can simply be used to carry out any comparison bs in the merge list and save the rest of the as in after.

That is not the interesting part, but hopefully it is a simple consideration that makes it clear how I am going to do it. The left branch where you get a1 < b1 and a2 < b1 and and an < b1 corresponds to going left and left and ... and going left. There are n Compare to this branch. In fact, I think you can get one more if instead an < b1 At the end you go to the right and say an > b1 and then an < b2 (or an > b2 since it doesn't matter at this point, both sides are one sheet). So the tree is exactly the height n+1, Right? Or am I wrong?

Runtime Analysis – How can merging two sorted arrays of N elements in any case require at least 2N – 1 comparisons?

The HW question on page 362 of Data structures and algorithms in C ++: fourth edition by Mark Allen Weiss reads as follows:

Prove that two sorted arrays are merged by N Item requires at least 2 * N * – 1 comparisons. You have to show that if two items in the merged lists are consecutive and from different lists, they have to be compared

If we try to find the lower limit, the number of comparisons would not be the same Nnot 2 * N * – 1? When the largest element is an array ON is smaller than the smallest element in an array B then you would have to make at most N comparisons, since at least from How Elements are inserted into the merged array, then the remaining elements in B can simply be appended to the merged array.

The lower limit must apply to all options N and any possible combination of elements in both arrays, right? 2 * N * – 1 seems to be more like that upper limit since there is no way, there can be more comparisons.

Note: I am not asking for an answer to the HW question itself, since I know that it is out of date. I am confused by the implicit claim that makes the lower limit question

dnd 5e – Character class and race comparisons between Warhammer 40k and D & D 5e

I play Dnd 5e with a group of friends and we have been Dnd players for years, but one of our friends has been obsessed with Warhammer for several years. We decided to give it a try, especially the Warhammer 40k RPG.

It seems to be a fairly complex game. I think the problem is that none of us know anyone who has ever played it firsthand. I watched YouTube videos, the obsessed friend made a small RPG game, two members of the group balked at the latest "rule book" and tried games at night, and occasionally five of us tried to play together. Unfortunately, every time it's a comedy with mistakes, because we decide that the rules work differently each time and it never seems right. But in any case, everything is fun.

Here's my question: The races seem to be extremely different between D&D and the Warhammer 40k RPG game, and I'm struggling to find similarities between the classes. Does anyone know how to compare any races or classes between the two games? For example, would a Space Marine in the Warhammer 40k RPG game be something like a paladin in dnd 5e?

Does somebody know?

How can you predict the number of comparisons QuickSort will make if you know the percentage by which the array is pre-sorted?

I have found that when you use a logarithmic scale, the number of comparisons made by a naive implementation of QuickSort is related to the percentage of items already sorted:
Curly bracket-shaped curve
How can this curve be described mathematically in the form of a curly bracket (the red curve represents the behavior of the c ++ "sort" function and appears to be much more complicated)? If exactly possible, you can accurately predict how many comparisons QuickSort would make by simply traversing the array, counting the number of elements for which array (i) <array (i + 1), and inserting that number into a Formula. I tried to find a mathematical formula that approximates using a genetic algorithm. In the end I found the following:

f(n,s)=exp((ln(n)+ln(ln(n)))*1.05+(ln(n)-ln(ln(n)))*0.83*abs(2.38854*pow(s,7)-0.284258*pow(s,6)-1.87104*pow(s,5)+0.372637*pow(s,4)+0.167242*pow(s,3)-0.0884977*pow(s,2)+0.315119*s))

Here it says & # 39; f & # 39; for the number of comparisons made by QuickSort, & # 39; n & # 39; for the number of elements in the array and & # 39; s & # 39; for the proportion of elements that are already sorted: -1 if the array is in reverse order, 1 if it is already sorted, and approximately 0 if it is mixed randomly.

Can you think of a better formula?

java sorting algorithms – find comparisons and motions

    package faculdade;

import java.util.Random;

public class Ordenacao {

    public static long comparacao;

    public static long movimentacao;

    public static void main(String() args) {
        int() vetor = new int(1000);
        fill(vetor);
        System.out.println("Vetor criado:");
        // show(vetor);
        // tempo inicial
        long tempoInicial = System.currentTimeMillis();
        //selectionSort(vetor);
        bubbleSort(vetor);
        //insertionSort(vetor);
        //quickSort(vetor, 0, vetor.length - 1);
        // tempo final
        long tempoFinal = System.currentTimeMillis();

        System.out.println("Executado em = " + (tempoFinal - tempoInicial) + " ms");
        System.out.println("n Comparações: " + comparacao + " Movimentaçoes: " + movimentacao);
        System.out.println("Finalizado.");


    }

    public static void selectionSort(int() vetor) {
        comparacao = 0;
        movimentacao = 0;
        for (int i = 0; i < vetor.length - 1; i++) {
            int menor = i;
            for (int j = i + 1; j < vetor.length; j++) {
                comparacao++;
                if (vetor(j) < vetor(menor)) {
                    comparacao++;
                    menor = j;
                }

            }
            swap(vetor, i, menor);
            // show(vetor);
            movimentacao++;
        }
    }

    public static void bubbleSort(int() vetor) {
        movimentacao = 0;
        comparacao = 0;
        for (int i = vetor.length; i >= 1; i--) {
            for (int j = 1; j < i; j++) {
                if (vetor(j - 1) > vetor(j)) {
                    swap(vetor, j, j-1);
                    comparacao++;
                }
            }
            show(vetor);
        }
    }

    public static void insertionSort(int() vetor) {
        comparacao = 0;
        movimentacao = 0;
        for (int i = 1; i < vetor.length; i++) {
            int current = vetor(i);
            int j = i - 1;
            while (j >= 0 && current < vetor(j)) {
                vetor(j + 1) = vetor(j);
                j--;
                comparacao++;
            }
            // at this point we've exited, so j is either -1
            // or it's at the first element where current >= a(j)
            vetor(j + 1) = current;
        }

            show(vetor);
            movimentacao++;
    }

    public static void quickSort(int vetor(), int esquerda, int direita) {

        int esq = esquerda;
        int dir = direita;
        int pivo = vetor((esq + dir) / 2);
        int troca;

        while (esq <= dir) {
            while (vetor(esq) < pivo) {
                esq = esq + 1;

            }
            while (vetor(dir) > pivo) {
                dir = dir - 1;

            }
            if (esq <= dir) {
                troca = vetor(esq);
                vetor(esq) = vetor(dir);
                vetor(dir) = troca;
                esq = esq + 1;
                dir = dir - 1;
                movimentacao++;

            }
            comparacao++;
        }
        if (dir > esquerda) {
            quickSort(vetor, esquerda, dir);

        }

        if (esq < direita) {
            quickSort(vetor, esq, direita);

        }


    }

    public static void fill(int() vetor) {
        Random r = new Random();
        for (int i = 0; i < vetor.length; i++) {
            vetor(i) = r.nextInt(100);
        }
    }

    public static void show(int() vetor) {
        for (int i = 0; i < vetor.length; i++) {
            System.out.print(vetor(i) + " ");
        }
        System.out.println("");
    }

    public static void swap(int() vetor, int a, int b) {
        int aux = vetor(a);
        vetor(a) = vetor(b);
        vetor(b) = aux;
        movimentacao++;

    }

}

At runtime, the comparison number corresponds to the train number. I think that's wrong