Homework Assignment #2
CS 163: Data Structures
Spring 2009
Answer the
following questions: *** You do NOT need
to use recursion with these questions ***
a) Show how to dynamically (with new) allocate an array of 50 integers
a. Then, using pointer arithmetic, display the contents of the array (do NOT use the subscript operator!)
b) Show how to dynamically allocate (with new) an array of 50 char *’s
a. Now show how you would allocate the first array of characters (to be 10 characters long)
c) Show how to dynamically (with new) allocate an array of 50 nodes
d) Show how to dynamically (with new) allocate an array of 50 node pointers
a. Assuming that other nodes have been added…Write an iterative function to insert a node at the end of the ith linked list (e.g., end of the 3rd linked list) where the ith item ranges from 1->49
b. Write the code to show how you would deallocate all dynamic memory for an array of linear linked lists.