CSE 1302C Test 2 10/24/11 Name:______________________________________ Directions: You have 90 minutes to complete this exam. All answers are to be your own without the assistance of others. YOU MUST DO BOTH SIDES! Question 0 (25 pts): The dreaded recursion question: What is the output of the following code? static float recurse(float x, float y) { Console.WriteLine(x + ":" + y); if (x / y <= 1) { return x; } else { return y + recurse(x / y, y); } } static void Main(string[] args) { Console.WriteLine(recurse(81, 3)); } Question 1 (25 pts): Assuming a Binary Search Tree (BST) with n elements and using “Big-Oh” notation: How long does it take to insert new data into a balanced BST? How long does it take to find a piece of data in a balanced BST? How long does it take to find the median in a balanced BST? What is the problem with inserting sorted data into a BST? Show the tree from inserting the following numbers into an empty BST: 8, 11, 13, 4, 9, 6, 7 Question 2 (25 pts): Compare and contrast the efficiency (using “Big-Oh” notation) of a sorted array of ints and a sorted linked list of ints with regard to the following. Which data structure is more efficient (or are they the same)? Finding the smallest number Finding the largest number Finding an arbitrary number (to see if it exists) Finding the median number(s) Finding the average of all numbers Question 3 (25 pts): Imagine we have a 1000 by 1000 2D array of numbers called “dataArray”. Show the code to write all of those numbers out to a file called “data.txt”. The numbers should be separated by commas.