Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an array of integers with size 5.
DSA C
int arr[[1]]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as size which creates an empty array.
Using size 1 or 10 which does not match the requirement.
✗ Incorrect
The array size must be 5 to hold 5 integers.
2fill in blank
mediumComplete the code to access the third element of the array.
DSA C
int value = arr[[1]]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 3 which is the fourth element.
Using index 1 which is the second element.
✗ Incorrect
Array indexing starts at 0, so the third element is at index 2.
3fill in blank
hardFix the error in the linked list node definition by completing the pointer declaration.
DSA C
struct Node {
int data;
struct Node[1] next;
}; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&' which is address-of operator, not pointer declaration.
Using '.' which accesses members, not declares pointers.
✗ Incorrect
The next pointer must be declared as a pointer to struct Node using '*'.
4fill in blank
hardFill both blanks to complete the hash map lookup function header and return type.
DSA C
[1] [2](HashMap* map, int key);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using void as return type which means no value returned.
Using insert as function name which is for adding, not lookup.
✗ Incorrect
The function returns an int and is named lookup to find a value by key.
5fill in blank
hardFill all three blanks to complete the array search function that returns index or -1 if not found.
DSA C
int search(int arr[], int size, int target) {
for (int [1] = 0; [2] < size; [3]++) {
if (arr[i] == target) {
return i;
}
}
return -1;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names causing compilation errors.
Using 'j' which is not declared in the loop.
✗ Incorrect
The loop variable is 'i' used consistently for initialization, condition, and increment.
