Homework Assignment #1

 

CS 163: Data Structures

Spring 2009

 

 

The Purpose of this Homework

is to Practice Recursion what we learned in CS162

 

            To prepare for this homework please review Linear Linked Lists and Recursion from CS162

 

1)      Write an iterative function to copy the entire contents of a linear linked lists. Put the copy into a new linear linked list.

2)      How would your answer to #1 change if you were to put the copy into an empty array instead?

3)      Now, change your answer to #1, using recursion to perform the copy!

4)      Write a recursive function that sums together all of the integer data in an array of size N

5)      Write a recursive function that adds a node to the end of a linear linked list

6)      Write a recursive function to count the number of positive numbers that are in a linear linked list of integers

7) ITERATIVELY: Write a function that will delete from an unsorted linked list of integers the node that contains the largest item, using only a single traversal.  ***do this iteratively ***