APP INVENTOR. Test Review



Similar documents
For example, we have seen that a list may be searched more efficiently if it is sorted.

Sorting revisited. Build the binary search tree: O(n^2) Traverse the binary tree: O(n) Total: O(n^2) + O(n) = O(n^2)

6. Standard Algorithms

Converting a Number from Decimal to Binary

Binary Heap Algorithms

Quick Sort. Implementation

No Solution Equations Let s look at the following equation: 2 +3=2 +7

Math Circle Beginners Group October 18, 2015

Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

Heaps & Priority Queues in the C++ STL 2-3 Trees

Analysis of Binary Search algorithm and Selection Sort algorithm

Section 1.4 Place Value Systems of Numeration in Other Bases

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

B-Trees. Algorithms and data structures for external memory as opposed to the main memory B-Trees. B -trees

Data Structures. Topic #12

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

Zeros of a Polynomial Function

Data Structures and Data Manipulation

Base Conversion written by Cathy Saxton

CSC148 Lecture 8. Algorithm Analysis Binary Search Sorting

Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser Quiz 1.

Module 9. User Interface Design. Version 2 CSE IIT, Kharagpur

Previous Lectures. B-Trees. External storage. Two types of memory. B-trees. Main principles

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Data Structures Fibonacci Heaps, Amortized Analysis

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

Test 4 Sample Problem Solutions, = , 7 5, = = 1.4. Moving the decimal two spots to the left gives

Outline. Introduction Linear Search. Transpose sequential search Interpolation search Binary search Fibonacci search Other search techniques

Battleships Searching Algorithms

Chapter 11 Number Theory

Chapter 13: Query Processing. Basic Steps in Query Processing

Solutions of Linear Equations in One Variable

Welcome to Harcourt Mega Math: The Number Games

Clock Arithmetic and Modular Systems Clock Arithmetic The introduction to Chapter 4 described a mathematical system

CHAPTER 19 Programming Lists of Data

Graphing Rational Functions

Node-Based Structures Linked Lists: Implementation

RSA Question 2. Bob thinks that p and q are primes but p isn t. Then, Bob thinks Φ Bob :=(p-1)(q-1) = φ(n). Is this true?

Zabin Visram Room CS115 CS126 Searching. Binary Search

Multiplying Fractions

s = s = s =

KS3 Computing Group 1 Programme of Study hours per week

Record Storage and Primary File Organization

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

Grade 7 & 8 Math Circles October 19, 2011 Prime Numbers

CHAPTER 18 Programming Your App to Make Decisions: Conditional Blocks

Solutions to Math 51 First Exam January 29, 2015

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 10

Symbol Tables. Introduction

Chapter 7 - Roots, Radicals, and Complex Numbers

Partitioning and Divide and Conquer Strategies

6 March Array Implementation of Binary Trees

Algorithms. Margaret M. Fleck. 18 October 2010

CSC 180 H1F Algorithm Runtime Analysis Lecture Notes Fall 2015

Chapter 6: Physical Database Design and Performance. Database Development Process. Physical Design Process. Physical Database Design

Outline BST Operations Worst case Average case Balancing AVL Red-black B-trees. Binary Search Trees. Lecturer: Georgy Gimel farb

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Physical Data Organization

Partial Fractions Decomposition

An Introduction to Number Theory Prime Numbers and Their Applications.

Simplifying Algebraic Fractions

MEP Y9 Practice Book A

recursion, O(n), linked lists 6/14

Fundamentals of Probability

Row Echelon Form and Reduced Row Echelon Form

International Journal of Advanced Research in Computer Science and Software Engineering

Kenken For Teachers. Tom Davis June 27, Abstract

Programming Your App to Make Decisions: Conditional Blocks

Binary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child

MATH-0910 Review Concepts (Haugen)

Chapter Objectives. Chapter 9. Sequential Search. Search Algorithms. Search Algorithms. Binary Search

Data Structures. Chapter 8

7.S.8 Interpret data to provide the basis for predictions and to establish

Historical Slideshow App A Coding Solution (This is a spoiler document)

Computer Science 210: Data Structures. Searching

Programming Lists of Data

- Easy to insert & delete in O(1) time - Don t need to estimate total memory needed. - Hard to search in less than O(n) time

Encoding Text with a Small Alphabet

Lecture 5: Gate Logic Logic Optimization

Useful Number Systems

Section IV.1: Recursive Algorithms and Recursion Trees

1 Present and Future Value

2) Based on the information in the table which choice BEST shows the answer to 1 906?

SOLVING QUADRATIC EQUATIONS - COMPARE THE FACTORING ac METHOD AND THE NEW DIAGONAL SUM METHOD By Nghi H. Nguyen

NUMBER SYSTEMS. William Stallings

/ Department of Mechanical Engineering. Manufacturing Networks. Warehouse storage: cases or layers? J.J.P. van Heur. Where innovation starts

Computer Science 281 Binary and Hexadecimal Review

Multiplying and Dividing Fractions

THE NUMBER OF REPRESENTATIONS OF n OF THE FORM n = x 2 2 y, x > 0, y 0

Chapter 7 Memory Management

Persistent Binary Search Trees

Data Structures and Algorithm Analysis (CSC317) Intro/Review of Data Structures Focus on dynamic sets

ZIMBABWE SCHOOL EXAMINATIONS COUNCIL. COMPUTER STUDIES 7014/01 PAPER 1 Multiple Choice SPECIMEN PAPER

The Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)!

361 Computer Architecture Lecture 14: Cache Memory

IB Maths SL Sequence and Series Practice Problems Mr. W Name

Greatest Common Factor and Least Common Multiple

Chapter 8: Bags and Sets

Hash Tables. Computer Science E-119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. Data Dictionary Revisited

Transcription:

APP INVENTOR Test Review

Main Concepts App Inventor Lists Creating Random Numbers Variables Searching and Sorting Data Linear Search Binary Search Selection Sort Quick Sort Abstraction Modulus Division

Lists

Lists Lists allow you to store a large group of data within a variable. Lists are an important part of computer science as we learned with searching and sorting data (see notes below)

Lists Each location in a list is called an index. Example: the second item (no way) found in the list below is found in index 2. The length of a list is determined by how many items are found in the list. Example: The list below has a length of 8.

Random Numbers

Random Numbers Often in programs we need to create random numbers. The random blocks are found in the Math block category. The block above will create a random number between 1 and 100 including 1 and 100. We used this block in the magic 8 ball program.

Variables

Variables A variable is a named place in memory. Each variable has a name and stores a value. Variables can hold: Numbers Colors Words Names of files media files Variables can only hold one value at a time but that value can change.

Creating a Variable App Inventor 1. Navigate to the Blocks View 2. Select the Variable built in category of blocks 3. Select the initialize global name to block 4. Give it a value (variables can hold, numbers, words, lists, colors, logic blocks) 5. Assign the variable a meaningful name

Variables Initialize a variable means to create a new variable and give it a value: Variable has 2 blocks Setter Blocks Used to set a new value stored in a variable Getter Blocks Used to get the value stored in a variable

Searching and Sorting Data

Searching And Sorting Why? Most of what a computer does is searching and sorting data. Because of this, it is a widely studied part of computer science. Producing many solutions to the problem of sorting and search data. We looked at 2 searches Linear Search Binary Search 2 Sorts Selection Quick

Searching Linear Search Linear Search: Checks each element in a sequence until the desired element is found or the list is exhausted, meaning that the desired target is not in the list. Used if the list that is to be searched is not ordered. Generally, this technique is used for small lists, or lists that are not searched often. Key Points: Speed: This search method is on average slower than the Binary Search. Order: This search can be used if the data is sorted or Not. Best Case Scenario: The item is found in the first comparison. Worst Case Scenario: The item is found in the last index of the list or it is not located in the list at all.

Linear Search - Example

Searching: Binary Search Binary Search: starts by comparing the target (the value that you are looking for) with the value found in the middle index of the list. If the value found in the middle index is greater than that of the target, you can ignore all of the data that is after that middle index. The process is then repeated with the remaining data until we either find the target value or satisfy ourselves that the target is not in the list. Find the new middle, compare, and remove the half where the target is not found.

Searching Binary Search Key points: Speed: This search method is on average faster than a Linear Search. Order: This search can only be used if the data is sorted. Best Case Scenario: The item will be found faster than a Linear Search. Worst Case Scenario: The item will be found just as fast as a Linear Search.

Binary Search: Example

Sorting- Selection Sort 1. Divide the list to be sorted into a sorted portion at the front (initially empty) and an unsorted portion at the end (initially the whole list). 2. Find the smallest element in the unsorted list: 1. Select the first element of the unsorted list as the initial candidate. 2. Compare the candidate to each element of the unsorted list in turn, replacing the candidate with the current element if the current element is smaller. 3. Once the end of the unsorted list is reached, the candidate is the smallest element. 3. Swap the smallest element found in the previous step with the first element in the unsorted list, thus extending the sorted list by one element. 4. Repeat the steps 2 and 3 above until only one element remains in the unsorted list.

Selection Sort - Key points Difficulty: Easy. The simplest sorting technique. Data Set Size: Very small. This is a good algorithm to sort a small number of elements because the number of comparisons is low. Speed: Slow... maybe. It is potentially very slow if you are sorting a large set of data of 100,000 phone numbers or example.

Sorting - Quick Sort 1. Randomly pick an element, called a pivot, from the list. 2. Reorder the list so that all elements with values less than the pivot are placed before the pivot, while all elements with values greater than the pivot are placed after it (equal values can go either way). 3. After this partitioning, the pivot is in its final position. 4. Repeat the process by sorting the sub-list of lesser elements and the sub-list of greater elements. (Source: Wikipedia.org)

Quick Sort Key Points Difficulty: Low to medium. More complex than a Selection Sort but still quite simple to understand. Data Set Size: Large. This is a good algorithm to sort a large number of elements because the number of comparisons is small in comparison to the number of items in the list. Speed: Faster... maybe. It is potentially very fast if you are sorting a large set of data of 100,000 phone numbers or example. It will never be slower than a selection sort

Abstraction

Abstraction - Definition In computer science the term abstract means to simplify, generalize or to eliminate irrelevant detail. In computer science, we use the term to mean simplifying or eliminating irrelevant detail so that we can create a model or plan a solution to a problem. An abstraction is a general representation of something -- of some person or place or event or process. Abstractions are formed by including only those details needed to make the abstraction useful to us in some way.

Abstraction - Example A map is an example of abstraction because it removes all unnecessary information from the map. It only keeps what is important; general aspects of the geography. It doesn t show every part of the geography. It can t. It can t show every tree and flower. The person who made the map abstracted out the irrelevant information and left the most important information for finding the treasure.

Abstraction - Example A variable is an example of abstraction. In a program a variable can hold many different values. The programmer doesn t have to worry about every single value that it holds. They just have to worry if the variable value can be used in an equation. The specific value in the variable number is not important. What is important is the equation. It will always add one to the current value of number.

Modulus Division

Modulus Division Modulus division returns the remainder after the division of one number by another. Rather than returning the quotient, modulus division returns the remainder. 26 % 5 = 1 (% = Modulus division) The modulus division block is found in the math category

Modulus division We used modulus division in the list_picker practice app We used it to know if the length of the list is odd or even. If it is odd then the modulus division will result in a number. If it results in a 0 then the list is even. 4 % 2 = 0 (even) 5 % 2 = 1 (odd)