Bird
0
0
DSA Cprogramming~10 mins

Palindrome Detection in DSA C - Interactive Practice

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

Complete the code to check if a string is a palindrome by comparing characters from start and end.

DSA C
int isPalindrome(char str[]) {
    int start = 0;
    int end = strlen(str) - 1;
    while (start < end) {
        if (str[start] != str[[1]]) {
            return 0;
        }
        start++;
        end--;
    }
    return 1;
}
Drag options to blanks, or click blank then click option'
Aend
Bstart
C0
Dstrlen(str)
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same index for both characters instead of start and end.
Comparing with a fixed index like 0 or length instead of 'end'.
2fill in blank
medium

Complete the code to calculate the length of the string for palindrome check.

DSA C
int length = [1](str);
Drag options to blanks, or click blank then click option'
Asize
Blength
Cstrlen
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using undefined functions like size or count.
Trying to use length as a function.
3fill in blank
hard

Fix the error in the palindrome check loop condition.

DSA C
while (start [1] end) {
    if (str[start] != str[end]) {
        return 0;
    }
    start++;
    end--;
}
Drag options to blanks, or click blank then click option'
A>
B==
C<=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using equality or greater than which stops loop too early or causes errors.
Using less than or equal which may cause unnecessary comparisons.
4fill in blank
hard

Fill both blanks to correctly reverse the string for palindrome comparison.

DSA C
int len = strlen(str);
char rev[len + 1];
for (int i = 0; i < len; i++) {
    rev[[1]] = str[[2]];
}
rev[len] = '\0';
Drag options to blanks, or click blank then click option'
Alen - 1 - i
Bi
Clen + i
Di - 1
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same index i for both strings which does not reverse.
Using incorrect index calculations causing out of bounds.
5fill in blank
hard

Fill all three blanks to create a function that returns 1 if palindrome, else 0.

DSA C
int isPalindrome(char str[]) {
    int start = 0;
    int end = [1](str) - 1;
    while (start [2] end) {
        if (str[start] != str[end]) {
            return [3];
        }
        start++;
        end--;
    }
    return 1;
}
Drag options to blanks, or click blank then click option'
Astrlen
B<
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong loop condition operators.
Returning 1 on mismatch instead of 0.