Your task is to write a function, listIsPalindromic, that determines whether the sequence of values in a given doubly linked list is palindromic. A sequence of values is palindromic if it reads the same backwards as forwards. For example, the sequence [1, 2, 3, 2, 1] is palindromic, whereas the sequence [1, 2, 3, 4] is not. The function should return true if the sequence of values in the linked list is palindromic, and false otherwise. Your function should not modify the list.
Click here to download a zip of the files.
list.c | Contains the implementation of basic list functions |
list.h | Contains the definition of the list data structure and function prototypes |
testListIsPalindromic.c | Contains the main function, which reads in a list from standard input, calls listIsPalindromic, and prints out the result. |
listIsPalindromic.c | Contains listIsPalindromic, the function you must implement |
Makefile | A makefile to compile your code |
tests/ | A directory containing the inputs and expected outputs for some basic tests |
autotest | A script that uses the tests in the tests directory to autotest your solution. You should only run this after you have tested your solution manually. |
Your program should behave like these examples:
$ ./testListIsPalindromic
Enter list: 1 2 3 2 1
listIsPalindromic returned TRUE
$ ./testListIsPalindromic
Enter list: 1 2 3 4
listIsPalindromic returned FALSE
$ ./testListIsPalindromic
Enter list: 9 4 7 1 1 7 4 9
listIsPalindromic returned TRUE
$ ./testListIsPalindromic
Enter list: 1 8 2 7 7 2 9 1
listIsPalindromic returned FALSE
$ ./testListIsPalindromic
Enter list:
listIsPalindromic returned TRUE
You can test your program manually by compiling your code using make
, and then running ./testListIsPalindromic
, as shown above. After you are satisfied with your solution, you can autotest it by running ./autotest
. This will run some basic tests on your program.