Can anyone help me explain this full permutation algorithm?

Updated on Financial 2024-08-11
5 answers
  1. Anonymous users2024-02-15

    Here's how it works:

    First, one number is selected from i numbers as the first number, and the rest of the i-1 numbers are arranged in full order, and all all full permutations are generated after i times are executed.

    The practice of making the remaining I-1 digits in full arrangement can be modelled on the practice of I-digits.

    for(j = i; j < n; j++)

    swap(list[i],list[j],temp);Make the jth digit the first.

    perm(list,i+1,n);

    swap(list[i],list[j],temp);Swap the jth digit back to its original position, and prepare to use the j+1 as the first one.

    It is recommended that you modify the function to the following form and observe it for yourself.

    void perm(char *list, int i, int n){

    int j,temp;

    for(j = 0; j < n; j++)

    coutfor(j = 0; j < n; j++)

    coutfor(j = i; j < n; j++)

    swap(list[i],list[j],temp);

    perm(list,i+1,n);

    swap(list[i],list[j],temp);

  2. Anonymous users2024-02-14

    Does the hanoi program know? It's the Tower of Hanoi.

    Recursive calls that are applied.

    Principle: Move n things from the first pillar to the third column.

    If someone can move the n-1 block from the first pillar to the second pillar, I just need to move the bottom one directly to the third one, and then that person will move the n-1 block from the second pillar to the third pillar.

    Then it becomes a matter of transporting the n-1 block.

    The same goes for the problem that can be degraded to the n-2 block.

    Until the n-(n-1) block, i.e. put a piece of the problem of handling.

    Got it? This is called recursively, constantly calling itself.

  3. Anonymous users2024-02-13

    A 60% return rate means that there is always a loss of money.

    But if we lose money, some of them still win, it depends on how we buy it.

    Winning the lottery is actually not difficult, it will be difficult in the middle of the period, so we have to win back what we lost before, and we have to pay both.

    It depends on how we place the order, and the selection of the number also requires some skill.

    the reason for blindly looking for it is actually that i don't know how to read the number casually under the thank you take my peng friend 27-83-773 TO PLAY PICKING IS VERY GOOD AND IT HURTS OTHERS VERY WELL T A SPACE THERE ARE A LOT OF PLAY PICKING AND KILLING NUMBERS TO EXPLAIN.

  4. Anonymous users2024-02-12

    Take the keyword sequence ( ) as an example, write the state of the keyword sequence at the end of each sort that executes the following sorting algorithm.

    Direct Insert Sort ( Hill Sort ( Bubbling Sort ( Quick Sort.

    Direct Selection Sort ( Heap Sort ( Merge Sort ( Cardinal Sort.

    Which of the above methods is stable sorting? What are the non-stable sorts? Try to give an example of an unstable sort.

    A ( Insert sort: (square brackets indicate unordered areas).

    Initial state: [.]

    First trip [second trip [

    The third trip [the fourth trip [

    Fifth trip [sixth trip [

    Seventh Trip [Eighth Trip [.]

    Ninth trip) Hill sort (in increments of ).

    Initial state: First trip.

    Second Trip, Third Trip.

    Bubbling sort (square brackets are unordered areas).

    Initial state of argument [

    First trip [second trip [

    The third trip [the fourth trip [

    Fifth [Sixth Round] Quick Sort (square brackets indicate unordered zones, layers indicate the number of layers corresponding to the recursive tree).

    Initial state [second layer[

    Level 3 [Level 4]

    Layer 5 [Layer 6] selects the sort directly (square brackets are unordered areas).

    Initial state: First trip.

    Second Trip, Third Trip.

    Fourth Trip [Fifth Trip [.]

    Sixth Trip [Seventh Trip [.]

    The eighth trip [ninth trip] heap sorting (by drawing two * trees, you can get the sorting result step by step).

    Initial state [to establish the initial heap [

    First sort rebuild heap [.]

    The second sort rebuilds the heap [.]

    The third sort rebuilds the heap [

    The fourth sort rebuilds the heap [

    The fifth sort rebuilds the heap [

    The sixth sort rebuilds the heap [

    The seventh sort rebuilds the heap [.]

    The eighth sort rebuilds the heap [.]

    The heap is rebuilt by the ninth sort.

    Merge sorting (for ease of representation, use bottom-up merge square brackets as an ordered area).

    Initial state: First trip.

    Second Trip, Third Trip.

    Fourth trip [cardinal sorting (square brackets indicate that a box has a total of boxes, and the box number is from to ).

    Initial state: First trip.

    The second congratulatory trip [

    The third trip [In the above sorting method, direct insert sorting Bubbling sorting Merge sorting and cardinal sorting are stable, other sorting algorithms are unstable The current Zen stove beam example is as follows: The difference is indicated by an * sign.

    Hill sort [.]

    Quick Sort [.]

    Directly select Sort [.]

    lishixinzhi/article/program/sjjg/201311/23531

  5. Anonymous users2024-02-11

    Summary. Using the simple choice sorting algorithm, write out the result of each sort of the following sequence: 44 30 -20 0 18 88 76 12

    Okay, okay? Fast!!! Hurry, hurry.

Related questions
9 answers2024-08-11

Late college and clearance applicants can apply for accommodation. >>>More

9 answers2024-08-11

Invalid page load protection (object sender, eventargs for five). >>>More

5 answers2024-08-11

The identifier for a CSS filter is "filter".

The syntax is: filter:filtername(parameters)parameters are the parameters that represent the properties of each filter. >>>More

3 answers2024-08-11

Good morning! I am very honored to have the opportunity to do this interview. >>>More

6 answers2024-08-11

From Ji Liuqi Ming Ji Beiluo, describing the tragic situation of Yuan Chonghuan when he was tortured by Ling Chi. The North and South Town Fu Division is a special agency under Jinyiwei, of which the North Town Fu Division is in charge of the edict prison. Many people in the academic community have expressed doubts about the authenticity of this description.