0% found this document useful (0 votes)
63 views

CSC 170 Computing: Science and Creativity: Big Idea: Algorithms Thinking of Solutions in Many Ways

Here is an algorithm in English to convert a binary number to its decimal equivalent: 1. Start with the binary number 1010101010. 2. Working from right to left, multiply each digit by its place value. The rightmost digit is the 1s place, next is the 2s place, then the 4s place, and so on, doubling each time. 3. Add up the results of the multiplications. This will be the decimal equivalent of the original binary number. 4. The decimal equivalent of 1010101010 is 1*512 + 0*256 + 1*128 + 0*64 + 1*32 + 0*16 + 1*8 + 0*4 + 1*2 + 0

Uploaded by

Miftahur Rohman
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

CSC 170 Computing: Science and Creativity: Big Idea: Algorithms Thinking of Solutions in Many Ways

Here is an algorithm in English to convert a binary number to its decimal equivalent: 1. Start with the binary number 1010101010. 2. Working from right to left, multiply each digit by its place value. The rightmost digit is the 1s place, next is the 2s place, then the 4s place, and so on, doubling each time. 3. Add up the results of the multiplications. This will be the decimal equivalent of the original binary number. 4. The decimal equivalent of 1010101010 is 1*512 + 0*256 + 1*128 + 0*64 + 1*32 + 0*16 + 1*8 + 0*4 + 1*2 + 0

Uploaded by

Miftahur Rohman
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 14

CSC 170

Computing: Science and Creativity

BIG IDEA: ALGORITHMS


THINKING OF SOLUTIONS IN MANY WAYS

Institute for Personal Robots in Education


(IPRE)
EARLY ALGORITHMS
● Alan Winfield of Bristol Robotics Laboratory
● A Robot tries to save one and then two robots
from falling int a hole |_
WHAT IS AN ALGORITHM?

● An algorithm is any well-defined


computational procedure that takes some
value or set of values as input and produces
some value or set of values as output
● The decimal equivalent of a binary number
● Algorithms can be non computer based
● Cake recipe, instructions to get to from here to
there, find a number in a phonebook
– Or how back up your contact list on a cell phone
● Algorithms are much older than computers
ALGORITHMS
● Dances, ceremonies,
recipes, and building
instructions are all
conceptually similar to
algorithms
● Babylonians defined some
fundamental mathematical
procedures ~3,600 years
ago
● Genes contain algorithms!
Photo credit: Daniel Niles
● step-by-step processes to
transcribe genes and produce
proteins
ALGORITHMS YOU MIGHT HAVE USED THIS WEEK

Tie your shoe laces Log in to D2L


Wasn’t easy, was it? Enter UA Net ID and
password, press
something

Attended CSc 170 Study for a test


Wake up, do your Is there really any easy
routine, drove, walked or way?
biked nearby …..
ALGORITHMS YOU'VE SEEN IN CSC 170

● Determine a letter grade if..else


● Interact with the user ask
● Help a player guess a word in fewer tries
repeat until loop
● Find if a digit is in a number for loop
● Create a 5 digit number? secretNumber
ALGORITHMS YOU MIGHT HAVE USED THIS WEEK

Luhn algorithm Recommenders


Credit card number You might also be
validation interested in …

PageRank EdgeRank
Google’s way of measuring Facebook’s method for
“reputation” of web pages determining what is highest
up on your news feed
FORMS OF CONTROL IN ALGORITHMS

Sequencing Selection
Application of each step of Use of Boolean condition to
an algorithm in order select execution parts
(sometimes: find order)

Iteration Recursion
Repetition of part of an Repeated application of the
algorithm until a condition is same part of algorithm on
met smaller problems
PROPERTIES OF ALGORITHMS
● Algorithm + Algorithm = Algorithm
● Part of Algorithm = Algorithm
● Several algorithms may solve the same problem,
but in differrent time
● Much of Computer Science research involves
development of algorithms that solve difficult problems
● And then implementing them in a programming language
to do it as quickly as possible
● Believe it or not, it can take seconds or decades
PROVING QUARKS EXIST
● Kenneth G. Wilson, winner of the
1982 Nobel Prize in physics, found he
didn’t have adequate computing
power to solve his theory numerically,
so he wanted easy ways to use large
numbers of parallel processors.”
● “He was decades ahead of his time with
respect to computing and networks..”
● So Wilson became a pioneer in the
field of supercomputing (Cornell)
● UofA CS and BIOr now looking
forpatterns in terabytes, or trillions
(1,000,000,000,000) of genomic data
ALGORITHM CORRECTNESS

● We don't only want algorithms to be fast and


efficient; we also want them to be correct!
● We also have probabalistic and stochastic
algorithms that have a randomness or probability
to report an answer
● File download time
● Weather predictions
● Potential Friends on Facebook
● Translating text using probabilistic text generation
● Predicting forest fire danger
● Discovering terroristic activities
● Ask the Magic eight ball https://eightball.tridelphia.net/
How to Express Algorithms…

● A programmer’s spouse tells him: “Run to the store


and pick up a loaf of bread. If they have eggs, get
a dozen.”
● The programmer comes home with 12 loaves of bread
● Algorithms need to be expressed in a context-free,
unambiguous way for all participants
WAYS TO EXPRESS ALGORITHMS
● Natural Language
● Pseudo Code
● Programming
Language
● Snap! Blocks
Let’s write an algorithm in a natural language

● Write an algorithm in English that takes a binary


number such as 1010101010 and reports the
decimal equivalent
11012 = 1x23 + 1x22 + 0x21 + 1x20
= 8 + 4 + 0 + 1 = 13 10

You might also like