// dsaI_17_16.java SJ import java.util.Deque; import java.util.LinkedList; import java.util.Scanner; public class dsaI_17_16_skeleton { // Main program usage // java dsaI_17_16 [merkkijono] public static void main(String[] args) { String mjono = null; if (args.length > 0) mjono = args[0]; if (mjono == null) { System.out.print("Give a string: "); Scanner sc = new Scanner(System.in); mjono = sc.nextLine(); } System.out.print("String '" + mjono + "' "); if (isPalindrome(mjono)) System.out.println("is a palindrome"); else System.out.println("is not a palindrome"); } // main() /** * Help method that copies string content to Deque */ public static Deque stringToDeque(String S) { Deque D = new LinkedList(); // TODO // hint: S.charAt(i) return D; } /** * 16. A palindrome is a word/string that reads the same also when read * backwards. Write an algorithm that finds out whether a string a * palindrome or not. Hint: store the string to a deque character by * character, and then do the checking. Take main program from course * www-page. What is the time complexity of your algorithm? * **/ public static boolean isPalindrome(String S) { Deque D = stringToDeque(S); // TODO return true; } } // class