# Automated Classification and Feedback Generation for Programming Assignments

Online-learning platforms (e.g., Coursera, Khan Academy, edX) are very popular and massive open online courses (MOOCs) have attracted thousands of students. We study the following reserach problem : in the traditional classroom setting students are given feedback (hints) by an instructor; in MOOCs this is not possible, since there typically is only a small number of instructors. For introductory programming assignments, students require feedback on different aspects of their code:

1. Correctness: guidance for writing a correct program.
2. Performance: help for improving the performance of an already correct program.

We have developed a tool that classifies student programs based on their high-level idea (which we also call algorithmic strategy); this classification enables us to automatically give feedback on correctness and performance: By recognizing the high-level idea of the student we can say “good job, your code is efficient!” or give a suggestion how to improve the code. Similarly, by recognizing the high-level idea of the student we can compare the student’s code to a correct program with the same high-level idea, and based on the differences suggest how to repair the program. Examples below illustrate these ideas:

Assignment: Decide if two strings (s and t) are anagrams (two strings are anagrams if they can be permuted to become equal).
 ```bool Puzzle(string s, string t) { var sa = s.ToCharArray(); var ta = t.ToCharArray(); Array.Sort(sa); Array.Sort(ta); return sa.SequenceEqual(ta); }``` ```bool Puzzle(string s, string t) { return s.All(c => s.Where(c2 => c2 == c) .Count() == t.Where(c2 =>c2 == c) .Count()); }``` ```bool Puzzle(string s, string t) { if (s.Length != t.Length) return false; char[] sa = s.ToCharArray(); char[] ta = t.ToCharArray(); for (int j=0; j < sa.Length; j++) { for (int i=0; i < sa.Length - 1;i++) { if (sa[i] < sa[i+1]){ char temp=sa[i]; sa[i]=sa[i+1]; sa[i+1]=temp; } if (ta[i] < ta[i+1]){ char temp=ta[i]; ta[i] = ta[i+1]; ta[i+1] = temp; } } } for (int k = 0; k < sa.Length; k++) { if (sa[k] != ta[k]) return false; } return true; }``` ```bool Puzzle(string s, string t) { if (s.Length != t.Length) return false; foreach (Char ch in s.ToCharArray()){ if (countChars(s, ch) != countChars(t, ch)){ return false; } } return true; } int countChars(String s, Char c){ int number = 0; foreach (Char ch in s.ToCharArray()){ if (ch == c){ number++; } } return number; }``` Feedback: “Instead of sorting, compare the number of characters in strings”. Feedback: “Count the characters in a pre-processing phase, instead of in a loop”.

These four examples show correct, but inefficient programs (all have complexity O(n2), while there exists a solution with complexity O(n) — do you know what it is?). The programs on the right use a different high-level idea (aka algorithmic strategy) than the programs on the left (counting character occurences instead of sorting). Our tool classifies programs based on the used algorithm, and despite their syntactic differences gives the same feedback for the programs on the left resp. on the right.

Assignment: Read two integers 0 <= n <= m, and count the Fibonacci numbers in the closed interval [n,m].
 ```int main() { long a=0, b=1,c=0,cnt=0; long int n,m; scanf("%ld%ld",&n,&m); while (c<=m) { c=a+b; if ((c>=n)&&(c<=m)) cnt=cnt+1; a=b; b=c; } printf("%d",cnt); }``` ```int main() { long int n,m,f,n1=2,n2=3; int c=0; scanf("%ld %ld",&n,&m); while(f<=m) { f=n1+n2; n1=f; n2=n1; if(f>=n && f<=m) c++; } printf("%d",c); }``` Correct program Incorrect program; feedback: "1. Assign 0 to n2 and f, and 1 to n1 before the loop; 2. Move the statement n2=n1; before n1=f; in the loop."
Our tool computes the smallest number of changes that transform the incorrect program on the right into the the correct program on the left, resulting in the feedback shown above. In fact, our tool computes such a repair with regard to every correct program in the database and reports only the repair that is best (smallest number of edits) with regard to all correct programs.

Classification and feedback generation is a very active area of research, and our goal is to develop techniques and tools to improve the state-of-the-art in automated programming education. If you find these results exciting, we can offer you a variety of topics for bachelor/master theses, projects for practical course work, and student jobs.

For more information, also check our recent paper on this topic: Feedback Generation for Performance Problems in Introductory Programming Assignments.

## Helmut Veith 1971-2016

It is with the deepest sadness that we announce Helmut Veith’s passing on March 12, 2016. Helmut was a brilliant researcher, an inspiring collaborator, a stimulating teacher, a generous friend, and a wonderful father and husband. He leaves a void that will be impossible to fill. Our thoughts are with his family and friends.

## CFP: Formal Reasoning in Distributed Algorithms (FRIDA’16)

Josef Widder and Igor Konnov are co-organizing the third workshop on Formal Reasoning in Distributed Algorithms. Check the workshop page.

## The paper following the invited talk by Helmut Veith at PSI’15

If you wanted to know anything about model checking of fault-tolerant distributed algorithms, then check our follow-up paper after the invited talk by Helmut Veith at PSI’15.

## Profil article on women in logic

A recent article in the Austrian weekly Profil about female logicians in Austria is featuring Agata Ciabattoni, Martina Seidl, Laura Kovacs, Magdalena Ortiz, Marijana Lazic, Shqiponja Ahmetaj, and Neha Lodha. All women are affiliated with the Doctoral College Logical Methods in Computer Science.

## Panel discussion on research funding in Austria

Helmut Veith was a panelist in a public discussion on research funding in Austria.