1/18
Flashcards covering the fundamentals of two-dimensional arrays, including their structure, creation, and manipulation.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is a key use case for two-dimensional arrays as discussed in the lecture?
Tracking the performance of a language ID classifier, specifically which languages are predicted best and which are confused for others.
What are the drawbacks of using a table with repeated labels for tracking language predictions?
The table can become large (e.g., 576 rows for 24 languages), and looking up information can be cumbersome.
What are the advantages of using a matrix (2D array) for tracking language predictions?
It simplifies finding counts for languages predicted for a given language and actual language counts of predictions.
How do you determine the total number of strings in a language using the 2D array?
Sum the values in the corresponding row.
How do you determine the total number of predictions of a language using the 2D array?
Sum the values in the corresponding column.
How are elements of a two-dimensional array accessed?
By two indices: one for the row and one for the column (e.g., rating[row][col]).
In Java, how do you create a 2D integer array named 'rating' with 3 rows and 4 columns?
int[][] rating = new int[3][4];
How can you generate each pair of indices for a 2D array?
Use a double 'for' loop (a loop within a loop).
What C code is used to define a constant to represent the number of languages?
What is the purpose of the initCounts() function?
To initialize all elements of the counts array to zero.
What is the purpose of the printCounts() function?
To print out the indices and values of elements in the counts array that are not zero.
What is the purpose of the getTotal() function?
To calculate the total number of samples in the counts 2D array by summing all its elements.
What is the purpose of the getTotalCorrect() function?
To sum the number of correct predictions (where row and column indices are equal) in the counts array.
How is the accuracy of the classifier calculated?
By dividing the total correct predictions by the total number of samples.
What statistics are calculated in the printReport(int lang) function?
Precision and Recall for a specific language.
What are the advantages of using arrays?
Arrays offer random access and are very fast.
What are the disadvantages of using arrays?
Arrays are of a fixed size, and insertions/deletions can be costly.
What is a 'manifest constant'?
A meaningful name/label associated with a value (e.g., #define NUMBEROFLANGS 24).
Why are constants useful?
They improve code readability and simplify changes (e.g., if the number of languages changes).