Introduction to computers Exam 2 授課教授:李錫智. Question_1 For the following program: Suppose the user enters 43 、 57 in the text boxes numberBox1 and numberBox2,

Slides:



Advertisements
Similar presentations
The Divide-and-Conquer Strategy
Advertisements

2010/12/12
Introduction to Computers - 3 rd exam- 授課教授:李錫智. 1.Consider the following program: Magic 8-ball function GetResponse()
布林代數的應用--- 全及項(最小項)和全或項(最大項)展開式
:Word Morphing ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10508:word morphing 解題者:楊家豪 解題日期: 2006 年 5 月 21 日 題意: 第一行給你兩個正整數, 第一個代表下面會出現幾個字串,
Section 1.2 Describing Distributions with Numbers 用數字描述分配.
Instructor: Ching-Chi Lin 林清池 助理教授
授課教授:李錫智 Data Structures -2 nd exam-. 1.[15] A simple way for implementing the vector ADT is to use an array A, where A[i] stores the element at rank.
指導教授:陳淑媛 學生:李宗叡 李卿輔.  利用下列三種方法 (Edge Detection 、 Local Binary Pattern 、 Structured Local Edge Pattern) 來判斷是否為場景變換,以方便使用者來 找出所要的片段。
Introduction to Computers - 2 nd exam- 授課教授:李錫智. 1. Double the Number
: Boxes ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11003: Boxes 解題者:蔡欣燁 解題日期: 2007 年 3 月 19 日.
:New Land ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11871: New Land 解題者:施博修 解題日期: 2011 年 6 月 8 日 題意:國王有一個懶兒子,為了勞動兒子,他想了一個 辦法,令他在某天早上開始走路,直到太陽下山前,靠.
: OPENING DOORS ? 題組: Problem Set Archive with Online Judge 題號: 10606: OPENING DOORS 解題者:侯沛彣 解題日期: 2006 年 6 月 11 日 題意: - 某間學校有 N 個學生,每個學生都有自己的衣物櫃.
: ShellSort ★★☆☆☆ 題組: Problem D 題號: 10152: ShellSort 解題者:林一帆 解題日期: 2006 年 4 月 10 日 題意:烏龜王國的烏龜總是一隻一隻疊在一起。唯一改變烏龜位置 的方法為:一隻烏龜爬出他原來的位置,然後往上爬到最上方。給 你一堆烏龜原來排列的順序,以及我們想要的烏龜的排列順序,你.
: The Playboy Chimp ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10611: The Playboy Chimp 解題者:蔡昇宇 解題日期: 2010 年 2 月 28 日 題意:給一已排序的數列 S( 升冪.
Introduction to Java Programming Lecture 5: Using Java Classes : String & Math Spring 2009.
計算機概論 - 排序 1 排序 (Sorting) 李明山 編撰 ※手動換頁.
: Fast and Easy Data Compressor ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10043: Fast and Easy Data Compressor 解題者:葉貫中 解題日期: 2007 年 3.
: Ahoy, Pirates! ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11402: Ahoy, Pirates! 解題者:李重儀 解題日期: 2008 年 8 月 26 日 題意:有一個海盜島有 N 個海盜,他們的編號 (id)
: Multisets and Sequences ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11023: Multisets and Sequences 解題者:葉貫中 解題日期: 2007 年 4 月 24 日 題意:在這個題目中,我們要定義.
程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷
資料結構實習-一 參數傳遞.
第六章 陣列.
Lecture 7 Sorting in Linear Time. Sorting in Linear Time2 7.1 Lower bounds for sorting 本節探討排序所耗用的時間複雜度下限。 任何一個以比較為基礎排序的演算法,排序 n 個元 素時至少耗用 Ω(nlogn) 次比較。
: Lucky Number ★★★★☆ 題組: Proble Set Archive with Online Judge 題號: 10909: Lucky Number 解題者:李育賢 解題日期: 2008 年 4 月 25 日 題意:給一個奇數數列 1,3,5,7,9,11,13,15…
演算法 8-1 最大數及最小數找法 8-2 排序 8-3 二元搜尋法.
Review of Chapter 9 張啟中. Inheritance Hierarchy Min PQ Max PQ Min Heap Mergeable Min PQ DeapMin-Max Min-LeftistMin-SkewMinFHeap MinBHeap DEPQMax Heap Symmetric.
845: Gas Station Numbers ★★★ 題組: Problem Set Archive with Online Judge 題號: 845: Gas Station Numbers. 解題者:張維珊 解題日期: 2006 年 2 月 題意: 將輸入的數字,經過重新排列組合或旋轉數字,得到比原先的數字大,
Chapter 10 m-way 搜尋樹與B-Tree
: Function Overloading ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11032:Function Overloading 解題者:許智祺 解題日期: 2007 年 5 月 8 日 題意:判對輸入之數字是否為.
: Where is the Marble? ★☆☆☆☆ 題組: VOLUME CIV 題號: Q Where is the Marble? 解題者:劉淑惠 解題日期: 2006 年 6 月 11 日 題意:有許多上面有號碼的彈珠,將彈珠上面的 號碼由小到大排列,找出某個號碼的第一顆彈珠.
演算法課程 (Algorithms) 國立聯合大學 資訊管理學系 陳士杰老師 Course 7 貪婪法則 Greedy Approach.
計算機概論 第6章 數位邏輯設計.
: Dream ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 11414: Dream 解題者:李育賢 解題日期: 2008 年 9 月 2 日 題意: 題目會給你一個數字代表測資的數量 ( 最多 100 組 ) , 每組測資第一個數字是此圖形點的個數.
: Problem E Antimatter Ray Clearcutting ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11008: Problem E Antimatter Ray Clearcutting 解題者:林王智瑞.
-Artificial Neural Network- Chapter 5 Back Propagation Network
:Commandos ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 11463: Commandos 解題者:李重儀 解題日期: 2008 年 8 月 11 日 題意: 題目會給你一個敵營區內總共的建築物數,以及建築物 之間可以互通的路有哪些,並給你起點的建築物和終點.
Introduction to Java Programming Lecture 12 Method Benefits, Declaring, and Calling Methods.
I/O of C and C++. printf and scanf of C Should add printf (“control string”, exp1, exp2,…) Scanf(“control string”, &var1, &var2,…)
: Finding Paths in Grid ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11486: Finding Paths in Grid 解題者:李重儀 解題日期: 2008 年 10 月 14 日 題意:給一個 7 個 column.
Chapter 2 Introduction to C Programming Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Introduction to Computers -3rd exam- 授課教授:李錫智. Q1 What will the web page look like if the user type 100 、 20 in the numberbox1 、 numberbox2 respectively?
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
JavaScript – Part II Data Types and Operations George Mason University June 3, 2010.
Introduction to Computers 第三次考試 授課教授 : 李錫智. 第一題 [15] Suppose random(x,y) returns an integer randomly between x and y inclusively. Consider the following.
Introduction to PASS, and Exercises on Operators and Basic I/O.
Data Structures -1 st test- March 30, 2015 授課教授:李錫智.
Computer Programming 2 Lab(1) I.Fatimah Alzahrani.
Introduction to computers 103 學年度 上學期 Solution of Homework_ch1 授課教授:李錫智.
Q and A for Sections 2.9, 4.1 Victor Norman CS106 Fall 2015.
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.
Introduction to computers 103 學年度 上學期 Solution of Homework_ch12 授課教授:李錫智.
Data Structures -3 rd test- 2015/06/01 授課教授:李錫智. Question 1 Suppose we use an array to implement a sorted list. Please answer the following questions.
Data Structures -Final exam- 2015/6/22 授課教授:李錫智. Question 1. Let a hash table have 13 entries. Suppose we have 10 integer keys: 68, 100, 58, 80, 72, 101,
Data Structures -3 st exam- 授課教師 : 李錫智 教授. 1. [5] Assume we have a binary tree which is implemented in a pointer-based scheme. Describe how to know the.
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()”?
Introduction to Programming
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
Introduction to Computers -1 st exam- 授課教授 : 李錫智 教授.
Data Structures -1 st exam- 授課教師 : 李錫智 教授. 1.[10] Suppose we have the ADT Bag which has the following operations: bool isEmpty(): tests whether Bag is.
INTRODUCTION TO COMPUTERS
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
Introduction to Computers - 4 th exam- 授課教授:李錫智. Hints: ADD [DR] [SR1] [SR2] DR SR1 SR2 SUB [DR] [SR1] [SR2] DR.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Data Structures -3 rd exam- 授課教師 : 李錫智 教授. 1.[10] Please answer the following questions about queue: [ 2] What is the response of the statement: “(new.
Introduction to Programming
Precedence Operators Error Types
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Python Creating a calculator.
Presentation transcript:

Introduction to computers Exam 2 授課教授:李錫智

Question_1 For the following program: Suppose the user enters 43 、 57 in the text boxes numberBox1 and numberBox2, respectively. What value will then be shown in the text box numberBox3 after the user hits the button? Add the Number <input type="button" value="Add the number:" onclick=" num1 = document.getElementById('numberBox1').value; num2 = document.getElementById('numberBox2').value; document.getElementById('numberBox3').value = num1 + num2;" />

Solution of Q1 Ans:4357 Because that the user type the numbers in TextBox, value of the TextBox is ‘Strings’ type. When we plus two of them, it’s equal to ‘strings_1’ + ‘strings_2’.

Question_2 Please design a web page that can estimate the BMI (Body Mass Index) of the user. The user enters his/her height (in meter) and weight (in kilogram) in two text boxes. After the user hits the button, the calculated BMI (BMI = weight/ height2) is shown in the third text box. A. [10%] Please develop your program without function calls. Show the resulting program. B. [10%] Please develop your program. It is required that a function call be used for the onclick part of the button. Show the resulting program.

Solution of Q2-A

Solution of Q2-B

Question_3 Can the program work? If it works, what does the webpage look like on the screen? If it does not work, please point out the syntax error(s) and correct the error(s). Personal Information Name =prompt("Please enter your name",""); Age =prompt("Please enter your age",""); Gender =prompt("Please enter your gender",""); document.write(" Student Name: "+ Name + " "); document.write(" Age: "+Age+" "); document.write(" Gender: " + Gender+" "); document.write(" ");

Solution of Q3 Ans: It’s not work. “…” and ‘…’ are a nested quotas. document.write(" Student Name: "+ Name + " "); That will be cause syntax error. We should correct it by using following descript: document.write(" Student Name: "+Name+" ");

Question_4 There are three classes. Five students are in Class A, and their heights are [ ] cm. Six students are in Class B, and their heights are [ ] cm. Five students are in Class C, and their height are [ ] cm. Suppose that you are going to pick the five tallest students of all these classes to organize a basketball team. All students in the team should be sorted in ascending order. Please describe an algorithm for completing this task step by step.

Solution of Q4 Ans: 1. Class A, Class B 與 Class C 分別排成三排,位置由 1 開始編號,並且按照身高由高到矮進 行排序, i 用來表示 Class A 同學的位置, j 用來表示 Class B 同學的位置, k 用來表示 Class C 同學的位置, n 用來表示 team 的空間, ( 以 D[ n ] 代表,) 2. 令 i=1 、 j=1 、 k=1 、 n=5 3. 比較 A 的第 i 個位置的值 ( 以 A[ i] 表示 ) 、 B 的第 j 個位置的值 ( 以 B[ j ] 表示 ) 與 C 的第 k 個位置 的值 ( 以 C[ k ] 表示 ) ,比較 A[ i ] 、 B[ j ] 、 C[ k ] 最大的放入 D[n] ,假設 A[i] 最大,執行 i=i+1 、 n=n-1 , (B[j] 、 C[k] 最大同理 ) 。 4. 重複 (3) ,直到 n<1 則停止。

Question_5 Suppose there is a line of books sorted by book numbers in ascending order. George wants to find a book by its book number. A. [5%] Please show an algorithm of order O(n) to do the job. Please explain why it is O(n). B. [5%] Please show an algorithm of order O(log(n)) to do the job. Please explain why it is O(log(n)).

Solution of Q5 Ans: Q5-A:Compare the specific index number with each book in sequence until we find the book. If there are N books in this sequence, we will compare N times at most. Cost time is proportional to the amount of data, so it is O(n). Q5-B:Divide the sequence from the median into two parts and find which new sequence contains the specific book. Repeat this operating until only one book left in sequence, and it’s the answer. Every time the operating can eliminate half numbers in sequence, it means that if we want to find a specific book among N books, we should have to operate log 2 (N) times. Cost time is proportional to log 2 (N), so it is O(log(n)).

Question_6 For the following program: The box after answer= will show “undefined” even that you enter a number in the box following x=. Please explain why, and show how to fix this bug by only adjusting the function. function squareValue(x) { x = x*x; } x= <input type="button" value="click here for x^2" onclick=" x = parseFloat(document.getElementById('value_x').value); x = squareValue(x); document.getElementById('answerBox').value = x; " /> answer=

Solution of Q6 Ans: We call the function, squareValue(x), but there are neither to assign global variable nor to return value after calculating. The value of ‘x’ is assigned to ‘nothing’ so that the answer can’t be shown expertly. We just adjust the function that add ‘return x’ additionally. function squareValue(x){ x = x*x; return x; }

Question_7 For the following program: What will the boxes Box_1, Box_2, and Box_3 show on this webpage? function funcCalc(x) { x = 2*x; document.getElementById('Box_2').value = x; } Box1 is x = 10; document.getElementById('Box_1').value = x; Box2 is funcCalc(x); Box3 is document.getElementById('Box_3').value = x;

Solution of Q7 Ans: 10, 20,10 The first time we assign x = 10 so that the value of Box_1 will be 10. (Be careful that when we declare ‘x’ in, the type of ‘x’ is global variables!) The second time we call the function funcCalc(x), the value of Box_2 will be 20. (Be careful that the ‘x’ will be local variables in function().) The third time we get ‘x’ again, we have two types of ‘x’, but local variables only be read in function. We just get value of ‘x’ in type of global variable x = 10, so the value of Box_3 will be 10.

Question_8 Please design the webpage of a simple checkout system to help customers to check their goods from a foreign e-shop. A. (5%) Describe your algorithm briefly. B. (5%) Design a function which can convert an amount of US dollars to another amount of NT dollars. C. (10%) Please develop your program. It is required that a function call be used for the onclick part of the button. Show the resulting program..

Solution of Q8-A Ans: 1. Get the value of pieceBox and translate string to floating type. 2. Calculate the cost of each goods by Price*Goods_pieces. 3. Add extra fee of shipping and sum up all the cost. 4. Get the value of exchange rate from TextBox and translate to float type. 5. Calculate the cost translate USD$ to NTD$ by Total*exchangeRate 6. Show the value of total sum in check price.

Solution of Q8-B

Solution of Q8-C