CS 361 Test TWO Name______________________________________________ Spring 2010 Due in class (hard copy) 26 April (1). Assume that you have a singly linked list with a dummy head node and that all the elements in the list(integers) are in sorted order. Write a function that removes any duplicate nodes from the list. (2). Assume that you have an EMPTY binary search tree, "T", which is implemented using a struct with pointers left & right and int element. What is the output of function "traverse" below if the following data is first inserted into the tree in the order given and no external balancing routines are called? data: 5, 6, 2, 8, 1, 3, 4 void traverse ( SEARCH_TREE T ); { if ( T != NULL ) { traverse ( T->right ); traverse ( T->left ); cout << T->element; }; } (3). Suppose we wanted to implement binary trees using a language that had pointers but did not allow recursion. Briefly describe two approaches to creating traversal routines in such a system. (4). Consider the array implementation of priority queues. What is the main advantage of the array implementation? Main disadvantage? (5). For internal sorting the quicksort is prefered over the mergesort. Why? What type of structures would make the mergesort more attractive? (6). How is "pattern scavenging" related to the type of class relationships called generalization? (7). Hashing is a technique to translate element unique identifiers into an ordered set of integers that can be used as the index values of a hash table structure. Describe three methods of handling hashing collisions. (8). Assume that you have a number of records that you want sorted by a certain key whose only possible values are "false" and "true". Using only constant extra space ( extra space is not proportional to n ), DESCRIBE an algorithm that will perform the sort in O(n) time. (9). Consider a linked list implementation of a queue with a dummy head node and "front" and "rear" pointers. Conceptually, what would we have to do (including modifying the node structure) to the queue layout so that only one pointer is needed to access both the front and rear of the queue in O ( 1 ) time? Hint: do you need to be able to move both ways in the list? (10). What is the "Big OH" of the following function fragment? void Func10 ( int n ); { for (int i=1 ; i