Midterm Exam: Introduction to Computer Science 1. What is “class” in object-oriented programming? Please give an example to explain it. (10%) 2. What is difference between object and class in object-oriented programming? (10%) 3. Problem: Create a list that includes each person’s name, telephone number, and email address. This list should then be printed in alphabetical order. The names to be included in the list are on scraps of paper and business cards. Please list at least three classes when you solve this program and explain your answer. (10%) 4. What is difference between "syntax error" and "logic error" in programming language? (10%) 5. Please explain the advantages of"reuse" on software development. (10%) 6. Consider the following array of values. Show the state of the list when firstUnsorted is first set equal to the 5th item in the bubble sort algorithm. (10%) lenth = 11 list[11] = {23,41,66,20,2,90,9,34,19,40,99} Hint: Bubble Sort Set firstUnsorted to 0 Set index to firstUnsorted + 1 Set swap to TRUE WHILE ( index < length AND swap ) Set swap to FALSE “Bubble up” the smallest item in unsorted part Set firstUnsorted to firstUnsorted + 1

Bubble up Set index to length - 1 WHILE ( index > firstUnsorted + 1 ) IF ( data[index] < data[index-1] ) Swap data[index] and data[index-1] Set swap to TRUE Set index to index - 1 7. write a top down design for the following tasks. (10%) a. calculating the average of ten test scores. b. calculating the average of an unknown number of test scores. c. describe the differences in the two designs. 8. For the following questions, mark the answer T or F. (40%) a. A binary search cannot be applied to a tree. b. A stack and a queue are different names foe the same ADT. c. A stack displays FIFO behavior. d. A queue displays LIFO behavior. e. A leaf in a tree is a node with no children. f. A binary tree is a tree in which each node can have zero, one, or two children. g. A binary search tree is another name for a binary tree. h. The value in the right child of a node (if it exists) in a binary search tree will be greater than the value in the node itself. i. The value in the left child of a node (if it exists) in a binary search tree will be greater than the value in the node itself. j. Algorithm that use a list must know whether the list is array based or linked. k. A text file stores binary data that is organized into group of 8 or 16 bits that are interpreted as characters. l. A program written in a high-level language is stored in a text file that is also called a source file. m. The type of a file determines which kinds of operations can be performed on it.

n. The current file pointer indicates the end of a file. o. Sequential access and direct access take about the same amount of time to retrieve data. p. Some operating systems maintain a separate read pointer and write pointer for a file. q. UNIX file permissions allow a group of users to access a file in various ways. r. In most operating systems, a directory is represented as a file. s. Two files in a directory system can have the same name if they are in different directories. t. A relative path is relative to the root of the directory hierarchy.

1358359468528106865_