// dsaI_17_15.java SJ import fi.joensuu.cs.tra.*; import java.util.LinkedList; public class dsaI_17_15_skeleton { public static void main(String[] args) { // stack size int N = 10; if (args.length > 0) N = Integer.valueOf(args[0]); // elements to reverse int k = 3; if (args.length > 1) k = Integer.valueOf(args[1]); LinkedStack S = new LinkedStack(); for (int i = 0; i < N; i++) S.push("a" + i); if (N <= 20) System.out.println(S); reverse_k(S, k); if (N <= 20) System.out.println(S); } // main() /** * 15. Write an algorithm that reverses the k topmost elements of a stack. * If there are ≤k ele- ments, algorithm reverses the whole stack. Use * either data structure library LinkedStack or Java API LinkedList. What * it the time complexity of your algorithm? **/ public static void reverse_k(LinkedStack S, int k) { // TODO } // reverse_k } // class dsaI_17_15