Information Science 1gulliver/is1/exercises/Answers/ALL...Information Science 1 Examples of answers...

13
Information Science 1 Examples of answers to Week 01 self-preparation assignments I. Why is this course (“Information Science”) taught in English? Write three most important, in your opinion, reasons: 1. Most computer science jobs in any country, including Japan, require knowledge of English. 2. Employees who speak English usually get higher salaries, have better careers, and are promoted sooner. 3. Ritsumeikan University requires this course to be taught in English. II. In the space below, list five major parts, which every modern personal computer has: 1. CPU 2. RAM 3. Network card 4. HDD (or SSD) 5. Graphics card III. a) A student missed (did not come to) 6 classes of “Information Science 1”. What mark will this student receive for the course? b) A student of “Information Science 1” was late to the class for 45min. Can this student take a quiz/test in the end of the class? How will this student’s attendance be registered? a) “F” b) Yes, the student can take the quiz/test in the end of the class. The student will, however, be registered as “Not attending” the class.

Transcript of Information Science 1gulliver/is1/exercises/Answers/ALL...Information Science 1 Examples of answers...

Information Science 1

Examples of answers to Week 01 self-preparation assignments

I. Why is this course (“Information Science”) taught in English? Write three most important, in your opinion, reasons:

1. Most computer science jobs in any country, including Japan, require knowledge of English.

2. Employees who speak English usually get higher salaries, have better careers, and are promoted sooner.

3. Ritsumeikan University requires this course to be taught in English. II. In the space below, list five major parts, which every modern personal computer has: 1. CPU 2. RAM 3. Network card 4. HDD (or SSD) 5. Graphics card III. a) A student missed (did not come to) 6 classes of “Information Science 1”. What mark will this student receive for the course? b) A student of “Information Science 1” was late to the class for 45min. Can this student take a quiz/test in the end of the class? How will this student’s attendance be registered? a) “F” b) Yes, the student can take the quiz/test in the end of the class. The student will, however, be registered as “Not attending” the class.

Information Science 1

Examples of answers to Week 02 self-preparation assignments

I. How many bits (exactly) in 0.125kB of memory? How many Bytes? 0.125kB = ___1024___bits = ____128__Bytes II. Draw the structure (main parts) of a CPU. Using the structure, draw the steps of the automatic sequence control (i.e. the phases of the fetch-execute cycle).

III. Draw a table of digital information units from bit to Petabyte. Indicate the corresponding notation symbols (i.e. B, kB, etc) and the unit sizes (in bytes). Unit name Symbol Exact size (Bytes) Approximate size (Bytes) bit b 1/8 1/8 Byte B 1 1 kilobyte kB 210 1,000 megabyte MB 220 1,000,000 gigabyte GB 230 1,000,000,000 terabyte TB 240 1,000,000,000,000 petabyte PB 250 1,000,000,000,000,000

1. Fetch an instruction 2. Decode the instruction

3. Fetch operands

4. Execute

5. Store the result

6. Fetch next instruction

Information Science 1

Examples of answers to Week 03 self-preparation assignments

I. Perform the specified conversions for these decimal, binary, base-8, and base-16 unsigned numbers: 1010010011.110(2 = __659.75____(10 = ___1223.6_____(8 = ___293.C_____(16 1023.25 = __3FF.4____(16 = __1111111111.01___(2 = ___1777.2____(8 512.44(8 = _____330.5625__(10 = __101001010.1001___(2 = ___14A.9___(16 E10Ah = _160412_(8 = ___1110000100001010____(2 = ___57610____(10 II. Circle only correct statements: a) This is a valid radix-5 number: 451(5 b) This is a valid hexadecimal number: 1516h c) A nibble is also called “hextet” d) 1 Megabyte ≈ 1,000,000 bytes III. Match left and right sides: • PC 3__ 1) is volatile • computer word 4__ 2) is also called Automatic Sequence Control • Fetch-Execute Cycle 2__ 3) stores the address of the next instruction • USB 5__ 4) determines the size of a memory cell • RAM 1__ 5) is a computer bus • ROM 6__ 6) is not volatile

IV. Perform the following conversions: 2113.11(4 =_151.3125_____(10 102001.2(3 ≈_298.666667_(10

Information Science 1

Examples of answers to Week 04 self-preparation assignments

I. Assume unsigned 24-bit numbers and perform the following calculations:

a) CCAB02(16 – F2600C(16 = ___–11332412____ (8 b) 0EA60014(16 + 41205016(8 = __F2B0A22__ (16 c) 010010(16 × 000001101010001010010001(2 = ____324276624420___ (8

II. Assume unsigned 12-bit numbers and perform the following calculations:

a) 384(16 / 36(8 = ___000000011110__ (2 b) 7068 / 2(8 = __DCE__ (16 c) 000100101100(2 / 7(8 ≈ _101010.11011011_ (2

III. Write the BCD code for the following (unsigned) numbers:

a) 121009 = _000100100001000000001001_ (BCD b) BA3(16 = _2979(10_=_0010100101111001__ (BCD

c) 2222(8 = _1170(10_=_0001000101110000___ (BCD

IV. Match the definitions:

• BCD _5_ 1) can be denoted with “hex” • Gray code _4_ 2) 8 • Carry or borrow in octal _2_ 3) 7 • Base-16 _1_ 4) reflected binary code • Base-2 _6_ 5) binary coded decimal • Largest single octal digit _3_ 6) the longest number representation

Information Science 1

Examples of answers to Week 05 self-preparation assignments

I. Assume 12-bit 2’s complement and perform the following calculation. Does an overflow occur?

a) EEAh – F07h = __FE3h Overflow? _No_ (Yes or No) b) 7002(8 – C0Dh = _0765(8 Overflow? _No_ (Yes or No) c) 625h + 534h = _5531(8 Overflow? _Yes (Yes or No) d) 76Bh + 7166(8 = _5E1h Overflow? _No_ (Yes or No)

II. Assuming 2’s complement, convert these 12-bit numbers to decimal:

a) 111110000111(2 = _-121__ (10 b) 000100010101(2 = _277__ (10 c) 9A0h = _-1632_ (10 d) 6205(8 = __-891__ (10

III. Convert the following decimal numbers to their 12-bit binary equivalents:

a) –1500 = _101000100100(2’s complement = _110111011100(signed magnitude b) –1026 = _101111111110(2’s complement = _110000000010(signed magnitude

c) 568 = _001000111000(2’s complement = 001000111000(signed magnitude

IV. Match the definitions:

• range in signed magnitude _1_ 1) from –2n-1 + 1 to 2n-1 – 1 • range in 2’s complement _3_ 2) binary arithmetic overflow • NaN _5_ 3) from –2n-1 to 2n-1 – 1 • result out of range _2_ 4) all the bits are inverted • 2’s complement _6_ 5) a special value in IEEE 754 • 1’s complement _4_ 6) used to store negative integers

Information Science 1

Examples of answers to Week 06 self-preparation assignments

I. Draw a flowchart of an algorithm for the following problem: Input three numbers, a, b, and c. Print first the number that has the greatest square and then the number that has the second greatest square. II. Write a pseudocode of an algorithm for the following problem: Get 100 negative numbers, and for every input number less than –10 but greater than –1000, print its value. 1. Set counter i ← 1 2. Input a number, xi 3. If xi ≥ 0 then

Print “Only negative numbers, please!” and Go to Step 2

4. If –1000 < xi < -10 then Print xi

5. i ← i+1 6. If i ≤ 100 then

Go to Step 2 7. Terminate

III. Match words with definitions:

• Waterfall _e_ a) Simplified English • Pseudocode _a_ b) Unified modeling language • Hierarchy chart_c_ c) Shows the overall system’s structure • Flowchart _d_ d) A logic diagram of an algorithm • UML _b_ e) A model of program life-cycle

Information Science 1

Examples of answers to Week 08 self-preparation assignments

I. Draw a flowchart of an algorithm for the following problem: Input 10 negative integers, 10 positive integers, and calculate and print their sum. II. Find (circle) all the errors in the following pseudocode:

final int COUNT=250; float 1_d,2_b,coefficient_2; int coefficient_1; input d,b; coefficient_1=coefficient_1+COUNT-d/b; print coefficient_2, coefficient; stop;

III. Evaluate the following arithmetic expressions. For each expression, assume int z=2.2, char y=’d’ and float x= –11.2 1.) x=z/3*5 – y x=_–100.0 2.) x=z*x x=_–22.4_ 3.) z=(x + 0.2) / 2 z=_–5____ 4.) y=4.5*z/4 + y y=_’f’____

Start

Get x

Print S

TRUE x > 0 && np <N

FALSE

Stop

N=10; nn , np =0; S =0;

S = S + x ; np++

x < 0 && nn <N TRUE

S = S + x ; nn ++

FALSE x == 0 ||

( nn <N|| np <N)

TRUE

FALSE

“ Repeat input ”

Information Science 1

Examples of answers to Week 09 self-preparation assignments

I. Evaluate arithmetic expressions in the pseudocode below. Describe the evaluation process, using comment statements in appropriate places of the pseudocode:

// Pseudocode begins here: int x,y; float a; x = 2.3; //x is assigned 2 a = 6.6/x; //a is assigned 3.3 y = ++x + a; //x gets 3, then y is assigned 6 y = y-- /5+1; //y is assigned 2, then y gets 1 x = a +.7+ y; //x is assigned 5 a = x - ++y +.5; //y gets 2, then a is assigned 3.5 x = 21/2%7; //x is assigned 3 y = (int)a * 1.5; //y is assigned 4 a = a - x%y; //a is assigned 0.5 // Pseudocode ends here.

II. Select the correct operator precedence:

= _5_ 1) 1 (highest precedence) preincrement _1_ 2) 2 + _4_ 3) 3 () _2_ 4) 4 / _3_ 5) 5 (lowest precedence)

III. Write the data types listed in order from narrowest (least precise) to widest (most precise): ___2. double (widest) 1. int ___4. float __ 2. double ___1. int ____ 3. char

___3. char __ 4. float ___5. boolean (narrowest) 5. boolean

Information Science 1

Examples of answers to Week 10 self-preparation assignments

I. Evaluate the following expressions for the Boolean values x=TRUE, y=FALSE, and z=TRUE by circling TRUE or FALSE. Use Boolean arithmetic for * and +.

a. (x||!z)&&(y||!y)&&!(z||!x) TRUE FALSE

b. (y||(!x&&!y&&z))&&x TRUE FALSE

c. !!((!(x||z)&&!x||!x)) TRUE FALSE

d. x OR z AND NOT(y) TRUE FALSE

e. (!(x+y+z)&&!(x*y*z)) TRUE FALSE

f. NOT(x+y*z) TRUE FALSE

II. Draw the Truth Table for F(x,y,z), including all possible combinations of Boolean x, y, and z. F(x,y,z) = x&&!y&&!z||x&&!y&&z||!x&&y III. For a truth table below, write G(x,y,z) in the form of a Boolean expression. G(x,y,z) = x&&!y&&!z||x&&y&&!z||!x&&y&&z||!x&&!y&&!z||x&&!y&&z

x y z F(x,y,z) 1 0 0 1 0 1 0 1 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 0 1 0 1 1 1 1 1 0

x y z G(x,y,z) 1 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 0 1 1 1 0 0 0 1 1 0 1 1 1 1 1 0

Information Science 1

Examples of answers to Week 11 self-preparation assignments

I. Match each concept on the left with the appropriate description on the right: · Indentation _d__ a) executes 0 or more times · “While” loop _a__ b) executes 1 or more times · Infinite loop _e__ c) a special constant used in event-controlled loops · “Do…While” loop _b__ d) ignored by computers · Sentinel _c__ e) executes “forever” II. What is the printed output of the following pseudocode?

int i=1; char j=’A’; for (; i >= -3; i=i-2) if (i==0)

print j+i; else

j=j+1; print j;

Output: 68 or ‘D’ III. Select the correct operator precedence: · != _5_ 1) 1 (highest precedence) · NOT _1_ 2) 2 · OR _7_ 3) 3 · AND _6_ 4) 4 · = _8_ 5) 5 · (post)++ _9_ 6) 6 · < _4_ 7) 7 · + _3_ 8) 8 · / _2_ 9) 9 (lowest precedence)

Information Science 1

Examples of answers to Week 12 self-preparation assignments

I. Write (e.g. in pseudocode) an example of a “while” loop which prints “7, 9, 11, 13”, and then re-write it as a “do while” loop.

int i=7; int i=7; while(i<14){ do { Print i; Print i; i=i+2;} i=i+2;} while(i<14)

II. What is the printed output of the following pseudocode?

int i=3; char j=’B’; //’B’ is ASCII 66 for (; i >= -2; i=i-1) if (i==0) j++; else print i;

print j; Output(s):__321-1-2C_______

III. Convert the following circuit diagram into a Boolean expression: X=__ A C A D B C B D∧ ∨ ∧ ∨ ∧ ∨ ∧ _

Information Science 1

Examples of answers to Week 13 self-preparation assignments

I. Find and circle all errors in the following algorithm: II. Select “TRUE” or “FALSE” for the following statements: a. Parameter passing by reference may cause side effects TRUE

b. “myBool = FALSE” is an assignment statement TRUE

c. “char” is an integer-compatible data type TRUE

d. while(1 > 2) is an infinite loop FALSE

e. An n-dimensional array has n+1 indices FALSE

f. ‘\0’ is a non-printable character TRUE

III. What is the results of the following assignments? (For each assignment, set float z=-2. and int x=4.3)

a. x=int(2*z) % x++ x=_1___

b. x=z+7-x x=_1___

c. x=x * 2.5 / (z + 2) x=_”ERROR” because

“infinity” (the result of the division) is not

defined for the integer data type

d. x=7 % 2 - ++x + z x=_-6__

Start

N=N-5

FALSE

35<NFALSE

Stop

Input N

Print N

Information Science 1

Examples of answers to Week 14 self-preparation assignments

I. For the operators on the left, write down the correct operator precedence:

• % _3____ a) 1 (highest precedence)

• OR _8____ b) 2

• == _6____ c) 3

• NOT _2____ d) 4

• + _4____ e) 5

• AND _7____ f) 6

• < _5____ g) 7

• ( ) _1____ h) 8 (lowest precedence)

II. Use De Morgnan’s Law and simplify the following expression: !(y>=−10 && y<=5) ! __(y<−10 || y>5)___ III. Match left and right: • UML _ c ____ a) Linearly, from the beginning to EOF

• Pseudocode _ b ____ b) A text-based design tool

• Logical file _ e ____ c) A graphical design tool

• Physical file _ d ____ d) Collection of bits on a SS I/O device

• Random access _ f ____ e) Interface to access data on a SS I/O device

• Sequential access _ a ____ f) Uses an index file or hash function