Looking for clarity on step in fractional knapsack problem proof I'm reading through the proof for the fractional knapsack problem presented here: https://www.cs.rice.edu/~nakhleh/COMP182/Knapsack.pdf
I follow the proof until the definition of the new set $Q = \langle q_1, q_2, ..., q_n \rangle$

for every $1 \leq i&lt;j: q_{i}=o_{i} ($also $q_{i}=y_{i})$ which is constructed as follows:
$q_j=y_j$
For $i=j+1$ to $n$

\begin{array}{l}
- d^{\prime} \leftarrow \min \left(q_{i}, d\right) \\
- q_{i} \leftarrow q_{i}-d^{\prime} \\
- d \leftarrow d-d^{\prime}
\end{array}
I don't understand where the $q_{j+1...n}$ elements come from. We only fill $Q$ up to $q_j$, but to fill $q_{j+1}$ we reference $q_i$ which is undefined — should it be 0? What am I missing?
All appearances of $q_i$ on the RHS are errors -- they should be replaced with $o_i$. I imagine the author was thinking of &quot;initialising&quot; $Q$ to be equal to $O$, and then updating its elements in-place.
Another minor issue I have is with the line &quot;After this procedure is done, the total value of the solution $Q$ is equal to the total value of $O$ (make sure youunderstand why!)&quot;. This is true, but as this is the key part of an introductory proof, I think it would have been better to break it into its two parts:

For any $k &gt; j$, moving positive weight from $o_k$ to $o_j$ results in a solution with value $\ge$ the original solution.
The original solution $O$ was assumed optimal, so the $\ge$ becomes a $=$.