How our brains work And how it ties in to programming and arrays Storage Sorting Algorithms Etc…

Slides:



Advertisements
Similar presentations
Introduction to Recursion and Recursive Algorithms
Advertisements

CS0004: Introduction to Programming Repetition – Do Loops.
Sorting CMSC 201. Sorting In computer science, there is often more than one way to do something. Sorting is a good example of this!
Recursion. Recursion is a powerful technique for thinking about a process It can be used to simulate a loop, or for many other kinds of applications In.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Fundamentals of Computer Science Lecture 14: Recursion Instructor: Evan Korth New York University.
1 CSE1301 Computer Programming: Lecture 28 List Sorting.
Fundamentals of Computer Science Lecture 14: Recursion Instructor: Evan Korth New York University.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
28-Jun-15 Recursion. 2 Definitions I A recursive definition is a definition in which the thing being defined occurs as part of its own definition Example:
Visual Basic: An Object Oriented Approach 3 – Making Objects Work.
Arrays Data Structures - structured data are data organized to show the relationship among the individual elements. It usually requires a collecting mechanism.
CS 106 Introduction to Computer Science I 10 / 16 / 2006 Instructor: Michael Eckmann.
Lesson 3 Variables – How our Brains Work - Variables in Python.
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
CATCH SCRATCH! Programming from Scratch. Remember Scratch?
Mr C Johnston ICT Teacher BTEC IT Unit 06 - Lesson 05 Learning To Program.
Department of Computer Science and Engineering, HKUST 1 HKUST Summer Programming Course 2008 Recursion.
Lists in Python.
Invitation to Computer Science, Java Version, Second Edition.
CS0004: Introduction to Programming Subprocedures and Modular Design.
Week 5 - Monday.  What did we talk about last time?  Linked list implementations  Stacks  Queues.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Chapter 15: Advanced Topics: Introducing Data Structures and Recursion Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 11Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 11 l Basics of Recursion l Programming with Recursion Recursion.
224 3/30/98 CSE 143 Recursion [Sections 6.1, ]
February 4, 2005 Searching and Sorting Arrays. Searching.
COMP Recursion, Searching, and Selection Yi Hong June 12, 2015.
By the end of this session you should be able to...
Simple Iterative Sorting Sorting as a means to study data structures and algorithms Historical notes Swapping records Swapping pointers to records Description,
Visual Basic.net Loops. Used to do multiple executions of the same block of code Do while loops Do until loops For next loops.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Java Programming: Guided Learning with Early Objects Chapter 11 Recursion.
read and learn from example loop programs develop modular program
Research Topics in Computational Science. Agenda Survey Overview.
Introduction to Loops For Loops. Motivation for Using Loops So far, everything we’ve done in MATLAB, you could probably do by hand: Mathematical operations.
Chapter 11Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 11 l Basics of Recursion l Programming with Recursion Recursion.
Identify if numbers are prime or composite. Sort whole numbers (through 50) into sets containing only prime or only composite numbers.
Conditionals Opening Discussion zWhat did we talk about last class? zDo you have any questions about the assignment? zPass by value limitations.
Searching and Sorting Searching: Sequential, Binary Sorting: Selection, Insertion, Shell.
Written by: Dr. JJ Shepherd
Computer Science 1620 Sorting. cases exist where we would like our data to be in ascending (descending order) binary searching printing purposes selection.
BO65: PROGRAMMING ITERATION 1. Starter  Write down what you think the code below outputs on screen: Dim intCounter as integer intCounter = 0 Do while.
National Diploma Unit 4 Introduction to Software Development Data Structures – Loops and selection.
Chapter 15: Recursion. Recursive Definitions Recursion: solving a problem by reducing it to smaller versions of itself – Provides a powerful way to solve.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Bubble sort. Quite slow, but simple Principles: Compare 2 numbers next to each other (lets call it current and the one next to it) If the current number.
Coding – Week 2 Functions, Arrays, and Objects. Functions  Functions are not a new concept – you’ve been using them already.  void setup() {} and void.
CSC 143 P 1 CSC 143 Recursion [Chapter 5]. CSC 143 P 2 Recursion  A recursive definition is one which is defined in terms of itself  Example:  Compound.
Lesson Objectives Aims Key Words
Introduction to Recursion
Introducing Instructions
Lesson 1 Introduction – Computing - Binary – Programming Basics.
Lesson 1 Introduction – Computing - Binary – Programming Basics.
Algorithm design and Analysis
Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro.
Recursion Chapter 11.
Introduction to pseudocode
Coding Concepts (Basics)
Do … Loop Until (condition is true)
For Loops (Iteration 1) Programming Guides.
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
The structure of programming
The structure of programming
Thinking procedurally
Remember Procedures A set of instructions grouped together to carry out a task. Run a procedure by using its name. Procedures can be run/used lots of.
How to allow the program to know when to stop a loop.
Basic Procedures By Phil Bagge HIAS Computing Inspector / Advisor
Adaptable Procedures By Phil Bagge HIAS Computing Inspector / Advisor
Presentation transcript:

How our brains work And how it ties in to programming and arrays Storage Sorting Algorithms Etc…

What is computing? Computing is about computers just as much as astronomy is about telescopes Computing is not just hardware etc.. It’s a science…

Why is it called computer science? Just because our brains do it automatically –doesn’t mean everything else will We study how our brains do things…and try and replicate that in an in-animate system.

Numbers on a visual screen presented to your brain Your brain contains the information (the Algorithim, if you like) To do stuff with these numbers. You could add the numbers Sort the numbers from smallest to largest.

How do we make a computer sort numbers? SORT 32……53…….81 Programming code Put behind this to sort! For instance. Declare variables 1 2 and 3 For i is 1 to 3 If 1 > 2 then move 1 to Right. Next i

Our brains do this automatically Much of computer science Is –copying the way the brain works Making a system –a computer –that can do what our brains do!

Algorithms in our brain (that resemble a sort program) At any given time, you can do a million different things, You could SIT STILL WALK RUN SWALLOW SING TALK THINK ABOUT YOUR EX BOYFRIEND THINK OF A PLAN TO KILL Person X EAT SOMETHING that is in your pocket CLIMB A TREE

SIT STILL WALK RUN SWALLOW SING TALK THINK ABOUT YOUR EX BOYFRIEND THINK OF A PLAN TO KILL Person X EAT SOMETHING that is in your pocket CLIMB A TREE

Take the simplest of processes like EATING

Eating Swallow Taste Chew Spit Chew Again Bite Transfer to Molars Swallow again Open Mouth Close Mouth Lift Spoon

Eating Swallow Taste Chew Spit Chew Again Bite Transfer to Molars Swallow again Open Mouth Close Mouth Lift Spoon If food looks edible Else If Food tastes nice Else Lift Spoon Put spoon down Bite Taste Swallow Spit

Eating If food looks edible Else If Food tastes nice Else Lift Spoon Put spoon down Bite Taste Swallow Spit

Use of Loops? Child genius –could recite timestables (up to 20) at age 4

Reciting timestables 2 times 1 is 2 2 times 2 is 4 And so on HOW DOES YOUR BRAIN DO THIS? Task: Recite your two timestable –starting at 1 and stop at 10.

Immediately The brain sets a START AND STOP i.e starts at 1 Stops at 10 This is a loop!

Three types of loops WHILE LOOPS REPEAT UNTIL LOOPS FOR LOOPS Declare i as integer i=1 While I <10 then i*2= answer Declare i as integer i=1 Repeat i * 2 = answer Until i=10 Dim i as integer For i = 1 to 10 i= i*2 Next i

Computers (in order to even remotely resemble our brains) need to be programmed. Algorithms are developed to do what we imagine is something very very simple

Algorithims will typically involve One or more of The FOUR MAIN programming constructs

What are the main programming constructs? SequenceSequence (sequential programming) just a whole load of STATEMENTS Iteration (loops –While, Repeat, For) Selection (if statements, case statements) Recursion –a very complex type of function That calls itself

What are loops –how do they work All loops have a start stop i.e they all have a STOPPING CONDITION.. Otherwise they would go on forever!

How many loops do you see here?

Have I correctly identified the start and stop of each loop?

Recursion Module Module1 Dim a As Integer = 3 Dim b As Integer = 3 Sub Main() add(a, b) Console.ReadLine() End Sub Function add(ByVal a, ByVal b) If a = 0 Then Return b Else add = (a - 1) + (b + 1) Console.WriteLine(add) End If End Function End Module

Recursion Function (x) If x = 1 Return 1 else Function = x - Function (x-1) x=3 What is the value returned by Function?

And what’s an Array? What is a variable? A variable is like a like a space you need to declare –so that the computer knows to set aside a block of space to store something that it may need to compute

If you are given two numbers 6040

Add those two numbers up now Number 1 Number 2 = Number 3

What is the capital of egypt?

What is the answer of the addition of those two numbers? = Number Your brain stored the number 100 somewhere! In a computer we call this storage the use of a VARIABLE

Say you had a whole load of numbers Instead of setting aside 9 blocks of space in Your head for these numbers you might set aside 1 BLOCK OF SPACE and call it “counting up” That way…whenever anyone said COUNTING UP You’d remember to count up from 1 to 9…and you#d Remember the 9 numbers THIS IS CALLED AN ARRAY (lots of variables)

Array counting up Index number