Two-Dimensional Arrays

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/18

flashcard set

Earn XP

Description and Tags

Flashcards covering the fundamentals of two-dimensional arrays, including their structure, creation, and manipulation.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

19 Terms

1
New cards

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.

2
New cards

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.

3
New cards

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.

4
New cards

How do you determine the total number of strings in a language using the 2D array?

Sum the values in the corresponding row.

5
New cards

How do you determine the total number of predictions of a language using the 2D array?

Sum the values in the corresponding column.

6
New cards

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]).

7
New cards

In Java, how do you create a 2D integer array named 'rating' with 3 rows and 4 columns?

int[][] rating = new int[3][4];

8
New cards

How can you generate each pair of indices for a 2D array?

Use a double 'for' loop (a loop within a loop).

9
New cards

What C code is used to define a constant to represent the number of languages?

define NUMBEROFLANGS 24

10
New cards

What is the purpose of the initCounts() function?

To initialize all elements of the counts array to zero.

11
New cards

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.

12
New cards

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.

13
New cards

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.

14
New cards

How is the accuracy of the classifier calculated?

By dividing the total correct predictions by the total number of samples.

15
New cards

What statistics are calculated in the printReport(int lang) function?

Precision and Recall for a specific language.

16
New cards

What are the advantages of using arrays?

Arrays offer random access and are very fast.

17
New cards

What are the disadvantages of using arrays?

Arrays are of a fixed size, and insertions/deletions can be costly.

18
New cards

What is a 'manifest constant'?

A meaningful name/label associated with a value (e.g., #define NUMBEROFLANGS 24).

19
New cards

Why are constants useful?

They improve code readability and simplify changes (e.g., if the number of languages changes).