Beruflich Dokumente
Kultur Dokumente
Student id:
Name:
Total 3 pages, including problem set (A, B, C), or 20 problems totally 105 points.
2.
3. 4. 5.
6.
7. 8.
many times does the statement, i i+1, execute respectively? [8%, each n 2 %] procedure PrimeChecker n a positive integer i 2 while( i * i n and n cannot be divided by i ) do ii+1 if( i * i > n) then print n is a prime else print n is not a prime 14. Binary tree problems [8%] a. What is a binary tree? [2%] b. Please draw all possible binary trees that consist of three nodes.[2%] c. Given a non-empty binary tree (the number of nodes is larger than 0), how many root node in this tree [2%]? And how many sibling nodes each node has? [2%] 15. [5%] Identify the level within a database system(user, programmer of application software, designer of the DBMS software) at which each of the following concerns or activities occur: Hint: Match both Table P15a and P15b listed below to find answers for each of the sub-problems. That is, you are to find the values for the tuple (a, b c, d, e) = (?,?,?,?,?).
Figure P15: The conceptual layers of a database implementation Table P15a: Questions about Databases Question a. How should data be stored on a disk to maximize efficiency? b. How many times should a user be allowed to mistype a password before the conversation is terminated? c. Is there a vacancy on flight 243? d. How should a relation be organized in mass storage? e. How can the PROJECT operation be implemented? Table P15b: Human Involved Type of People (1). Ordinary user (2). Programmer of application software (3). Designer of the DBMS software
16. [10%] Using the commands SELECT, PROJECT and JOIN, write a sequence of instructions to answer each of the following questions about airlines, flights (for a particular day), and passengers in a relational database: (Note A: Airline, F: Flight, P:Passenger, S:Seat ) X relations A F Air Sky AS205 Air Sky AS37 Air Hop AH89 Air Sky AS37 Air Hop AH67 Air Top AT331 Y relation P F John John John Ray Tim Tim AS205 AS37 AH89 AS37 AH67 AT331
a. Obtain a list of the flights that John takes reservations. [4%] b. Obtain a list of the names of the Airlines that Tim takes reservations. [6%]
X relation U V AA LL CC KK
BB MM 30