Introduction to Computer Science

Total Page:16

File Type:pdf, Size:1020Kb

Introduction to Computer Science

Introduction to Computer Science Second Exam 4/30/2007 1.(10%) The table below represents a portion of linked list in a computer’s main memory. Each entry in the list consists of two cells: The first contains a letter of the alphabet; the second contains a pointer t the next list entry. If the head pointer contains the value 44, what name is represented by the list? Change the pointer so that the list contains the name Jean. Address Contents 40 N 41 46 42 I 43 40 44 J 45 50 46 E 47 00 48 M 49 42 50 A 51 40

See HW 8.9

2. (5%)(a) Design an algorithm for printing a linked list in reverse order using a stack as an auxiliary storage structure. (5%)(b) Design a recursive procedure to perform this same task without making explicit use of a stack. In what form is a stack still involved in your recursive solution. See HW 8.14(a)(b) 3. (a) (6 %) Suppose a queue implemented in a circular fashion is in the state shown below. Draw a diagram showing the structure after the letters G and R are inserted, three letters are removed, and the letters D and P are inserted.(b) (4 %) What error occurs in part (a) if the letters G, R, D, and P are inserted before any letters are removed?

HW 8.26

4. (10 %) Suppose two arrays of 6 integers are used to implement a stack and a circular queue respectively. Both structures are initially empty. After consecutive operations of inserting 35, inserting 38, removing one item, inserting 63, inserting 24, removing one item, inserting 7, inserting 12, removing one item, inserting 30, inserting 68, and inserting 17, on both structures, what are the contents stored in both arrays? (Please indicate clearly what the pointers point to.)

5. (10%) If a hashed file is partitioned into 11 buckets, what is the probability of at least two out of three arbitrary records hashing into the same section? (Assume the hash algorithm gives no bucket priority over the others.) How many records must be stored in the file until it is more likely for collisions to occur than not? (a)1-(11/11)(10/11)(9/11) 6. (6%)(a)Write a sequence of instructions(using the operations SELECT, PROJECT, and JOIN) to retrieve the Name and JobTitle of each current employee from the relational database described below. (4%) (b) Write it using SQL.. HW 9.15 9.16 7. (10 %) The table below represents a portion of a computer’s main memory containing a binary tree stored row by row in a contiguous block as described in the chapter. Draw a picture of the tree. Address Contents 50 A 51 B 52 C 53 D 54 E 55 F 56 G 8. (10%)Given the two relations X and Y below X: A B Y: C D 2 s t 1 5 z r 3 w 2 draw the relation Result that would be produced by the following statements? Temp ¬ JOIN X and Y where X.A > Y.D Result ¬ PROJECT X.B, Y.C from Temp Answer : : s, w 9. (5%) Summary the difference between a flat file and a database. (5%) Explain immediate addressing and direct addressing? (A) Database = a collection of data that is multidimensional, since internal links between its entries make the information accessible from a variety of perspectives Flat File = a traditional one-dimensional file storage system that presents its information from a single point of view (B) Immediate addressing: instruction contains the data to be accessed Direct addressing: instruction contains the address of the data to be accessed

10. (5%) Which component of an operating system maintains the directory system? (5%) Which component of an operating system handles the details associated with particular peripheral equipment? (a) file management (b) device driver

Recommended publications