Skip to the content. Back to Chapter 2
<style> :not(ul) + ol { counter-reset: list-ctr; list-style-type: none; list-style-position: outside; } :not(ul) + ol > li { counter-increment: list-ctr; } :not(ul) + ol > li::before { content:"Q" counter(list-ctr) ". "; margin-left: -25px; } ol ul { list-style-type: lower-roman; } ol ol { list-style-type: lower-alpha; } ol ul ul { list-style-type: lower-roman; } ul ol { list-style-type: circle; } ul { list-style-type: decimal; } ul ul { list-style-type: lower-alpha; } ul ul ul { list-style-type: lower-roman; }

Chapter 35

  1. Use an array.

    • ['James', 'Paul', 'Sophie', 'Holly', 'Nathan', 'Tom']
    • ['James', 'Paul', 'Sophie', 'Nathan', 'Tom']
    • ['James', 'Melissa', 'Paul', 'Sophie', 'Nathan', 'Tom']
  2. Have items that are aware of the indexes of the next and previous items, and update the indexes of the next and previous item (linked list)

  3. Adjust the algorithm used to determine the correct place to insert the item to look at item priorities

  4. Because it prevents using indexing with the model used

  5. index name pointer
    0 Browning 3
    1 Turner null
    2 Johnson 1
    3 Cray 2
    4 Allen 0
    5 null

    start: 4
    nextfree: 5

    First, write the value into the element of the array specified by nextfree. Then, read start to determine the item to link to - set pointer[nextfree] to start. Next, modify nextfree to point to the first free space in the array (generally one more than its previous value).

    • 3
    • 'Mortimer'
    • 4
    • 'Cray'
  6. --- omitted as no requirement to complete questions and I don't want to do this diagram ---

  7. >SET items TO 0
    SET ptr TO start
    WHILE ptr DO
        INC items
        SET ptr TO Names[ptr].pointer
    END WHILE
    OUTPUT There are $items items in Names
    

Exercises