Recall & Review
beginner
What is array traversal?
Array traversal means visiting each element in an array one by one, usually from the first element to the last.
Click to reveal answer
beginner
How do you traverse an array forwards in C?
Use a for loop starting from index 0 up to the last index, accessing each element in order.
Click to reveal answer
beginner
What is reverse traversal of an array?
Reverse traversal means visiting array elements starting from the last element down to the first.
Click to reveal answer
intermediate
Why is it important to know array traversal patterns?
Knowing traversal patterns helps to solve problems like searching, sorting, and modifying arrays efficiently.
Click to reveal answer
beginner
Show the C code snippet to traverse an array forwards and print each element.
int arr[] = {1, 2, 3, 4};
int n = 4;
for (int i = 0; i < n; i++) {
printf("%d ", arr[i]);
}
// Output: 1 2 3 4
Click to reveal answer
Which index does array traversal in C usually start from?
✗ Incorrect
In C, arrays start at index 0, so traversal usually begins at 0.
What is the last index of an array with size n?
✗ Incorrect
Array indices go from 0 to n-1, so the last index is n-1.
Which loop is commonly used for array traversal in C?
✗ Incorrect
For loops are simple and clear for traversing arrays.
What happens if you traverse an array beyond its last index?
✗ Incorrect
Accessing beyond array bounds causes undefined behavior or crashes.
How do you traverse an array in reverse order?
✗ Incorrect
Reverse traversal starts at last index and moves backward to 0.
Explain how to traverse an array forwards and backwards in C.
Think about how the loop index changes in each case.
You got /4 concepts.
Why must you be careful not to access array elements outside their valid indices during traversal?
Consider what happens if you read or write outside the array.
You got /4 concepts.
