WJEC GCSE Computer Science

Slides:



Advertisements
Similar presentations
College of Information Technology & Design
Advertisements

Chapter 3 Brute Force Brute force is a straightforward approach to solving a problem, usually directly based on the problem’s statement and definitions.
Search and Recursion CS221 – 2/23/09. List Search Algorithms Linear Search: Simple search through unsorted data. Time complexity = O(n) Binary Search:
Sorting and Searching. Searching List of numbers (5, 9, 2, 6, 3, 4, 8) Find 3 and tell me where it was.
Recursion. Idea: Some problems can be broken down into smaller versions of the same problem Example: n! 1*2*3*…*(n-1)*n n*factorial of (n-1)
Searching and Sorting Copyright Prentice Hall (with modifications by Evan Korth)
Objectives Learn how to implement the sequential search algorithm Explore how to sort an array using the selection sort algorithm Learn how to implement.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (3) Recurrence Relation 11/11 ~ 11/14/2008 Yang Song.
Searching Arrays Linear search Binary search small arrays
Searching and Sorting Arrays
Sorting and Searching Arrays CSC 1401: Introduction to Programming with Java Week 12 – Lectures 1 & 2 Wanda M. Kunkle.
CHAPTER 7: SORTING & SEARCHING Introduction to Computer Science Using Ruby (c) Ophir Frieder at al 2012.
Fall 2013 Instructor: Reza Entezari-Maleki Sharif University of Technology 1 Fundamentals of Programming Session 17 These.
Chapter Complexity of Algorithms –Time Complexity –Understanding the complexity of Algorithms 1.
Sorting Algorithms. Sorting Sorting is a process that organizes a collection of data into either ascending or descending order. public interface ISort.
SEARCHING. Vocabulary List A collection of heterogeneous data (values can be different types) Dynamic in size Array A collection of homogenous data (values.
1 Sorting (Bubble Sort, Insertion Sort, Selection Sort)
ALGORITHMS.
1 Searching and Sorting Searching algorithms with simple arrays Sorting algorithms with simple arrays –Selection Sort –Insertion Sort –Bubble Sort –Quick.
1 Principles of Computer Science I Honors Section Note Set 5 CSE 1341.
New Mexico Computer Science For All Search Algorithms Maureen Psaila-Dombrowski.
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
Computer Science 101 A Survey of Computer Science Sorting.
1. Searching The basic characteristics of any searching algorithm is that searching should be efficient, it should have less number of computations involved.
CMPT 120 Topic: Sorting Algorithms – Part 1. Last Lectures Searching algorithms and their time efficiency Linear search is of order n -> O(n) i.e., has.
Chapter 3: Sorting and Searching Algorithms 3.1 Searching Algorithms.
Exam practice. Exam 1  Describe how a Boolean expression can control the operation of a loop  Describe the difference between a while loop and for loop.
Searching and Sorting Copyright Prentice Hall (with additions / modifications by Evan Korth)
OCR A Level F453: Data structures and data manipulation Data structures and data manipulation a. explain how static data structures may be.
Copyright Prentice Hall Modified by Sana odeh, NYU
Searching Arrays Linear search Binary search small arrays
Recursion.
Searching and Sorting Searching algorithms with simple arrays
Sort Algorithm.
Searching and Sorting Algorithms
Outline lecture Revise arrays Entering into an array
COP 3503 FALL 2012 Shayan Javed Lecture 15
Introduction to Search Algorithms
Lesson 5-15 AP Computer Science Principles
Chapter 8 Arrays Objectives
Topics discussed in this section:
Sorting Data are arranged according to their values.
Topics discussed in this section:
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Bubble Sort Bubble sort is one way to sort an array of numbers. Adjacent values are swapped until the array is completely sorted. This algorithm gets its.
Teaching Computing to GCSE
Bubble Sort Bubble sort is one way to sort an array of numbers. Adjacent values are swapped until the array is completely sorted. This algorithm gets its.
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.
Algorithms Chapter 3 With Question/Answer Animations
Selection Sort Sorted Unsorted Swap
Selection Sort – an array sorting algorithm
CSc 110, Spring 2017 Lecture 39: searching.
كلية المجتمع الخرج البرمجة - المستوى الثاني
Chapter 8 Arrays Objectives
Sorting Data are arranged according to their values.
Teaching Computing to GCSE
MSIS 655 Advanced Business Applications Programming
UNIT – V PART - I Searching By B VENKATESWARLU, CSE Dept.
Search,Sort,Recursion.
C Arrays (2) (Chapter 6) ECET 264.
Given value and sorted array, find index.
Searching and Sorting Arrays
Chapter 8 Arrays Objectives
Intro to Computer Science CS1510 Dr. Sarah Diesburg
CPS120: Introduction to Computer Science
CPS120: Introduction to Computer Science
Binary Search Counting
The Binary Search by Mr. Dave Clausen
Sorting Algorithms.
CMPT 225 Lecture 16 – Heap Sort.
Presentation transcript:

WJEC GCSE Computer Science Unit 2 Searching and Sorting

Learning Intentions and Outcomes Explain and use linear and binary search algorithms. Describe the characteristics of merge sort and bubble sort algorithms. Developing Explain how linear and binary search algorithms work Follow linear and binary search algorithms to identify if an item is found in a list Describe how the merge sort algorithm works Describe how the bubble sort algorithm works Secure Demonstrate a bubble sort algorithm on a set of data Demonstrate a merge sort algorithm on a set of data

Linear Search Linear search is the simplest searching algorithm; it starts at the first element in the list and checks every element until it finds the one it is looking for. LIST = Let’s search for 7: SEARCH = 7 FOR i in range(LIST): if LIST[i] == SEARCH: RETURN “Found” 3 8 1 4 7 6 9 2 12 11 10 5

Binary Search Binary search is a good way of searching lists that have been sorted. At each step it halves the number of items it needs to look at. In this example we are going to search for 14. 1 2 4 5 6 8 10 12 13 14 15 1 FUNCTION BSearch(List, ItemToFind, Min, Max) Variable Value Min Max MidPoint 2 MidPoint = (Min + ((Max – Min / 2)) 6 3 IF List[MidPoint] < ItemToFind THEN (10-5) 5 9 11 4 Bsearch(List, ItemToFind, MidPoint+1, Max) 10 8 5 5 ELSE IF List[MidPoint] > ItemToFind THEN Return Value 10 6 Bsearch(List, ItemToFind, Min, MidPoint-1) 7 ELSE 8 RETURN MidPoint 9 END IF 9 END FUNCTION

Comparing Linear and Binary Search

Bubble Sort

Bubble Sort One “Pass” of the Bubble Sort Algorithm A “Pass” is an iteration over the entire unsorted section of the array.

Merge Sort

Workbook Complete section 10 Q1-4