Algorithms Today we will look at: what we mean by efficiency in programs why efficiency matters what causes programs to be inefficient? will one algorithm.

Slides:



Advertisements
Similar presentations
Growth-rate Functions
Advertisements

Analysis of Algorithms: time & space Dr. Jeyakesavan Veerasamy The University of Texas at Dallas, USA.
Announcements You survived midterm 2! No Class / No Office hours Friday.
Higher Computing: Unit 1: Topic 3 – Computer Performance St Andrew’s High School, Computing Department Higher Computing Topic 3 Computer Performance.
Complexity Theory  Complexity theory is a problem can be solved? Given: ◦ Limited resources: processor time and memory space.
CMPT 225 Sorting Algorithms Algorithm Analysis: Big O Notation.
Data Structures Data Structures Topic #13. Today’s Agenda Sorting Algorithms: Recursive –mergesort –quicksort As we learn about each sorting algorithm,
the fourth iteration of this loop is shown here
What is an Algorithm? (And how do we analyze one?)
Algorithmic Complexity Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
CS 206 Introduction to Computer Science II 09 / 10 / 2008 Instructor: Michael Eckmann.
Chapter XI Reduced Instruction Set Computing (RISC) CS 147 Li-Chuan Fang.
Hardware Basics: Inside the Box 2  2001 Prentice Hall2.2 Chapter Outline “There is no invention – only discovery.” Thomas J. Watson, Sr. What Computers.
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
State Machines Timing Computer Bus Computer Performance Instruction Set Architectures RISC / CISC Machines.
Cmpt-225 Simulation. Application: Simulation Simulation  A technique for modeling the behavior of both natural and human-made systems  Goal Generate.
By D.Kumaragurubaran Adishesh Pant
Instructions Slides 3,4,5 are general questions that you should be able to answer. Use slides 6-27 to answer the questions. Write your answers in a separate.
External Sorting Chapter 13.. Why Sort? A classic problem in computer science! Data requested in sorted order  e.g., find students in increasing gpa.
The Computer Systems By : Prabir Nandi Computer Instructor KV Lumding.
Computing hardware CPU.
1 Growth of Functions CS 202 Epp, section ??? Aaron Bloomfield.
1 Chapter 24 Developing Efficient Algorithms. 2 Executing Time Suppose two algorithms perform the same task such as search (linear search vs. binary search)
What have mr aldred’s dirty clothes got to do with the cpu
IT253: Computer Organization
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
What is cache memory?. Cache Cache is faster type of memory than is found in main memory. In other words, it takes less time to access something in cache.
Simple Iterative Sorting Sorting as a means to study data structures and algorithms Historical notes Swapping records Swapping pointers to records Description,
Introduction to Computer Architecture. What is binary? We use the decimal (base 10) number system Binary is the base 2 number system Ten different numbers.
Sorting – Insertion and Selection. Sorting Arranging data into ascending or descending order Influences the speed and complexity of algorithms that use.
Stored Programs In today’s lesson, we will look at: what we mean by a stored program computer how computers store and run programs what we mean by the.
Motivation: Sorting is among the fundamental problems of computer science. Sorting of different datasets is present in most applications, ranging from.
© GCSE Computing Computing Hardware Starter. Creating a spreadsheet to demonstrate the size of memory. 1 byte = 1 character or about 1 pixel of information.
1 5. Abstract Data Structures & Algorithms 5.6 Algorithm Evaluation.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
COMPUTER ORGANIZATIONS CSNB123 NSMS2013 Ver.1Systems and Networking1.
Complexity Analysis. 2 Complexity The complexity of an algorithm quantifies the resources needed as a function of the amount of input data size. The resource.
Memory Management OS Fazal Rehman Shamil. swapping Swapping concept comes in terms of process scheduling. Swapping is basically implemented by Medium.
Activity 1 Review the work from last lesson so that you can explain the following: -What is the purpose of a CPU. -What steps does the CPU take to process.
Chapter 9: Sorting1 Sorting & Searching Ch. # 9. Chapter 9: Sorting2 Chapter Outline  What is sorting and complexity of sorting  Different types of.
RISC / CISC Architecture by Derek Ng. Overview CISC Architecture RISC Architecture  Pipelining RISC vs CISC.
The Processor & its components. The CPU The brain. Performs all major calculations. Controls and manages the operations of other components of the computer.
Quicksort This is probably the most popular sorting algorithm. It was invented by the English Scientist C.A.R. Hoare It is popular because it works well.
 A computer is an electronic device that receives data (input), processes data, stores data, and produces a result (output).  It performs only three.
Data Structures and Algorithms Instructor: Tesfaye Guta [M.Sc.] Haramaya University.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Complexity of Algorithms Fundamental Data Structures and Algorithms Ananda Guna January 13, 2005.
CPIT Program Execution. Today, general-purpose computers use a set of instructions called a program to process data. A computer executes the.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Assignment 5 is posted. Exercise 8 is very similar to what you will be doing with assignment 5. Exam.
1 5. Abstract Data Structures & Algorithms 5.6 Algorithm Evaluation.
Algorithm Complexity is concerned about how fast or slow particular algorithm performs.
GCSE OCR Computing A451 The CPU Computing hardware 1.
Design and Analysis of Algorithms
Chapter 2.1 CPU.
Chapter 2 Memory and process management
Algorithmic complexity: Speed of algorithms
Computer Science Higher
F453 Computing Questions and Answers
1. Systems and Software Development
Advanced QlikView Performance Tuning Techniques
3.3.3 Computer architectures
Database Management Systems (CS 564)
Objective of This Course
Lesson 15: Processing Arrays
Big O Notation.
Algorithmic complexity: Speed of algorithms
Algorithmic complexity: Speed of algorithms
Year 10 Computer Science Hardware - CPU and RAM.
Database Systems (資料庫系統)
WJEC GCSE Computer Science
Presentation transcript:

Algorithms Today we will look at: what we mean by efficiency in programs why efficiency matters what causes programs to be inefficient? will one algorithm always be the most efficient way of doing something? can efficiency be measured?

What is Efficiency? Efficiency is about making the best use of available resources... –a fuel-efficient car will travel further on a litre of fuel –an energy-efficient light-bulb will produce more light from the same amount of electricity In programming, efficiency is a similar idea – but what are the resources? –memory (RAM) –secondary storage (e.g. disc space) –processor time (which, in most cases, equates to the actual amount of time taken to do a task)

Why Does It Matter? As computers get faster and have more memory and storage space, efficiency is becoming less of an issue, but: users find it stressful to wait for computers to complete tasks, and employers have a duty to look after their employees’ health sometimes speed of reaction is important – e.g. with real-time control systems, or with things like simulators and games to ensure a realistic experience. some computers – e.g. web-servers – run more than one program concurrently; if your web-site is inefficient, it could have an impact on the others running on the same server.

What Affects Efficiency? Efficient database design, re-use of variables, the use of binary flags to combine multiple values in a single byte can all of used to reduce memory usage. Efficient file formats and compression techniques can be used to minimise the amount of storage space required (although compression does take time to do!). Hardware is getting cheaper and better, though, so you’re most likely to want to save time through efficient algorithm design.

What Makes Program Slower? Processors perform instructions in cycles, and not all steps in your program will require a single cycle (it depends on the architecture, e.g. RISC v. CISC). Two big factors affecting performance are: –unnecessary repetition: the more times you repeat, e.g. comparisons when sorting – the longer the program will take to run. Try to use as few steps as possible. –complex calculations: some types of calculations (e.g. sines, cosines or square roots) take longer than simple arithmetic. For this reason, if you use a complex calculation more than once in your program, do it once and assign the value to a variable. NB. This will all change when quantum computers appear!

Does the Efficiency of a Program Change? You have probably already noticed that the amount of data affects how long it takes for a program to run – e.g. longer CDs take longer to rip, and larger files take longer to load, etc. – even though the program is doing the same thing. Sometimes the type or properties of the data might have an effect on the efficiency of an program – e.g. compare sorting algorithms for: –values that are nearly ordered already –random values –values in reverse order

Can Efficiency Be Measured? Computer Scientists use a measure called big O to describe how long a program takes to run (or, more strictly-speaking, the time-complexity of the algorithm!) The letter n is used to describe the number of inputs to a program – e.g. if you’re sorting ten numbers then n = 10. The average “complexities” of common sorts are: –Bubble sort: O(n 2 ) –Selection sort: O(n 2 ) –Insertion sort: O(n 2 ) –Quicksort: O(n log n) This also indicates how the time increase with the amount of data – e.g. if you sort twenty numbers instead, a bubble sort will take 4x longer, but a quicksort only 2.6x longer.