Introduction to Computers 第三次考試 授課教授 : 李錫智. 第一題 [15] Suppose random(x,y) returns an integer randomly between x and y inclusively. Consider the following.

Slides:



Advertisements
Similar presentations
1 RTL Example: Video Compression – Sum of Absolute Differences Video is a series of frames (e.g., 30 per second) Most frames similar to previous frame.
Advertisements

The Binary Numbering Systems
Introduction to computers Exam 2 授課教授:李錫智. Question_1 For the following program: Suppose the user enters 43 、 57 in the text boxes numberBox1 and numberBox2,
Form Validation. Learning Objectives By the end of this lecture, you should be able to: – Describe what is meant by ‘form validation’ – Understand why.
Introduction to Computers - 3 rd exam- 授課教授:李錫智. 1.Consider the following program: Magic 8-ball function GetResponse()
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
Introduction to Computers - 2 nd exam- 授課教授:李錫智. 1. Double the Number
Skills: none Concepts: the amount of information in an image This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.
Introduction to Computers -1 st exam- 授課教授:李錫智. 1. Given 12 bits, (a).How many different distinct combinations can we get from these bits? Ans: 2 12 =
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 1 按一下以編輯母片標題樣式 按一下以編輯母片 第二層 第三層 第四層 第五層 1 Problem E: Jolly Jumpers A sequence of n > 0 integers is called a jolly.
Connecting with Computer Science, 2e
Representing Information as Bit Patterns
Introduction to Programming with Java, for Beginners
CS430 © 2006 Ray S. Babcock CS430 – Image Processing Image Representation.
Chapter 1 Data Storage. 2 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns.
Last time 3 main components to a computer system Types of computers Talked about software – task oriented What are some kinds of data that a computer works.
Chapter 1 The Big Picture. QUIZ 2 5 Explain the abstractions we normally apply when using the following systems: DVD player Registering for classes on.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Chapter 5 Data representation.
TERMS TO KNOW. Programming Language A vocabulary and set of grammatical rules for instructing a computer to perform specific tasks. Each language has.
©Brooks/Cole, 2003 Chapter 2 Data Representation.
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Binary Representation. Binary Representation for Numbers Assume 4-bit numbers 5 as an integer  as an integer  How? 5.0 as a real number  How?
Introduction to Computers -3rd exam- 授課教授:李錫智. Q1 What will the web page look like if the user type 100 、 20 in the numberbox1 、 numberbox2 respectively?
Computers Organization & Assembly Language
Representing Information Digitally. Digitization Initially transforming data for computer use Assigning people social security numbers The creation of.
Welcome Topic: Pixels A.M.Meshkatur Rahman Class: vii Roll: 07.
Chapter 11 Fluency with Information Technology 4 th edition by Lawrence Snyder (slides by Deborah Woodall : 1.
Shawlands Academy Higher Computing Data Representation.
07/10/ Strings ASCII& Processing Strings with the Functions - Locate (Instr), Mid, Length (Len), Char (ChrW) & ASCII (Asc)
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Idea 1: Bits Two states in a digital machine: 1.presence of.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Agenda Last class: Memory, Digitizing Numbers Today: Digitizing: Text
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Introduction to Computers -Final exam- 授課教授:李錫智. Q1 Write a function named Reverse that takes a string as input and returns a copy of that string in reverse.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Computer Vision Introduction to Digital Images.
CS 111 – Sept. 3 More data representation Review hex notation Text –ASCII and Unicode Sound and images Commitment: –For Wednesday: Please read pp
Introduction to Probability Theory ‧ 3- 1 ‧ Speaker: Chuang-Chieh Lin Advisor: Professor Maw-Shang Chang National Chung Cheng University Dept. CSIE, Computation.
DATA REPRESENTATION CHAPTER DATA TYPES Different types of data (Fig. 2.1) The computer industry uses the term “MULTIMEDIA” to define information.
CSC 1010 Programming for All Lecture 7 Input, Output & Graphics.
Introduction to computers 103 學年度 上學期 Solution of Homework_ch12 授課教授:李錫智.
Data Representation. What is data? Data is information that has been translated into a form that is more convenient to process As information take different.
Chapter2 Constants, Variables, and Data Types. 2.1 Introduction In this chapter, we will discuss –constants (integer, real, character, string, enum),symbolic.
INTRODUCTION TO COMPUTERS 2nd exam solution. Question 1 Suppose that you are given a group of non-negative numbers and you are asked to arrange them in.
Data Structures -2 nd exam- 授課教師 : 李錫智 教授 1. 1.[10] Please answer the following questions about stack: What is the response of the statement “(new stack()).isEmpty()”?
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,
Introduction to Computers -1 st exam- 授課教授 : 李錫智 教授.
Chapter 3: Data Representation Chapter 3 Data Representation Page 17 Computers use bits to represent all types of data, including text, numerical values,
Lecture Exercise (Wk4) CS1301 Introduction To Computer Programming (11-12 Semester B) Page 1 Question 2 (a)Complete the code.
Scanner Scanner Introduction: Scanner is an input device. It reads the graphical images or line art or text from the source and converts.
INTRODUCTION TO COMPUTERS
1 Chapter 8 - Characters and Strings Outline 8.1Introduction 8.2Fundamentals of Strings and Characters 8.3Character Handling Library 8.4String Conversion.
Introduction to Computers - 4 th exam- 授課教授:李錫智. Hints: ADD [DR] [SR1] [SR2] DR SR1 SR2 SUB [DR] [SR1] [SR2] DR.
Data Structures -3 rd exam- 授課教師 : 李錫智 教授. 1.[10] Please answer the following questions about queue: [ 2] What is the response of the statement: “(new.
Lec 3: Data Representation
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
CSCI 198: Lecture 4: Data Representation
How to Convert Pictures into Numbers
CSCI 161: Lecture 4: Data Representation
What do these words mean to you?
Ch2: Data Representation
- orange white green - cyan - red - blue Example 1 24 bit RGB
4.1 Strings ASCII & Processing Strings with the Functions
Chapter 2 Data Representation.
Data Representation Chapter 2 Computer HW (Von Neumann Model) Program
- orange white green - cyan - red - blue Example 1 24 bit RGB
Java-Assignment #4 (Due, April. 9, 2004)
Presentation transcript:

Introduction to Computers 第三次考試 授課教授 : 李錫智

第一題 [15] Suppose random(x,y) returns an integer randomly between x and y inclusively. Consider the following program: Just for Fun function GetResponse() { var response; if (document.getElementById('inputArea').value == "") { alert("What is your question?"); } else { response = random(1,5); document.getElementById('outputBox').value = response; }

Have a Fun Enter your question in the text area below: The page says:

(a) [5] What is the content of the “outputBox” without any user’s input? (b) [5] What happens if the user hits the button without any other input? (c) [5] What happens if the user hits the button after entering “How are you?” in the text area? (a) 空白 (b) 跳出警告視窗,警告視窗上的字為 What is your question? (c)OutputBox 會顯示一個 1~5 之間的隨機亂數 Ans:

第二題 [20] Consider the following program: Another Fun function XXX() { var goal, redPos, bluePos; goal = parseFloat(document.getElementById('len').value); redPos = parseFloat(document.getElementById('redDot').value); bluePos = parseFloat(document.getElementById('blueDot').value); if (redPos < goal && bluePos < goal) { redPos = redPos + 3; bluePos = bluePos + 5; document.getElementById('redDot').value = redPos; document.getElementById(‘blueDot’).value = bluePos; }

if (redPos >= goal && bluePos >= goal) { alert(“It‘s a tie!”); } else if (redPos >= goal) { alert(“Red Dot wins!”); } else if (bluePos >= goal) { alert(“Blue Dot wins!”); } } Dave's Online Dot Race Race length: Red Dot : : Blue Dot

(a) [10] What is the output of the program if the user types 10 in the “len” box, 7 in the “redDot” box, 9 in the “blueDot” box, and hits the button? (b) [10] What is the output of the program if the user types 20 in the “len” box, 27 in the “redDot” box, 19 in the “blueDot” box, and hits the button? (a) 跳出警告視窗,警告視窗上的字為 It’s a tie ! (b) 跳出警告視窗,警告視窗上的字為 Red Dot wins ! Ans:

第三題 [15] A grayscale image is one in which each pixel can be white, or black, or various shades of gray in between. On the other hand, a color image is one in which each pixel contains three components, red, green, and blue. Assuming that there are 256 discernable shades of gray. Also, assume that there are 256 different values for red, green, and blue, respectively. Suppose you are given an image of 1024×1024 pixels.

(a) [2] How many Mega bits are required for the image if it is a grayscale one? (b) [3] How many Mega bits are required for the image if it is a color one? (c) [5] How many Mega bits are required for a video of 2 hours? Suppose a video requires 30 images per second? (d) [5] How many Mega bits are required for the video if you compress the video using Mpeg which has a compression ratio 100:1? Note that when an image file of size K is compressed with a compression ratio of a:1, the resulting image file would be of size K/a (a)1024*1024*8=8Mbits (b)1024*1024*8*3=24Mbits (c)1024*1024*8*3*30*3600*2= Mbits (d) /100=51840Mbits Ans:

第四題 [10] Assume that random(x,y) returns an integer between x and y inclusively. Please write a program to record the number of occurrences of 5 when random(1,6) is called 1,000 times. Please show the number in a text box. Also, the user has to hit the button in order to start the counting.

function count() { var num=1000,temp,count_five=0; while(num>=1) { temp=Math.floor(Math.random()*6+1); num=num-1; if(temp==5) { count_five=count_five+1; } document.getElementById('text').value=count_five; } Ans:

第五題 [10] Predict the output sequences that would be produced by each of the following while loops. (a) [5] num = 1; while (num >= 5 && num <= 30) { document.write(num + " "); num = 3*num + 1; } document.write("DONE WITH FIRST!"); DONE WITH FIRST ! Ans:

(b) [5] x = 1; y = 30; while (x < y) { document.write(x + " " + y + " "); x =2* x + 1; y = y – 2; } document.write("DONE WITH SECOND!"); DONE WITH SECOND ! Ans:

第六題 [12] Consider the following code segment: If (x > y) { y = x; } else if (x < y) { x = 100; } else { y = -50; } document.write(“x = “ + x + “, y = “ + y); Given the following assignments, predict the output that the preceding code would produce: (a) x = -7, y = 8; (b) x = 15, y = 3; (c) x = -8, y = -8; (d) x = 0, y = -9. (a) x=100, y=8 (b) x=15, y=15 (c) x=-8, y=-50 (d) x=0, y=0 Ans:

第七題 [18] Using the IEEE Single-Precision Floating-Point Representation (32 bits), please answer the following questions: (a) What is the bit string for the decimal number ? (b) What is the decimal number for the bit string ? (c) How many bytes for sending the following sequence in ASCII codes?“Hello, I am John. How are you doing? Have fun!?#” (d) What is the smallest positive single-precision value denoted in bit string? (e) What is the largest positive single-precision value denoted in bit string? (f) What is the smallest negative single-precision value denoted in bit string? Hint: The case of all zeros in the EXPONENT field is reserved for representing 0.0 (real zero).

Ans: