CSC161 2010F, Class 53: Linked Stacks and Queues Overview: * Exam 3 questions. * Review. * Implementing Linked Stacks. * Implementing Linked Queues. Admin: * Happy CS Education Week. * Food for week 14. * EC for Tuesday's Women Computers movie. * EC for Thursday's CS Extra * Reading for Tuesday: Walker on Bash Scripts (link online). Exam 3 * Can we use struct node instead of struct string_node and struct list instead of struct string_list? * Yes. * When you declare a new array of strings using the two bracket thingy. char strings[n][m]; * n is number of strings. * m is size of string. * How do you allocate it? * The declaration does the allocation. * How do your refer to the 4th string? strings[4] * Cool? 14 degrees F * When we're referencing the fields of structures, is it not enough to link? * The compiler needs to see the declaration of the structure in order to figure out how to use it. * The declaration needs to be in the same file or in an included header file. * How do I debug the problems with the macro? * cc -E is really helpful * Can you cancel the loop problem? * Yes. * Can it be extra credit? * Yes. * How do I deal with the immutability of strings? * Don't put immutable strings in the list! list.add("Hello") is immutable list.add(strdup("Hello")) is mutable Review: On Wednesday IN CLASS, we were ... yeah * Stacks and queues and other linear collections * Implemented using ARRAYS But we can also implement them using linked nodes * Easier to manage implementation * Linked nodes are dynamic: We can keep growing the stack and queue But how? * Stack: Add new things to the head and remove from the head * Queue: Add new things to the tail and remove from the head