From fce9b86d9326e22ae982163d6368197b5cd65823 Mon Sep 17 00:00:00 2001 From: jkangEDC Date: Tue, 10 Dec 2024 18:58:28 -0500 Subject: [PATCH] A11y-U8 fix lists - done U8 --- .../1-counting-trees.es.html | 6 +++--- .../1-counting-trees.html | 7 +++++-- .../2-writing-recursive-reporters.es.html | 5 +++-- .../2-writing-recursive-reporters.html | 9 +++++---- .../3-subsets/2-subsets.html | 7 ++++--- .../2-generalizing-the-map-pattern.html | 10 +++++----- .../3-even-number-filter.es.html | 7 ++++--- .../3-even-number-filter.html | 6 +++--- .../2-pascal-efficiency.es.html | 11 ++++++----- .../2-pascal-efficiency.html | 14 +++++++------- .../1-sorting-a-list.es.html | 19 ++++++++++--------- .../1-sorting-a-list.html | 15 ++++++++------- .../2-selection-sort.html | 4 ++-- .../3-partition-sort.html | 13 +++++++------ 14 files changed, 72 insertions(+), 61 deletions(-) diff --git a/cur/programming/8-recursive-reporters/1-recursive-reporters/1-counting-trees.es.html b/cur/programming/8-recursive-reporters/1-recursive-reporters/1-counting-trees.es.html index e37eea4ac9..fd002c952d 100644 --- a/cur/programming/8-recursive-reporters/1-recursive-reporters/1-counting-trees.es.html +++ b/cur/programming/8-recursive-reporters/1-recursive-reporters/1-counting-trees.es.html @@ -18,7 +18,7 @@

Contar árboles

imagen de árbol fractal
  1. - Abre tu proyecto "U7L1-Árbol". ¿Cuántos segmentos de línea hay en un árbol de cada nivel? Completa esta tabla. (Puedes contar a simple vista o usar Snap! para contar).
  2. + Abre tu proyecto "U7L1-Árbol". ¿Cuántos segmentos de línea hay en un árbol de cada nivel? Completa esta tabla. (Puedes contar a simple vista o usar Snap! para contar). @@ -54,8 +54,8 @@

    Contar árboles

  3. Habla con tu compañero¿Cómo se compara la cantidad de segmentos en un nivel con la cantidad de segmentos en el nivel anterior?
  4. Construya un bloque que tenga un número de árbol como entrada y la cantidad de segmentos en ese nivel como salida -
  5. - segmentos de árbol (7) reporta 127
    + segmentos de árbol (7) reporta 127
    + diff --git a/cur/programming/8-recursive-reporters/1-recursive-reporters/1-counting-trees.html b/cur/programming/8-recursive-reporters/1-recursive-reporters/1-counting-trees.html index 2d66f758d5..408c738732 100644 --- a/cur/programming/8-recursive-reporters/1-recursive-reporters/1-counting-trees.html +++ b/cur/programming/8-recursive-reporters/1-recursive-reporters/1-counting-trees.html @@ -56,8 +56,9 @@

    Counting Trees

    nivel
  6. Talk with Your Partner How does the number of segments in one level compare to the number of segments in the previous level?
  7. -
  8. Build a block whose input is a tree number and whose output is the number of segments in that level:
  9. - segments in tree (7) reporting 127
    +
  10. Build a block whose input is a tree number and whose output is the number of segments in that level: + segments in tree (7) reporting 127
    +
@@ -115,6 +116,8 @@

Counting Trees

triangles in level (5) fractal reporting 121
  • "U8L1-Recursive-Reporters"Save your work as U8L1-Recursive-Reporters
  • + +
    Do we need this commented out content? --MF, 6/22/20
    diff --git a/cur/programming/8-recursive-reporters/1-recursive-reporters/2-writing-recursive-reporters.es.html b/cur/programming/8-recursive-reporters/1-recursive-reporters/2-writing-recursive-reporters.es.html index 213cc1d34c..a075b0196e 100644 --- a/cur/programming/8-recursive-reporters/1-recursive-reporters/2-writing-recursive-reporters.es.html +++ b/cur/programming/8-recursive-reporters/1-recursive-reporters/2-writing-recursive-reporters.es.html @@ -18,8 +18,9 @@

    Escribir reporteros recursivos

    La función factorial n! se define como el producto de los números enteros de 1 a n.

      -
    1. El valor de 9! es 362.880. Encuentra el valor de 10!.
    2. -
      No olvides el consejo de Betty: ¡Los casos base son importantes!
      +
    3. El valor de 9! es 362.880. Encuentra el valor de 10!. +
      No olvides el consejo de Betty: ¡Los casos base son importantes!
      +
    4. Describe la relación entre 37! y 36!.
    5. Usa estas ideas para construir un factorial bloque usando un reportero recursivo.
    diff --git a/cur/programming/8-recursive-reporters/1-recursive-reporters/2-writing-recursive-reporters.html b/cur/programming/8-recursive-reporters/1-recursive-reporters/2-writing-recursive-reporters.html index d4218d89af..cf2c272dc1 100644 --- a/cur/programming/8-recursive-reporters/1-recursive-reporters/2-writing-recursive-reporters.html +++ b/cur/programming/8-recursive-reporters/1-recursive-reporters/2-writing-recursive-reporters.html @@ -38,8 +38,9 @@

    Writing Recursive Reporters

    The factorial function, n!, is defined to be the product of the integers from 1 to n.

      -
    1. The value of 9! is 362,880. Find the value of 10!.
    2. -
      Don't forget Betty's advice: base cases are important!
      +
    3. The value of 9! is 362,880. Find the value of 10!. +
      Don't forget Betty's advice: base cases are important!
      +
    4. Describe the relationship between 37! and 36!.
    5. Use these ideas to build a factorial block using a recursive reporter.
    6. @@ -68,8 +69,8 @@

      Writing Recursive Reporters

      Word processing programs count the number of words and letters in documents. One way to count the number of letters in a phrase is to use a recursive reporter.

      +
      Can we use a phrase that is more familiar to the high schooler's experience? --MF Such as? These are the first words of the Declaration of Independence. I do not want to use the Pledge of Allegiance. -BK
        -
        Can we use a phrase that is more familiar to the high schooler's experience? --MF Such as? These are the first words of the Declaration of Independence. I do not want to use the Pledge of Allegiance. -BK
      1. The phrase "in the course of human events" has 24 letters. How many letters are there in the phrase "When in the course of human events"?
      2. Recursion always needs a base case to stop the script from calling itself forever. What sort of base case might we use for this situation?
      3. @@ -82,6 +83,7 @@

        Writing Recursive Reporters

        Create your own version of the join words block. This block inputs a list and outputs a string sentence, with spaces:
        my join words(list{We, the. People, of, the, United, States}) reporting -We the People of the United States
      4. +

      Again, I am concerned with teaching recursion as "a more complicated way to do what you already know how to do." I don't think my join words works because it can be done so much more quickly non-recursively by using combine. I do like letter count though because it does simplify the code. --MF
      @@ -90,7 +92,6 @@

      Writing Recursive Reporters

      I need a suggestion to change this. Or is the suggestion to delete the join-words task? Any other things to replace it? Also we should use "empty?" when possible, not "length = 0". -BK

      -

    The list operations all but first of and in front of are frequently used in recursive reporters.

    diff --git a/cur/programming/8-recursive-reporters/3-subsets/2-subsets.html b/cur/programming/8-recursive-reporters/3-subsets/2-subsets.html index c0b85dc3d7..1449030fec 100644 --- a/cur/programming/8-recursive-reporters/3-subsets/2-subsets.html +++ b/cur/programming/8-recursive-reporters/3-subsets/2-subsets.html @@ -20,9 +20,10 @@

    Listing the Subsets

    1. Write down all the subsets of {Apple, Orange, Banana}. How many are there?
    2. -
    3. Write down all the subsets of {Pretzel, Apple, Orange, Banana}. Try to do this with as little work as possible.
    4. -
      Add a question that gets at how 2 is just an augmentation of 1. --MF, 6/17/20 - Talk with Your PartnerDescribe how you did it.
      +
    5. Write down all the subsets of {Pretzel, Apple, Orange, Banana}. Try to do this with as little work as possible. +
      Add a question that gets at how 2 is just an augmentation of 1. --MF, 6/17/20 + Talk with Your PartnerDescribe how you did it.
      +
    6. MARY Note to self: this is hard. for example, in base case (subsets of empty list), you have to report a list containing the empty list. Add a question that gets at the base case.
      diff --git a/cur/programming/8-recursive-reporters/4-building-higher-order-functions/2-generalizing-the-map-pattern.html b/cur/programming/8-recursive-reporters/4-building-higher-order-functions/2-generalizing-the-map-pattern.html index f324026645..e8e34fe1a5 100755 --- a/cur/programming/8-recursive-reporters/4-building-higher-order-functions/2-generalizing-the-map-pattern.html +++ b/cur/programming/8-recursive-reporters/4-building-higher-order-functions/2-generalizing-the-map-pattern.html @@ -69,12 +69,12 @@

      Generalizing the Map Pattern

      Occasionally a problem comes up that doesn't exactly match the map pattern, but comes close. In that case, you can't use map, but your understanding of the pattern still helps. Here's an example:
      odd numbered items of (data){if(empty? (data)){report(empty list)} else{if(empty? (all but first of (data))){report(data)} else{report((item(1) of (data)) in front of (odd numbered items of(all but first of (all but first of (data)))))}}}
      Fill in the blanks: This script is just like the map pattern except for ______ (base case) and _____ (in the recursive case). +
      +

      Shouldn't pairup come before odd numbered? --MF, 9/26/18

      +

      BH:that's ok, but take ALL the text from #2 and move it here with this. --MF, 6/17/20

      +

      The fill in the blank is not something we’ve seen before in the curriculum. Seems out of place. --Michelle via MF, 4/22/22

      • I don't really agree, but I'm open to discuss. --MF, 4/22/22

      +
    7. -
      -

      Shouldn't pairup come before odd numbered? --MF, 9/26/18

      -

      BH:that's ok, but take ALL the text from #2 and move it here with this. --MF, 6/17/20

      -

      The fill in the blank is not something we’ve seen before in the curriculum. Seems out of place. --Michelle via MF, 4/22/22

      • I don't really agree, but I'm open to discuss. --MF, 4/22/22

      -
    8. Build the pairup block:
      pairup(list{now, here, after, math}), reporting {nowhere, hereafter, aftermath} diff --git a/cur/programming/8-recursive-reporters/4-building-higher-order-functions/3-even-number-filter.es.html b/cur/programming/8-recursive-reporters/4-building-higher-order-functions/3-even-number-filter.es.html index 2588aad874..0ad82b4dc6 100644 --- a/cur/programming/8-recursive-reporters/4-building-higher-order-functions/3-even-number-filter.es.html +++ b/cur/programming/8-recursive-reporters/4-building-higher-order-functions/3-even-number-filter.es.html @@ -24,8 +24,8 @@

      Números pares y mantener

      Haz los siguientes ejercicios usando recursividad, no funciones de orden superior.

        -
        Intenta modificar el código de evens.
        -
      1. +
      2. +
        Intenta modificar el código de evens.
        Escriba un bloque termina en-a que tome una lista de palabras como entrada y reporte una lista de esas palabras de la entrada cuya última letra es a.
        termina en-a(lista{la, lluvia, en, España, es, en, Europa}), reporta {la, lluvia, Europa}Números pares y mantener
      -
      Crear mapear, mantener y combinar es un gran logro. Sin embargo, cada uno de estos bloques solo generaliza un patrón simple. Algunas personas piensan ni siquiera aprender a usar las funciones de orden superior son en la universidad, ni mucho menos a construirlasn. 🎉 ¡Enhorabuena! 👏 ¡Completaste La belleza y alegría de la Informática (BJC)! 🏆

      +
      +

      Crear mapear, mantener y combinar es un gran logro. Sin embargo, cada uno de estos bloques solo generaliza un patrón simple. Algunas personas piensan ni siquiera aprender a usar las funciones de orden superior son en la universidad, ni mucho menos a construirlasn. 🎉 ¡Enhorabuena! 👏 ¡Completaste La belleza y alegría de la Informática (BJC)! 🏆

      diff --git a/cur/programming/8-recursive-reporters/4-building-higher-order-functions/3-even-number-filter.html b/cur/programming/8-recursive-reporters/4-building-higher-order-functions/3-even-number-filter.html index bc4689a748..173b2e7a22 100755 --- a/cur/programming/8-recursive-reporters/4-building-higher-order-functions/3-even-number-filter.html +++ b/cur/programming/8-recursive-reporters/4-building-higher-order-functions/3-even-number-filter.html @@ -33,10 +33,10 @@

      Even Numbers and Keep

      Fundamental Concern: The pedagogy here is killing me. Here draw a square with recursion or functionally. WHY?!?!? Don't torture students. Give them a problem where this technique really matters. --MF, 9/26/18

      Do the following exercises using recursion, not higher order functions.

        -
        Try modifying the code from evens.
      1. - Write a block ends-e that takes a list of words as input, and reports a list of those words from the input whose last letter is e.
        - ends-e(list{the, rain, in, Spain, is, in, Europe}), reporting {the, Europe} +
        Try modifying the code from evens.
        + Write a block ends-e that takes a list of words as input, and reports a list of those words from the input whose last letter is e.
        + ends-e(list{the, rain, in, Spain, is, in, Europe}), reporting {the, Europe}
      2. Write a block numbers that takes a list of mixed words and numbers as input, and reports a list of just the numbers from the input list.
        diff --git a/cur/programming/8-recursive-reporters/optional-project-pascals-triangle/2-pascal-efficiency.es.html b/cur/programming/8-recursive-reporters/optional-project-pascals-triangle/2-pascal-efficiency.es.html index fa457e588d..50103682ce 100644 --- a/cur/programming/8-recursive-reporters/optional-project-pascals-triangle/2-pascal-efficiency.es.html +++ b/cur/programming/8-recursive-reporters/optional-project-pascals-triangle/2-pascal-efficiency.es.html @@ -17,8 +17,8 @@

        El triángulo de Pascal y la eficiencia

        Estás a punto de averiguar cuántas llamadas recursivas se necesitan para calcular un valor en el triángulo de Pascal.

        +
        ¿Qué podrías insertar dentro del bloque para rastrear esto?
          -
          ¿Qué podrías insertar dentro del bloque para rastrear esto?
        1. Modifica tu bloque pascal para llevar la cuenta de cuántas veces se ejecuta el bloque.
        2. ¿Cuántas veces se llama al bloque pascal al calcular pascal(14)(5)?
        3. ¿Qué ocurre cuando llamas a pascal(20)(5)?
        4. @@ -29,12 +29,13 @@

          El triángulo de Pascal y la eficiencia

          Muchas de las llamadas recursivas son redundantes. Por ejemplo: pascal(14)(5) llamará a pascal(10)(3) muchas veces, pidiendo la misma información.

          +
          Esta técnica se llama memoización. Esto no es un error tipográfico; no hay "r" en la palabra. Cada respuesta grabada es como un "memorándum".
            -
            Esta técnica se llama memoización. Esto no es un error tipográfico; no hay "r" en la palabra. Cada respuesta grabada es como un "memorándum".
          1. Usa una estructura de lista para realizar un seguimiento de los valores ya calculados de pascal, de modo que, cuando se vuelvan a proporcionar las mismas entradas, la función busque el valor guardado en lugar de realizar más llamadas recursivas.
          2. -
          3. Hay una fórmula directa para pascal que se usa mucho:
          4. -
            \text{pascal}(n,r) = \frac{n!}{r!(n-r)!}
            -

            Crea una versión de pascal que use la fórmula. Compara la eficiencia de esta versión con la versión recursiva y determina si cada versión se ejecuta en tiempo constante, tiempo lineal, tiempo cuadrático o tiempo exponencial.

            +
          5. Hay una fórmula directa para pascal que se usa mucho: +
            \text{pascal}(n,r) = \frac{n!}{r!(n-r)!}
            +

            Crea una versión de pascal que use la fórmula. Compara la eficiencia de esta versión con la versión recursiva y determina si cada versión se ejecuta en tiempo constante, tiempo lineal, tiempo cuadrático o tiempo exponencial.

            +
          diff --git a/cur/programming/8-recursive-reporters/optional-project-pascals-triangle/2-pascal-efficiency.html b/cur/programming/8-recursive-reporters/optional-project-pascals-triangle/2-pascal-efficiency.html index 953210b4a7..0c7ebfe5d4 100755 --- a/cur/programming/8-recursive-reporters/optional-project-pascals-triangle/2-pascal-efficiency.html +++ b/cur/programming/8-recursive-reporters/optional-project-pascals-triangle/2-pascal-efficiency.html @@ -26,8 +26,8 @@

          Pascal's Triangle and Efficiency

          You are about to figure out how many recursive calls are needed to compute a value in Pascal's Triangle.

          +
          What could you insert inside the block to track this?
            -
            What could you insert inside the block to track this?
          1. Modify your pascal block to keep count of how many times the block is executed.
          2. How many times is the pascal block called when calculating pascal(14)(5)?
          3. What happens when you call pascal(20)(5)?
          4. @@ -58,14 +58,14 @@

            Pascal's Triangle and Efficiency

            pascal(7,2) + pascal(7,3) + pascal(7,3) + pascal(7,4) + pascal(7,3) + pascal(7,4) + pascal(7,4) + pascal(7,5)

          -->
          +
          This technique is called memoization. This is not a typo; there's no "r" in the word. Each recorded answer is like a "memo".
            -
            This technique is called memoization. This is not a typo; there's no "r" in the word. Each recorded answer is like a "memo".
          1. Use a list structure to keep track of already-computed values of pascal, so that when the same inputs are given again, the function looks up the saved value instead of making more recursive calls.
          2. -
          3. There is a direct formula for pascal that is often used:
          4. -
            \text{pascal}(n,r) = \frac{n!}{r!(n-r)!}
            -
            PG: I'm ignoring for the moment the fact that I'm not sure we've taught enough about "quadratic time" etc. for the kids to tell.
            -

            Build a version of pascal that uses the formula. Compare the efficiency of this version to the recursive version, and determine whether each version runs in constant time, linear time, quadratic time, or exponential time.

            - +
          5. There is a direct formula for pascal that is often used: +
            \text{pascal}(n,r) = \frac{n!}{r!(n-r)!}
            +
            PG: I'm ignoring for the moment the fact that I'm not sure we've taught enough about "quadratic time" etc. for the kids to tell.
            +

            Build a version of pascal that uses the formula. Compare the efficiency of this version to the recursive version, and determine whether each version runs in constant time, linear time, quadratic time, or exponential time.

            +
          diff --git a/cur/programming/8-recursive-reporters/optional-project-sorting/1-sorting-a-list.es.html b/cur/programming/8-recursive-reporters/optional-project-sorting/1-sorting-a-list.es.html index 2a3d881710..9504ab354d 100644 --- a/cur/programming/8-recursive-reporters/optional-project-sorting/1-sorting-a-list.es.html +++ b/cur/programming/8-recursive-reporters/optional-project-sorting/1-sorting-a-list.es.html @@ -17,8 +17,8 @@

          Ordenar una lista

          ocho nombres, ordenado

          +
          Intenta describir el algoritmo con suficiente detalle para que otra persona pueda usar tu descripción para ordenar una lista.
            -
            Intenta describir el algoritmo con suficiente detalle para que otra persona pueda usar tu descripción para ordenar una lista.
          1. Diseña un algoritmo recursivo para ordenar los nombres.
              @@ -26,14 +26,15 @@

              Ordenar una lista

            • Luego considera cómo le dirías a una computadora, que no es tan inteligente como tú y solo puede realizar procedimientos específicos, cómo ordenar una lista.
          2. -
          3. Ahora construye tu algoritmo: una ordenación reportera toma una lista como entrada y genera una nueva lista de los mismos elementos en orden alfabético. Prueba tu algoritmo usando nombres y números.
          4. -
            - La comparación de números y cadenas se puede hacer usando los mismos bloques, por lo que tu algoritmo de clasificación debería funcionar igualmente bien para nombres y números.
            - - (Abigail)<(Ava) reporta verdadero - (7)<(3) reporta falso -
            +
          5. Ahora construye tu algoritmo: una ordenación reportera toma una lista como entrada y genera una nueva lista de los mismos elementos en orden alfabético. Prueba tu algoritmo usando nombres y números. +
            + La comparación de números y cadenas se puede hacer usando los mismos bloques, por lo que tu algoritmo de clasificación debería funcionar igualmente bien para nombres y números.
            + + (Abigail)<(Ava) reporta verdadero + (7)<(3) reporta falso +
            +
          6. Comparte tus algoritmos de clasificación. Describe algunas similaraciones y diferencias entre los diferentes algoritmos de clasificación.
          diff --git a/cur/programming/8-recursive-reporters/optional-project-sorting/1-sorting-a-list.html b/cur/programming/8-recursive-reporters/optional-project-sorting/1-sorting-a-list.html index 0db1897c7e..fef75a6370 100755 --- a/cur/programming/8-recursive-reporters/optional-project-sorting/1-sorting-a-list.html +++ b/cur/programming/8-recursive-reporters/optional-project-sorting/1-sorting-a-list.html @@ -31,8 +31,8 @@

          Sorting a List

          Kill the sentence about numbers and words; numbers don't sort numerically if you do a lexicographic sort, so mixing the two is tricky. --bh
          +
          Try to describe the algorithm in enough detail so that someone else could use your description to sort a list.
            -
            Try to describe the algorithm in enough detail so that someone else could use your description to sort a list.
          1. Design a recursive algorithm for sorting the names.
              @@ -40,12 +40,13 @@

              Sorting a List

            • Then consider how you would tell a computer, which is not as smart as you and can only perform specific procedures, how to sort a list.
          2. -
          3. Now build your algorithm: a sort reporter takes a list as input and outputs a new list of the same elements in alphabetical order. Test your algorithm using both names and numbers.
          4. -
            - Comparing numbers and strings can be done using the same blocks, so your sorting algorithm should work equally well for names and numbers.
            - (Abigail)<(Ava) reporting true - (7)<(3) reporting false -
            +
          5. Now build your algorithm: a sort reporter takes a list as input and outputs a new list of the same elements in alphabetical order. Test your algorithm using both names and numbers. +
            + Comparing numbers and strings can be done using the same blocks, so your sorting algorithm should work equally well for names and numbers.
            + (Abigail)<(Ava) reporting true + (7)<(3) reporting false +
            +
          6. Share your sorting algorithms. Describe some similarities and differences between different sorting algorithms.
          diff --git a/cur/programming/8-recursive-reporters/optional-project-sorting/2-selection-sort.html b/cur/programming/8-recursive-reporters/optional-project-sorting/2-selection-sort.html index 9e8bc41f17..83b4b34ec1 100644 --- a/cur/programming/8-recursive-reporters/optional-project-sorting/2-selection-sort.html +++ b/cur/programming/8-recursive-reporters/optional-project-sorting/2-selection-sort.html @@ -46,8 +46,8 @@

          Selection Sort

          Write the earliest in block. For names, this returns the first name alphabetically in a list:
          {Emma, Olivia, Sophia, Isabella, Ava, Mia, Emily, Abigail} earliest in(list{Emma, Olivia, Sophia, Isabella, Ava, Mia, Emily, Abigail}) reporting Abigail +
          ST-4/12/18 Tim Matthies Piazza request for visuals here in #4 and #5.
          -
          ST-4/12/18 Tim Matthies Piazza request for visuals here in #4 and #5.
        5. Write code that finds the index of the earliest item. This value is 8 for the list of names above. (You may not need this step, depending on your algorithm. See if you can do the next step without it.)
        6. Need to correct link after new U5 labs are finished. --MF, 3/29/19
          @@ -72,8 +72,8 @@

          Selection Sort

          names starting with(Z) reporting {....,Zacary, Zaccal, Zaccahaeus, Zaccheus, Zach, ...}
        7. -
          ST-4/13/18: Tim Matthies at Piazza noticed that we need to give directions for how to import this data. It turns out that capturing the data from the link given, importing and cleaning it is completely non-trivial and I don't think we have done this before in the curriculum. I recommend we make the following (huge) starter file available where the names are isolated and listed in popularity order, devoid of gender and number fields.
        +
        ST-4/13/18: Tim Matthies at Piazza noticed that we need to give directions for how to import this data. It turns out that capturing the data from the link given, importing and cleaning it is completely non-trivial and I don't think we have done this before in the curriculum. I recommend we make the following (huge) starter file available where the names are isolated and listed in popularity order, devoid of gender and number fields.
        diff --git a/cur/programming/8-recursive-reporters/optional-project-sorting/3-partition-sort.html b/cur/programming/8-recursive-reporters/optional-project-sorting/3-partition-sort.html index c39617f651..f722d02b70 100644 --- a/cur/programming/8-recursive-reporters/optional-project-sorting/3-partition-sort.html +++ b/cur/programming/8-recursive-reporters/optional-project-sorting/3-partition-sort.html @@ -18,8 +18,9 @@

        Partition Sort

        Another commonly used sort is called a partition sort. Here's how it works:
        • Step 1. In an unsorted list, select the first item in the list (which probably won't be the item that should appear first after sorting). This item is called a pivot.
        • -
          BH: About step 2 and its yellow box: This handwaves away the deep issue, which is that sometimes the sort key is smaller than the sort record, so two records may sort alike but not be equal. I'm not sure if this has to be addressed but maybe it should be mentioned in the TG. BK: I didn't understand what this comment means, sorry.
          -
        • An item is "with the pivot" only if it has the same value as the pivot.
          Step 2. For each item in the list, decide if it comes before the pivot, with the pivot, or after the pivot.
        • +
        • An item is "with the pivot" only if it has the same value as the pivot.
          Step 2. For each item in the list, decide if it comes before the pivot, with the pivot, or after the pivot. +
          BH: About step 2 and its yellow box: This handwaves away the deep issue, which is that sometimes the sort key is smaller than the sort record, so two records may sort alike but not be equal. I'm not sure if this has to be addressed but maybe it should be mentioned in the TG. BK: I didn't understand what this comment means, sorry.
          +
        • Step 3. Partition the data into three categories: items before the pivot, with the pivot, after the pivot. The lists before and after the pivot are unsorted.
        • Step 4. If there are items before the pivot, use a partition sort to put them in order. If there are items after the pivot, use a partition sort to put them in order.
        • Step 5.The sorted list is made from appending the three result lists together.
        • @@ -41,14 +42,14 @@

          Partition Sort

          To write a partition sort block in Snap!, you'll need code for a base case, and code that follows the steps of the partition sort.

          -
            -
            Obsolete +
            Obsolete Click here to load a starter project. Then save it.
            Examine this new project containing the append block (Variables menu). append(list{Ava, Abigail})(list{Emma})(list{Olivia, Sophia, Isabella, Mia, Emily})
            Describe what the append block does. -
            +
            +
            1. You'll need to figure out how to place the items into the three categories, and how to create one final list to output.
              Build the recursive reporter partition sort. Its output, for any list, should be the same as the output for selection sort.
          @@ -62,7 +63,7 @@

          Partition Sort

          Why are there different sorting algorithms? Some sorting algorithms take longer than others to run, but even an algorithm that's slow in general may be useful in special cases.

          -
            +
            1. You could also use a long list of names here.
              Make a 500-item list of random numbers, and then sort the list using the three sorting algorithms you built in this lab. Keep track of the timings: