National Central University, Taiwan

Slides:



Advertisements
Similar presentations
Solve problems with Java code Algorithms with Java.
Advertisements

HaploReg, RegulomeDB and more on Python programming
Exercise (1).
Order of operators: x ** y x * y, x / y, x // y, x % y x + y, x - y
Def f(n): if (n == 0): return else: print(“*”) return f(n-1) f(3)
Strings Testing for equality with strings.
Lab 8 User Defined Function.
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
WS Algorithmentheorie 03 – Randomized Algorithms (Primality Testing) Prof. Dr. Th. Ottmann.
Designing Algorithms Csci 107 Lecture 3. Designing algorithms Last time –Pseudocode –Algorithm: computing the sum 1+2+…+n –Gauss formula for 1+2+…+n Today.
Recursion. Sum a list of numbers Iterative def sum(L): total = 0 for i in L: total += i return total Recursive def sum(L): if len(L) == 0: return 0 else:
Genome Sciences 373 Genome Informatics Quiz Section 5 April 28, 2015.
Adapted from slides by Marie desJardins
 Experiment 07 Function Dr. rer.nat. Jing LU
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
Python: Modularisation Damian Gordon. Modularisation Remember the prime checker program:
First Program  Open a file  In Shell  Type into the file: 3  You did it!!! You wrote your first instruction, or code, in python!
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 6 Value-Returning.
60 Questions (review for final exam) CSC 161: The Art of Programming Prof. Henry Kautz 12/7/
How to start Visual Studio 2008 or 2010 (command-line program)
Python The tutorial
Functions. Built-in functions You’ve used several functions already >>> len("ATGGTCA")‏ 7 >>> abs(-6)‏ 6 >>> float("3.1415")‏ >>>
Xin Liu Feb 4, * Use midterm questions for previous 231/217 midterms for practices * ams
Data Collections: Lists CSC 161: The Art of Programming Prof. Henry Kautz 11/2/2009.
Modularisation Damian Gordon. Modularisation Let’s imagine we had code as follows:
My Python Programmes NAME:.
Lecture 15 – more on lists and for…in loops, the split() function COMPSCI 1 1 Principles of Programming.
5 While-Statements © 2010 David A Watt, University of Glasgow Accelerated Programming 2 Part I: Python Programming.
1 CS 177 Week 6 Recitation Slides Review for Midterm Exam.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
Prime Numbers Damian Gordon. Prime Numbers So let’s say we want to express the following algorithm: – Read in a number and check if it’s a prime number.
8. DECISION STRUCTURES Rocky K. C. Chang October 18, 2015 (Adapted from John Zelle’s slides)
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
If statement.  It is made up of three main components:  The keyword itself,  an expression that is tested for its truth value,  and a code suite to.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 4: Control Structures (Part 2) Xiang Lian The University of Texas – Pan American Edinburg, TX
PYTHON FUNCTIONS. What you should already know Example: f(x) = 2 * x f(3) = 6 f(3)  using f() 3 is the x input parameter 6 is the output of f(3)
First Program  Open a file  In Shell  Type into the file: 3  You did it!!! You wrote your first instruction, or code, in python!
Python – Part 4 Conditionals and Recursion. Conditional execution If statement if x>0:# CONDITION print (‘x is positive’) Same structure as function definition.
Machine Language Computer languages cannot be directly interpreted by the computer – they are not in binary. All commands need to be translated into binary.
More on conditional statements. Conditionals In some situations the typical if-else statements may become cumbersome Depending on the situation, there.
Exercise 2 : Using for loop Repetition (loop) (1)control variable initialization (2)Test Conditon (3)Modification of control variable value order : (1)
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
Pseudo-code 1 Running time of algorithm is O(n)
Recall: d is a divisor of n  n % d == 0
while Repetition Structure
Python: Logic Gates Damian Gordon.
Coding Concepts (Sub- Programs)
The University of Texas – Pan American
Practice with loops! What is the output of each function below?
2-1 Inductive Reasoning.
What does this do? def revList(L): if len(L) < = 1: return L x = L[0] LR = revList(L[1:]) return LR + x.
Linear Search Binary Search Tree
Conditionals.
If Statements.
Suppose I want to add all the even integers from 1 to 100 (inclusive)
Intro to Programming & Algorithm Design
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
PYTHON: BUILDING BLOCKS Sequencing & Selection
Programming Concepts and Database
Understand the interaction between computer hardware and software
Python Basics with Jupyter Notebook
4-9问题的形式化描述.
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
List Comprehensions Problem: given a list of prices, generate a new list that has a 20% discount to each. Formally: input: list of old prices; output:
Calculate 81 ÷ 3 = 27 3 x 3 x 3 3 x 3 x 3 x 3 ÷ 3 = This could be written as
CSCE 206 Lab Structured Programming in C
Lecture 23 – Practice Exercises 5
Lecture 23 – Practice Exercises 5
COMPUTING.
Lecture 6 - Recursion.
Presentation transcript:

National Central University, Taiwan Algorithm Small Talk Prof. Jehn-Ruey Jiang National Central University, Taiwan

Algorithm is IPO Traditional Algorithm Process Input Output E.G.: An Integer n, n>0 true or false: n is odd (true) or even (false)

Algorithm Example 1 Algorithm OddNumberTest Input: n, nZ+ Output: true (n is odd) or false (n is even) 1: r  n % 2 2: if r0 3: return true 4: else 5: return false

Algorithm Implementation 1 def OddNumberTest(n): r=n%2 if r!=0: return True else: return False print OddNumberTest(3) Result: True

Algorithm is IPO Machine Learning Algorithm Process Input Output E.G.: A 64 x 64 x 256 Image M Process true or false: M is a cat (true) or not (false)

Algorithm Example 2 A 64 x 64 x 256 Image M Process true or false: M is a cat (true) or not (false)

Algorithm Example 2 (Cont’d) A 64 x 64 x 256 Image M Process true or false: M is a cat (true) or not (false)

Algorithm Example 2 (Cont’d) A 64 x 64 x 256 Image M Process (DNN) true or false: M is a cat (true) or not (false)

Python Programming To calculate: By python codes import numpy as np a=np.array([[1,3,5,7], [2,4,6,8]]) b=np.array([[1,8,9], [2,7,10], [3,6,11], [4,5,12]]) print np.matmul(a,b) Result: [[ 50 94 178] [ 60 120 220]]

To be Continued