Fix: avoid greedy selection in parsons line grader LIS calculation#1304
Open
ascholerChemeketa wants to merge 4 commits into
Open
Fix: avoid greedy selection in parsons line grader LIS calculation#1304ascholerChemeketa wants to merge 4 commits into
ascholerChemeketa wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the longest-increasing-subsequence (LIS) computation used by the Parsons line grader to avoid greedy subsequence selection, improving correctness of “out-of-order” block highlighting for certain answer permutations.
Changes:
- Replaces the previous greedy subsequence builder with a dynamic-programming LIS construction (build LIS ending at each position, then select the longest).
- Improves consistency of identified “in-order” blocks for grading/highlighting in incorrect-order submissions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+11
to
+17
| var subsequenceForCurrent = [arr[i]]; | ||
| for (var j = 0; j < i; j++) { | ||
| if ( | ||
| arr[j] < arr[i] && | ||
| allSubsequences[j].length + 1 > subsequenceForCurrent.length | ||
| ) { | ||
| subsequenceForCurrent = allSubsequences[j].concat(arr[i]); |
Comment on lines
+11
to
20
| var subsequenceForCurrent = [arr[i]]; | ||
| for (var j = 0; j < i; j++) { | ||
| if ( | ||
| arr[j] < arr[i] && | ||
| allSubsequences[j].length + 1 > subsequenceForCurrent.length | ||
| ) { | ||
| subsequenceForCurrent = allSubsequences[j].concat(arr[i]); | ||
| } | ||
| } | ||
| allSubsequences.push(subsequenceForCurrent); |
Comment on lines
45
to
48
| "btm-expressions": "^0.1.12", | ||
| "byte-base64": "^1.1.0", | ||
| "canvas": "^3.2.3", | ||
| "codemirror": "^5.59.4", |
Member
There was a problem hiding this comment.
This makes sense to me @ascholerChemeketa as I do not have to install canvas to run the tests on my mac.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jan Pearce introduced me to Lori Postner this morning. Lori identified inconsistencies and confusing behavior with block highlighting for solutions with incorrect ordering. I took a look at the longest increasing sequence generation code and it does appear there is an issue.
Given [5, 1, 6, 2, 3, 4], it would identify [2, 3, 4] as the LIS sequence instead of [1, 2, 3, 4]. The algorithm is greedy - when starting at 1, once it identifies [1, 6] as a possibility, it rejects considering [1, 2, ....] as 2 doesn't continue the first possible sequence discovered. Thus the longest sequence if finds for 1 is [1, 6] and the final LSI identified is [2, 3, 4].