Bird
0
0
DSA Cprogramming~10 mins

Hash Map vs Array vs Linked List for Lookup in DSA C - Interactive Comparison Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A5
B10
C0
D1
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.
2fill in blank
medium

Complete 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'
A3
B0
C1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 3 which is the fourth element.
Using index 1 which is the second element.
3fill in blank
hard

Fix 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'
A*
B&
C[]
D.
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&' which is address-of operator, not pointer declaration.
Using '.' which accesses members, not declares pointers.
4fill in blank
hard

Fill 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'
Aint
Blookup
Cvoid
Dinsert
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.
5fill in blank
hard

Fill 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'
Ai
Dj
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names causing compilation errors.
Using 'j' which is not declared in the loop.