Tutorial 6 Array Problem Solving

Slides:



Advertisements
Similar presentations
Identity and Inverse Matrices
Advertisements

Inverses of n x n Matrices. The Inverse Matrix If A is an n x n matrix, the inverse of A (call it A -1 ) is the matrix such that A * A -1 is equal to.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 10.
Matrix Algebra THE INVERSE OF A MATRIX © 2012 Pearson Education, Inc.
Value Iteration 0: step 0. Insertion Sort Array index67 Iteration i. Repeatedly swap element i with.
Tutorial 9 String and Structure NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO.
Using Matrices to Solve a 3-Variable System
CE 311 K - Introduction to Computer Methods Daene C. McKinney
4.7 Identity and Inverse Matrices. What is an identity? In math the identity is the number you multiply by to have equivalent numbers. For multiplication.
Copyright © Cengage Learning. All rights reserved. 7.6 The Inverse of a Square Matrix.
Using Matrices to Solve a System of Equations. Multiplicative Identity Matrix The product of a square matrix A and its identity matrix I, on the left.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic concepts and uses of arrays ❏ To be able to define C.
 Definition: An Identity Matrix is a square matrix that, when multiplied by another matrix, equals the same matrix.  Form: In the Identity Matrix the.
Section 8.3 – Systems of Linear Equations - Determinants Using Determinants to Solve Systems of Equations A determinant is a value that is obtained from.
B+ Tree What is a B+ Tree Searching Insertion Deletion.
F UNDAMENTALS OF E NGINEERING A NALYSIS Eng. Hassan S. Migdadi Inverse of Matrix. Gauss-Jordan Elimination Part 1.
Reasoning with invariants Jordi Cortadella Department of Computer Science.
Inverse & Identity Matrices
2.5 The Gauss-Jordan Method for Calculating Inverses Finding Inverses When the matrix is a 2 x 2, the inverse is easy to find using the determinant. What.
Chapter 4 Section 4: Inverse and Identity Matrices 1.
EXAMPLE 3 Find the inverse of a 3 × 3 matrix Use a graphing calculator to find the inverse of A. Then use the calculator to verify your result. 2 1 – 2.
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Searching Course Lecture Slides 28 May 2010 “ Some things Man was never.
Inverse and Identity Matrices Can only be used for square matrices. (2x2, 3x3, etc.)
Bill Payment Optimization Algorithms. Purpose To find and/or construct algorithms that will optimize the decision process of paying bills from an account.
Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO.
Chapter 4 Review: Manipulating Matrices Introduction to MATLAB 7 Engineering 161.
4.4 Identify and Inverse Matrices Algebra 2. Learning Target I can find and use inverse matrix.
4.5 Matrices, Determinants, Inverseres -Identity matrices -Inverse matrix (intro) -An application -Finding inverse matrices (by hand) -Finding inverse.
1 Arrays of Arrays An array can represent a collection of any type of object - including other arrays! The world is filled with examples Monthly magazine:
CS1010E Programming Methodology Tutorial 7 Arrays and Matrices C14,A15,D11,C08,C11,A02.
Methods for Multiplication Tutorial By: Melinda Hallock.
Tutorial 2 Control Flow: Loops NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO.
Slide 1 Insert your own content.. Slide 2 Insert your own content.
Copyright © Cengage Learning. All rights reserved. 8 Matrices and Determinants.
Matrices IB Mathematics SL. Matrices Describing Matrices Adding Matrices.
Using Matrices to Solve a 3-Variable System
16 Searching and Sorting.
Decision Trees DEFINITION: DECISION TREE A decision tree is a tree in which the internal nodes represent actions, the arcs represent outcomes of an action,
Lecture 5 of Computer Science II
Arrays (review) CSE 2011 Winter May 2018.
1.5 Matricies.
Computer Programming BCT 1113
Tutorial 8 Pointers and Strings
Chapter 8 Arrays Objectives
More complexity analysis & Binary Search
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.
Sorting Data are arranged according to their values.
CSE 143 Lecture 23: quick sort.
Warmup: Find the product, if possible. −6 4 − 
Search Sorted Array: Binary Search Linked List: Linear Search
Chapter 8 Arrays Objectives
CIS16 Application Development and Programming using Visual Basic.net
Sorting Data are arranged according to their values.
Slide 1 Insert your own content.. Slide 1 Insert your own content.
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.
Master Theorem Yin Tat Lee
Slide 1 Insert your own content.. Slide 1 Insert your own content.
Slide 1 Insert your own content.. Slide 1 Insert your own content.
Unit 3: Matrices
Array and Matrix Functions
CSE 373 Data Structures and Algorithms
24 Searching and Sorting.
Given value and sorted array, find index.
ARRAY DIVISION Identity matrix Islamic University of Gaza
Domain range A A-1 MATRIX INVERSE.
Chapter 8 Arrays Objectives
Inverse of a Matrix Solving simultaneous equations.
Insertion Sort Array index Value Insertion sort.
Instructor: Dr. Michael Geiger Spring 2017 Lecture 30: Sorting & heaps
Presentation transcript:

Tutorial 6 Array Problem Solving NUS School of Computing CS1010E Programming Methodology CS1010E Tutorial Slides Prepared by Wu Chao

CS1010E Tutorial Slides Prepared by Wu Chao Quick Summary CS1010E Tutorial Slides Prepared by Wu Chao

Q1: Insertion Sort Algorithm CS1010E Tutorial Slides Prepared by Wu Chao

Q1: Insertion Sort Algorithm 7 13 20 38 44 52 88 89 90 92 Starting with index 0 10 If current value is greater or equal, we return this index Otherwise, return last CS1010E Tutorial Slides Prepared by Wu Chao

Q1: Insertion Sort Algorithm CS1010E Tutorial Slides Prepared by Wu Chao

Q1: Insertion Sort Algorithm 7 13 20 38 44 52 88 89 90 92 52 13 20 38 44 52 Store the last value 52 Start copying from back Put last into the first CS1010E Tutorial Slides Prepared by Wu Chao

Q1: Insertion Sort Algorithm CS1010E Tutorial Slides Prepared by Wu Chao

Q1: Insertion Sort Algorithm findIndex(a[],1,a[1]); index = 0; shiftRight(a[],0,2); findIndex(a[],2,a[2]); index = 0; shiftRight(a[],0,3); findIndex(a[],3,a[3]); index = 0; shiftRight(a[],0,4); findIndex(a[],4,a[4]); index = 2; shiftRight(a[],2,3); CS1010E Tutorial Slides Prepared by Wu Chao

Q1: Insertion Sort Algorithm CS1010E Tutorial Slides Prepared by Wu Chao

Q2: Matrix Manipulation CS1010E Tutorial Slides Prepared by Wu Chao

Q2: Matrix Manipulation To check if a matrix is Identity Matrix: (1) Left Diagonal must be 1 (2) Others must be 0 Diagonal indices: i == j CS1010E Tutorial Slides Prepared by Wu Chao

Q2: Matrix Manipulation j = 0 1x9 + 2x6 + 3x3 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 9 8 7 6 5 4 3 2 1 9 8 7 6 5 4 3 2 1 30 i = 0 = X i = 0 A B C CS1010E Tutorial Slides Prepared by Wu Chao

Q2: Matrix Manipulation You have to iterate through all the cells of the resulting matrix and calculate its value! CS1010E Tutorial Slides Prepared by Wu Chao

Q2: Matrix Manipulation CS1010E Tutorial Slides Prepared by Wu Chao

CS1010E Tutorial Slides Prepared by Wu Chao Q3: Magic Square … CS1010E Tutorial Slides Prepared by Wu Chao

CS1010E Tutorial Slides Prepared by Wu Chao Q3: Magic Square [0][1] [2][2] CS1010E Tutorial Slides Prepared by Wu Chao

CS1010E Tutorial Slides Prepared by Wu Chao Q3: Magic Square [0][1] [1][0] [2][0] [2][2] CS1010E Tutorial Slides Prepared by Wu Chao

CS1010E Tutorial Slides Prepared by Wu Chao Q3: Magic Square CS1010E Tutorial Slides Prepared by Wu Chao