Computer Science Sorting Pre-Test Discussion/program

Slides:



Advertisements
Similar presentations
Chapter 12 Sorting and searching. This chapter discusses n Two fundamental list operations. u Sorting u Searching n Sorted lists. n Selection/bubble sort.
Advertisements

An intro to programming concepts with Scratch Session 8 of 10 sessions Working with lists; sorting a list.
Revision.
Order Analysis of Algorithms Debdeep Mukhopadhyay IIT Madras.
Computer Science: A Structured Programming Approach Using C1 8-4 Array Applications In this section we study two array applications: frequency arrays with.
Searching and Sorting Copyright Prentice Hall (with modifications by Evan Korth)
CS107 Introduction to Computer Science Lecture 5, 6 An Introduction to Algorithms: List variables.
CS 106 Introduction to Computer Science I 03 / 08 / 2010 Instructor: Michael Eckmann.
IT Systems Flip - Flops EN230-1 Justin Champion C208 –
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic concepts and uses of arrays ❏ To be able to define C.
End Show Writing a computer program involves performing the following tasks. 1. Understanding the problem 2. Developing an Algorithm for the problem 3.
Creating Table using LOOP By Adnan and M.Qazi Programmers.
Computer Science 101 Introduction to Sorting. Sorting One of the most common activities of a computer is sorting data Arrange data into numerical or alphabetical.
Summary Algorithms Flow charts Bubble sort Quick sort Binary search Bin Packing.
Introduction to C++ Programming Language Assistant Professor Jeon, Seokhee Assistant Professor Department of Computer Engineering, Kyung Hee University,
Sorts Tonga Institute of Higher Education. Introduction - 1 Sorting – The act of ordering data Often, we need to order data.  Example: Order a list of.
Fundamentals of Algorithms MCS - 2 Lecture # 15. Bubble Sort.
To know and use the Bubble Sort and Shuttle Sort Algorithms.
Sorting List is rearranged into sorted order How is the sorted order determined? – The ItemType is responsible for determining the key to be used in comparison.
Example { 1 – –1} Use Bubble Sort (sort in increasing order} After first pass { –1 50} After Second Pass { } After.
1. Understand the application of Pseudo Code for programming purposes 2. Be able to write algorithms in Pseudo Code.
Computer Science I: Understand how to evaluate expressions with DIV and MOD Random Numbers Reading random code Writing random code Odds/evens/…
Sorting & Searching Geletaw S (MSC, MCITP). Objectives At the end of this session the students should be able to: – Design and implement the following.
Array Review Selection Sort Get out your notes.. Learning Objectives Be able to dry run programs that use arrays Be able to dry run programs that use.
Computer Science 2 Arrays of Records. First Record Program Input an unknown number of Team Names, School names, and Total scores. (While loop) –Output:
Searching and Sorting Copyright Prentice Hall (with additions / modifications by Evan Korth)
Starter Complete the Word Search. CG3.7 Algorithms (The Insertion Sort (Chapter 46) & Algorithm Testing)
Copyright Prentice Hall Modified by Sana odeh, NYU
Introduction to Sorting
Growth of Functions & Algorithms
Learning outcomes 2 Developing Code – Input Output Model
Entry Ticket: Algorithms and Program Construction
Data Structures and Algorithms
Chapter 2 (16M) Sorting and Searching
Chapter 8 Arrays Objectives
Topics discussed in this section:
Array Review Selection Sort
Analysis of Bubble Sort and Loop Invariant
Topics discussed in this section:
مفاهیم بهره وري.
Computer Science 1 Online time to complete/enhance second repeat program Be able to read and write a program that uses the ‘case’ statement.
محاضرة 1: مقدمة للمسـاق و مراجعـة للأساسيـات
Chapter 8 Arrays Objectives
Sorts on the AP Exam Insertion Sort.
Simple Algorithms to Teach the Ideas Behind Coding
Computer Science 2 Arrays of Records.
Computer Science 2 Review the Bubble Sort
Insertion Sort Quiz on Thursday.
Computer Science 2 Getting an unknown # of …. Into an array.
Insertion Sort.
Computer Science Sorting.
Computer Science 2 Arrays of Records.
Simple Algorithms to Teach the Ideas Behind Coding
Sorting Example Bubble Sort
Chapter 8 Arrays Objectives
AP Java 9/21/2018.
do/while Selection Structure
Sorting Develop a sorting algorithm
COP3530- Data Structures Introduction
Computer Science I: Get out your notes.
Array Review Selection Sort
Program: Mini Phone Book 2/11/2016
Insertion Sort.
Random Numbers while loop
Computer Science 1 while
Mod 3 Lesson 2 Me First! Sorting
Dry Run Fix it Write a program
WJEC GCSE Computer Science
Algorithms.
Insertion and Shell Sorts
Presentation transcript:

Computer Science Sorting Pre-Test Discussion/program Bubble and Selection Sort (If time)

Learning Objectives Develop two algorithms for putting information in order. Be introduced to measuring the efficiency of an algorithm

Sorting How do you put things in order? (Low to high) Pseudo-Code Develop a sorting algorithm

Bubble Sort Low High 8 2 6 9 21 1 Speed: O(n2) Stability: Stable How it works: Check- Switch Show it after each pass Low High 8 2 6 9 21 1

Bubble Sort {This is just the code for Bubble Sort} for pass:= 1 to (size -1) do begin for check:= 1 to size-1 do if TheArray[check]>TheArray[check+1] then dummy:= TheArray[check]; TheArray[check]:= TheArray[check+1]; TheArray[check+1]:= dummy; End; {Of the if and the for check loop} end;{Of the for pass loop}

Bubble Sorting Program Option #1 Randomly generate 100 scores from 1 to 50. Show the numbers before they are sorted show the numbers after they are sorted. Push: Show graphically the numbers being sorted. Push: Change it to 5000, 50000, 5000000 numbers and time how long it takes for them to sort. Push: Improve the efficiency of the sort. Option #2 Input 10 race times for the 100 meter dash. (enter the time as seconds) Output: The times sorted from fastest to slowest. Push: Enter the name that goes with each time, and show a chart of names and times for the race.