Illuminating Computer Science CCIT 4-6Sep

Slides:



Advertisements
Similar presentations
College of Information Technology & Design
Advertisements

Searching for Data Relationship between searching and sorting Simple linear searching Linear searching of sorted data Searching for string or numeric data.
MATH 224 – Discrete Mathematics
BITS, BYTES, AND THE BINARY SYSTEM HOW PROGRAMS CREATE IMAGES ON YOUR PC.
1 Chapter 2 The Digital World. 2 Digital Data Representation.
The Efficiency of Algorithms
The Binary Numbering Systems
8 Algorithms Foundations of Computer Science ã Cengage Learning.
CPS120: Introduction to Computer Science Searching and Sorting.
HST 952 Computing for Biomedical Scientists Lecture 9.
Stephen P. Carl - CS 2421 Recursive Sorting Algorithms Reading: Chapter 5.
Sorting Algorithms. Motivation Example: Phone Book Searching Example: Phone Book Searching If the phone book was in random order, we would probably never.
CMPS1371 Introduction to Computing for Engineers SORTING.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (3) Recurrence Relation 11/11 ~ 11/14/2008 Yang Song.
 2003 Prentice Hall, Inc. All rights reserved Sorting Arrays Sorting data –Important computing application –Virtually every organization must sort.
Selection Sort, Insertion Sort, Bubble, & Shellsort
CS 106 Introduction to Computer Science I 10 / 16 / 2006 Instructor: Michael Eckmann.
Sorting and Searching Arrays CSC 1401: Introduction to Programming with Java Week 12 – Lectures 1 & 2 Wanda M. Kunkle.
 2006 Pearson Education, Inc. All rights reserved Searching and Sorting.
Binary Conversion In today’s lesson we will link together the binary and algorithm topics by looking at how to get the computer to: convert binary to decimal.
Binary Numbers.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
CHAPTER 7: SORTING & SEARCHING Introduction to Computer Science Using Ruby (c) Ophir Frieder at al 2012.
Lecture for Week Spring.  Numbers can be represented in many ways. We are familiar with the decimal system since it is most widely used in everyday.
Chapter 3: The Fundamentals: Algorithms, the Integers, and Matrices
Week 11 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
IT253: Computer Organization
(C) 2010 Pearson Education, Inc. All rights reserved. Java How to Program, 8/e.
Chapter 19 Searching, Sorting and Big O
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 19: Searching and Sorting.
 2006 Pearson Education, Inc. All rights reserved Searching and Sorting.
SEARCHING. Vocabulary List A collection of heterogeneous data (values can be different types) Dynamic in size Array A collection of homogenous data (values.
LAB#7. Insertion sort In the outer for loop, out starts at 1 and moves right. It marks the leftmost unsorted data. In the inner while loop, in starts.
CS 361 – Chapters 8-9 Sorting algorithms –Selection, insertion, bubble, “swap” –Merge, quick, stooge –Counting, bucket, radix How to select the n-th largest/smallest.
Chapter Algorithms 3.2 The Growth of Functions 3.3 Complexity of Algorithms 3.4 The Integers and Division 3.5 Primes and Greatest Common Divisors.
Sorting and Searching. Selection Sort  “Search-and-Swap” algorithm 1) Find the smallest element in the array and exchange it with a[0], the first element.
UNIT 5.  The related activities of sorting, searching and merging are central to many computer applications.  Sorting and merging provide us with a.
Sorting and Searching by Dr P.Padmanabham Professor (CSE)&Director
ALGORITHMS.
1 Searching and Sorting Searching algorithms with simple arrays Sorting algorithms with simple arrays –Selection Sort –Insertion Sort –Bubble Sort –Quick.
Chapter 9 Sorting. The efficiency of data handling can often be increased if the data are sorted according to some criteria of order. The first step is.
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
1. Searching The basic characteristics of any searching algorithm is that searching should be efficient, it should have less number of computations involved.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Data Structures Arrays and Lists Part 2 More List Operations.
CPS120: Introduction to Computer Science Sorting.
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
Sorting & Searching Geletaw S (MSC, MCITP). Objectives At the end of this session the students should be able to: – Design and implement the following.
 2006 Pearson Education, Inc. All rights reserved. 1 Searching and Sorting.
Data Structures and Algorithms Instructor: Tesfaye Guta [M.Sc.] Haramaya University.
09/06/ Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types.
Chapter 16: Searching, Sorting, and the vector Type.
Lists and Sorting Algorithms
OCR A Level F453: Data structures and data manipulation Data structures and data manipulation a. explain how static data structures may be.
Component 1.6.
Finite Automata.
Victorian Curriculum Mathematics F - 6 Algorithms unplugged
Tips and tools for creating and presenting wide format slides
IGCSE 6 Cambridge Effectiveness of algorithms Computer Science
Lesson Objectives Aims Understand the following “standard algorithms”:
Quick-Sort 9/12/2018 3:26 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Teach A level Computing: Algorithms and Data Structures
Binary Search Back in the days when phone numbers weren’t stored in cell phones, you might have actually had to look them up in a phonebook. How did you.
CSc 110, Spring 2017 Lecture 39: searching.
8/04/2009 Many thanks to David Sun for some of the included slides!
Sorting "There's nothing in your head the sorting hat can't see. So try me on and I will tell you where you ought to be." -The Sorting Hat, Harry Potter.
William Stallings Computer Organization and Architecture 10th Edition
Quick-Sort 4/25/2019 8:10 AM Quick-Sort     2
Presentation transcript:

Illuminating Computer Science CCIT 4-6Sep

Illuminating Computer Science CCIT 4-6Sep Presented by: Nada Hany Sherief, MSc.

Illuminating Computer Science CCIT 4-6Sep Agenda Data: the raw materials – Representing Information Binary Numbering System Image Representation Putting Computers to Work – Algorithms Searching Algorithms Sorting Algorithms Telling Computers What to do Finite State Automata Programming Languages 3

Illuminating Computer Science CCIT 4-6Sep

Illuminating Computer Science CCIT 4-6Sep Binary Numbering System (1/3) The word computer comes from the Latin computare, which means to calculate or add together Computers today are more than just giant calculators. They can be a library, help us to write, find information for us, play music and even show movies. So how do they store all this information? Believe it or not, the computer uses only two things: zero and one! 5

Illuminating Computer Science CCIT 4-6Sep Binary Numbering System (2/3) Decimal Numbering System Weights (units, tens, hundreds, thousands,…) Why Base 10 (there are only 10 digits 0-9 ) Binary Numbering System Weights (1, 2, 4, 8, 16,…) Why Base 2 (there are only 2 digits 0,1) 6

Illuminating Computer Science CCIT 4-6Sep Binary Numbering System (3/3) Binary to Decimal Conversion Add the weights Example: 1001, Can you work out what is? Decimal to Binary Conversion Repeated Division by 2 method Read the numbers upside down 7

Illuminating Computer Science CCIT 4-6Sep Image Representation (1/4) Computer screens are divided up into a grid of small dots called pixels (picture elements). In a black and white picture, each pixel is either black or white. The letter “a” has been magnified above to show the pixels. When a computer stores apicture, all that it needs to store is which dots are black and which are white. 8

Illuminating Computer Science CCIT 4-6Sep Image Representation (2/4) The picture below shows us how a picture can be represented by numbers. The first line consists of one white pixel, then three black, then one white. The first number always relates to the number of white pixels. If the first pixel is black the line will begin with a zero. 9

Illuminating Computer Science CCIT 4-6Sep Image Representation (3/4) 10

Illuminating Computer Science CCIT 4-6Sep Image Representation (4/4) 11

Illuminating Computer Science CCIT 4-6Sep

Illuminating Computer Science CCIT 4-6Sep Searching Algorithms (1/6) Computers operate by following a list of instructions set for them. These instructions enable them to sort, find and send information. To do these things as quickly as possible, you need good methods for finding things in large collections of data, and for sending information through networks. An algorithm is a set of instructions for completing a task. 13

Illuminating Computer Science CCIT 4-6Sep Linear Search Algorithm (2/6) Linear search is a method for finding a particular value in a list, that consists of checking every one of its elements until the desired one is found. Linear search can be described as a recursive algorithm: 14

Illuminating Computer Science CCIT 4-6Sep Linear Search Algorithm (3/6) Example Using the algorithm below, find 6 within the following list: 15

Illuminating Computer Science CCIT 4-6Sep Binary Search Algorithm (4/6) Binary search algorithm, finds the position of a specified value within a sorted array. In each step, the algorithm compares the input key value with the key value of the middle element of the array. If the keys match, then a matching element has been found so its index, or position, is returned. Else if the sought key is less than the middle element's key, then the algorithm repeats its action on the sub-array to the left of the middle element or, if the input key is greater, on the sub-array to the right. If the remaining array to be searched is reduced to zero, then the key cannot be found in the array and a special "Not found" indication is returned. 16

Illuminating Computer Science CCIT 4-6Sep Binary Search Algorithm (5/6) Example 1: 17

Illuminating Computer Science CCIT 4-6Sep Binary Search Algorithm (6/6) Example 2: 18

Illuminating Computer Science CCIT 4-6Sep Sorting Algorithms (1/9) Computers are often used to put lists into some sort of order, for example names into alphabetical order, appointments or by date, or items in numerical order. Sorting lists helps us find things quickly, and also makes extreme values easy to see. If you sort the marks for a class test into numeric order, the lowest and highest marks become obvious. If you use the wrong method, it can take a long time to sort a large list into order, even on a fast computer. 19

Illuminating Computer Science CCIT 4-6Sep Selection Sort (2/9) One method a computer might use is called selection sort. This is how selection sort works: First find the lightest weight in the set and put it to one side. Next, find the lightest of the weights that are left, and remove it. Repeat this until all the weights have been removed. 20

Illuminating Computer Science CCIT 4-6Sep Selection Sort (3/9) 21

Illuminating Computer Science CCIT 4-6Sep Quick Sort (4/9) Quick sort is a lot faster than selection sort, particularly for larger lists. In fact, it is one of the best methods known. This is how quick sort works: Choose one of the objects at random, and place it on one side of the balance Scales. Now compare each of the remaining objects with it. Put those that are lighter on the left, the chosen object in the middle, and the heavier ones on the right. Choose one of the groups and repeat this procedure. Do the same for the other group. Remember to keep the one you know in the centre. Keep repeating this procedure on the remaining groups until no group has more than one object in it. 22

Illuminating Computer Science CCIT 4-6Sep Quick Sort (5/9) 23

Illuminating Computer Science CCIT 4-6Sep Insertion Sort (6/9) Insertion sort works by removing each object from an unsorted group and inserting it into its correct position in a growing list. With each insertion the group of unsorted objects shrinks and the sorted list grows, until eventually the whole list is sorted. 24

Illuminating Computer Science CCIT 4-6Sep Bubble Sort (7/9) Bubble sort involves going through the list again and again, swapping any objects side by- side that are in the wrong order. The list is sorted when no swaps occur during a pass through the list. 25

Illuminating Computer Science CCIT 4-6Sep Merge Sort (8/9) First, the list is divided at random into two lists of equal size (or nearly equal if there are an odd number of items). Each of the two half-size lists is sorted, and the two lists are merged together. Merging two sorted lists is easy—you repeatedly remove the smaller of the two items at the front of the two lists. 26

Illuminating Computer Science CCIT 4-6Sep Merge Sort (9/9) 27

Illuminating Computer Science CCIT 4-6Sep

Illuminating Computer Science CCIT 4-6Sep Finite State Automata (1/4) Computer programs often need to process a sequence of symbols such as letters or words in a document, or even the text of another computer program. Computer scientists often use a finite-state automaton to do this. A finite-state automaton (FSA) follows a set of instructions to see if the computer will recognize the word or string of symbols. 29

Illuminating Computer Science CCIT 4-6Sep Finite State Automata (2/4) The Mysterious Coin Game Some friends downloaded a game from the Internet in which a robot flipped a coin and they had to guess whether it would turn up heads or tails. At first the game looked very easy. At least they would have a 50/50 chance of winning—or so they thought! After a while though they started to get suspicious. There seemed to be a pattern in the coin tosses. They decided to investigate. Joe wrote down the results of their next attempts at the game and this is what they found: (h = heads, t = tails) 30

Illuminating Computer Science CCIT 4-6Sep Finite State Automata (3/4) Can you find a predictable pattern? There is a very simple ‘map’ that will describe the sequence of coin tosses. See if you can figure it out. (Hint: it has just 4 ‘islands’) 31

Illuminating Computer Science CCIT 4-6Sep Finite State Automata (4/4) Pattern: If you follow it, you will see that the first two coin tosses of each three have the same outcome. 32

Illuminating Computer Science CCIT 4-6Sep Programming Languages Computers operate by following a list of instructions, called a program, that has been written to carry out a particular task. Programs are written in languages that have been specially designed, with a limited set of instructions, to tell computers what to do. Some languages are more suitable for some purposes than others. Regardless of what language they use, programmers must become adept at specifying exactly what they want the computer to do. 33

Illuminating Computer Science CCIT 4-6Sep Programming Languages It is important that programs are well written. A small error can cause a lot of problems. Imagine the consequences of an error in the program of a computer in a space shuttle launch, a nuclear power plant, or the signals on a train track! 34

Illuminating Computer Science CCIT 4-6Sep Programming Languages C hello world example C program to add two numbers 35

Illuminating Computer Science CCIT 4-6Sep 36