Problem #9: Understanding Database Queries



CS 150 Sample Final Exam Prof. Harrington. 100 points. 2 hours.

You may use your notes written on four sides of 8.5 X 11 inch paper. You may not use calculators or books.

( 8)1. Do the following base conversions. Show your work.

a. Convert the number 66(base 10) into base 3.

b. Convert the number 111100110110010010(base 2) into base 16, without converting the entire base 2

representation to base 10 first

( 8) 2. Draw a circuit diagram that corresponds to the following Boolean expression: A(B + (CA)')

A

B

C

( 9) 3. Use the construction method from class to create Huffman codes for the following letters. Please draw your final tree in the space below and then fill in the third column of the following table.

Letter Frequency Code

T 11

E 10

N 7

G 6

R 5

A 2

Z 1

( 8) 4. Play computer with the program below. Keep columns for the memory address of the instruction (shown after each line of assembler code), and the accumulator value after the instruction has executed, and the value of the data X, Y and Z after the instruction has executed: To save time, you may choose to show only those values that change at each line. The initial values of the accumulator and the memory value are shown to the right. Complete the line for the instruction at memory address 0, and continue from there.

Assembler code Memory address

TOP LOD X 0

JZR END 1

SUB Y 2

STO X 3

LOD Z 4

ADD ONE 5

STO Z 6

JMP TOP 7

END STP 8

X DAT 5 9

Y DAT 5 10

Z DAT 3 11

ONE DAT 1 12

Program

Counter ACCUM X Y Z

--------------------

initial 0 5 5 3

0

( 8) 5. Write a SSCPU assembly language program which inputs two numbers from the user, and outputs the sum of the two numbers. You do NOT need to provide machine code.

( 8) 6.Carefully consider the following Palgo code and then show the picture which would result from running this code on the grid. Line numbers are shown to assist you in keeping track as you play computer:

line numbers

A = 4 1

B = 1 2

while (A+B < 22) 3

draw(A,B) 4

if (A>B) then 5

B=B+6 6

Else 7

A=A+2 8

end

end

| |0 |1 |

|9 |4 |3 |

|7 |2 |7 |

|10 |6 |6 |

|3 |1 |3 |

|5 |5 |2 |

a. Draw the table which results from the following statement:

SELECT B

FROM finx

WHERE (A = C)

b. Draw the table which results from the following statement:

SELECT *

FROM finx

WHERE ((C>4) OR ((B>C) AND (A ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download