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.

Slides:



Advertisements
Similar presentations
DCMS: Training Manual Help Desk Management July, 2010.
Advertisements

College of Information Technology & Design
MATH 224 – Discrete Mathematics
Exercise (1).
Homework - Chapter 03 Solution.
SIS – NBS Online Specimen Tracking System Training
Computer Science 101 Efficiency and Complexity Analysis.
CS1010 Programming Methodology
Introduction to computers Exam 2 授課教授:李錫智. Question_1 For the following program: Suppose the user enters 43 、 57 in the text boxes numberBox1 and numberBox2,
Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,
Introduction to Computers - 3 rd exam- 授課教授:李錫智. 1.Consider the following program: Magic 8-ball function GetResponse()
: Arrange the Numbers ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 11481: Arrange the Numbers 解題者:李重儀 解題日期: 2008 年 9 月 13 日 題意: 將數列 {1,2,3, …,N}
Java Programming, 3e Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Introduction to Computers - 2 nd exam- 授課教授:李錫智. 1. Double the Number
0 Advanced Selection CE : Introduction to Software Development Week 3 Lecture 2.
Microsoft Excel 2003 Illustrated Complete with Excel Programming.
Algorithm Design Techniques: Induction Chapter 5 (Except Section 5.6)
CS107 Introduction to Computer Science Lecture 5, 6 An Introduction to Algorithms: List variables.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
: Flip Sort ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10327: Flip Sort 解題者:歐子揚 解題日期: 2010 年 2 月 26 日 題意:在這個問題中使用一種排序方式 (Flip) ,意思就是 只能交換相鄰的.
JavaScript Lesson 1 TBE 540. Prerequisites  Before beginning this lesson, the learner must be able to… Create a basic web page using a text editor and/or.
- SEARCHING - SORTING.  Given:  The array  The search target: the array element value we are looking for  Algorithm:  Start with the initial array.
Syndrome Decoding of Linear Block Code
Downloading and Installing PAF Insight PAF Insight can be easily downloaded Or can be installed from a CD A license is needed t0 activate the program.
Introduction to Computers -3rd exam- 授課教授:李錫智. Q1 What will the web page look like if the user type 100 、 20 in the numberbox1 、 numberbox2 respectively?
PYTHON PROGRAMMING Week 10 – Wednesday. TERMS – CHAPTER 1 Write down definitions for these terms:  Computation  Computability  Computing  Artificial.
CS 0004 –Lecture 8 Jan 24, 2011 Roxana Gheorghiu.
Review Binary Tree Binary Tree Representation Array Representation Link List Representation Operations on Binary Trees Traversing Binary Trees Pre-Order.
1 Chapter 1 MATLAB Primer This introductory chapter is relatively short and has as its main objective the introduction of MATLAB ® to the reader. This.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Mail merge I: Use mail merge for mass mailings Perform a complete mail merge Now you’ll walk through the process of performing a mail merge by using the.
Introduction to Computers 第三次考試 授課教授 : 李錫智. 第一題 [15] Suppose random(x,y) returns an integer randomly between x and y inclusively. Consider the following.
07/10/ Strings ASCII& Processing Strings with the Functions - Locate (Instr), Mid, Length (Len), Char (ChrW) & ASCII (Asc)
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
Integers BAA* Content covered Situation Some more to try Reflection Test yourself cards Thinking harder What are the possibilities? Warm up Choose the.
Chapter 3 Sec 3.3 With Question/Answer Animations 1.
Additional Problems.
Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems.
Introduction to Algorithms By Mr. Venkatadri. M. Two Phases of Programming A typical programming task can be divided into two phases: Problem solving.
Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! With Microsoft ® Office 2007 Intermediate Chapter.
The 2-Way Merge Problem 學生:曾羽銘.
Graphical User Interface You will be used to using programs that have a graphical user interface (GUI). So far you have been writing programs that have.
Java Programming, 2E Introductory Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
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.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
Sorting and Searching. Searching  Problem definition: Given a value X, return the index of X in the array if such X exist. Otherwise, return NOT_FOUND(-1).
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()”?
31/01/ Selection If selection construct.
CHAPTER EIGHT ARRAYS © Prepared By: Razif Razali1.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
CS 141 Computer Programming 1 Branching Statements.
Introduction to Programming Python Lab 5: Strings and Output 05 February PythonLab5 lecture slides.ppt Ping Brennan
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
INTRODUCTION TO COMPUTERS 1st exam solution. Question 1 Please answer the following questions: [5%] Show the page before the user pushes the button. [5%]
Lecture Exercise (Wk4) CS1301 Introduction To Computer Programming (11-12 Semester B) Page 1 Question 2 (a)Complete the code.
Linear Search Linear Search is a fundamental search algorithm. Linear search, also known as sequential search, is a process that checks every element in.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
JavaScript 101 Lesson 6: Introduction to Functions.
INTRODUCTION TO COMPUTERS
Document that explains the chosen concept to the animator 1.
Chapter 3 Chapter Summary  Algorithms o Example Algorithms searching for an element in a list sorting a list so its elements are in some prescribed.
Perform a complete mail merge Lesson 14 By the end of this lesson you will be able to complete the following: Use the Mail Merge Wizard to perform a basic.
ALGORITHMS AND FLOWCHARTS
Lecture 2 Introduction to Programming
Algorithm An algorithm is a finite set of steps required to solve a problem. An algorithm must have following properties: Input: An algorithm must have.
Chapter 8 Search and Sort
4.1 Strings ASCII & Processing Strings with the Functions
Programming Concepts and Database
Presentation transcript:

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 sequence from largest to smallest. You may organize a line that begins with the largest person and continues in descending order according to magnitude. Describe an algorithm for completing this task.

Solution of Q1 比較型的 Sorting Buble Sort Selection Sort Merge Sort Insertion Sort……

Question 2 Suppose you need to look up a specific number from a sequence of N numbers using sequential search. A.How many checks would be required, in the worst case, to find the number? B.How many checks would be required, in the best case, to find the number?

Solution of Q2 A.N B.1

Question 3 Consider the list of numbers shown below: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85] A.Which number in the list is the "easiest" to find using binary search? That is, which number could be located in the fewest number of checks? Please explain.

Question 3 B.Which number in the list is the "hardest" to find using binary search? That is, which number would require the largest number of checks? Please explain.

Solution of Q3 A.45 ,因為它為整個數列的中位數。 B.35 、 40 、 80 、 85 ,因為這幾個數都需要花 費 4 次比對。

Question 4 Recall that Newton’s algorithm uses the following expression to refine the square root of a positive number N: newApproximation = (oldApproximation + N/oldApproximation)/2

Question 4 Imagine that, while you are using Newton's algorithm, the approximations converge on the actual square root of N. Would the value change if you tried to further refine the square root? Why or why not?

Solution of Q4 不會,因為已經收斂了。 newApproximation=(oldApproximation+N/oldAp proximation)/2=oldApproximation

Question 5 Please answer the following questions: A.Show the page before the user pushes the button. B.Show the page after the user types 45 in the tempBox text box, types 12 in the windBox text box, and pushes the button.

Question 5

Solution of Q5-A

Solution of Q5-B

Question 6 Please answer the following questions: A.Show the page if the user pushes the button without typing anything in the inputBox text box. B.Show the page after the user types in “I am sad.” and pushes the button.

Question 6

Solution of Q6-A

Solution of Q6-B

Question 7 Please answer the following questions: A.Show the page after the user types 25 in the redDot text box, types 30 in the blueDot text box, and pushes the button. B.Show the page after the user types 5 in the len text box, types 4 in the redDot text box, types 4 in the blueDot text box, and pushes the button.

Question 7

Solution of Q7-A

Solution of Q7-B

Question 8 Create a Web page that reads in an intgeger number entered by the user and then determines whether that number is even positive, odd positive, negative, or zero. The page should contain a text box in which the user can enter the number and a button for initiating the analysis.

Question 8 When the user inputs the desired number and clicks the button, a function should be called to identify the number’s type and display the result in an alert box.

Solution of Q8

Question 9 Create a Web page that prompts the user to enter a specific number of years and then displays the corresponding time in seconds. Assume that all years consist of exactly 365 days.

Question 9 Your page should include the definition of a function named YearsToSeconds that requires one input a value corresponding to a number of years--and returns the equivalent time in seconds, and another definition of a function named DoConversion that reads the number of years from a text box, calls the function YearsToSeconds, and displays the number of seconds in another text box after the user enters the number and pushes the button.

Solution of Q9

Question 10 A.Consider the following code segment Given x=23 and y=7, what the output would the above code produce?

Question 10 if (x >= y) { if (x*10 ");} else{document.write("TWO ");} } else{document.write("THREE ");}

Solution of Q10-A TWO

Question 10 B.Consider the following code segment: What ranges in which temperature and windSpeed are located in order to show a window with message “Good 5!”?

Question 10 if (temperature <= 50){ if (windSpeed < 7) {alert(“Good 1!”);} else{ if (windSpeed >= 15) {alert(“Good 2!”);} else{alert(“Good 3!”);} }} ………. ……… else{ if (windSpeed > 10) {alert(“Good 4!”);} else{ if (windSpeed < 5) {alert(“Good 5!”);} else{alert(“Good 6!”);} }}

Solution of Q10-B Temperature > 50 windSpeed < 5