CSCI 131,

Fall 2002,

Test 3.


  1. [1 pt] Define Abstract Data Type

  2. [4 pts] Define the ADT List using the definition in part 1

  3. [10 pts] Write a procedure which given an array of elements and the number of elements in the array, places the elements in the array in descending order (largest item in position 0).

  4. [5 pts] Write a procedure which given an array of elements, the length of the array, and an item, returns true if item is present in the array and false if the item is not present in the array.

  5. [5 pts] Give an example of an algorithm which runs in O(1), O(lg n), O(n) and O(n2).

  6. [5 pts] Discuss the difference between an ordered list and an unordered list (performance, behavior. ...). When should each be used?

  7. [10 pts] Assume an array based implementation of a linked list. Assume the array size is 5. Show the data structure and the list after the following operations:
    L.Insert(1);
    L.Insert(5);
    L.Insert(4);
    L.Delete(1);
    L.Delete(4);
    		
    Please draw the array, the linked list, and the free list.

  8. [5 pts] Write the class declaration (header) for an array based linked list. Use your definition from part 2.

  9. [5 pts] Write the code for the insert procedure for the class in part 8.