Review - PowerPoint PPT Presentation

About This Presentation
Title:

Review

Description:

formula: Cij = Ai * Bj. public static int[][] Multiplication(int[][] A, int[][]B) ... Constructor in child class will call constructor in parent class automatically ... – PowerPoint PPT presentation

Number of Views:7
Avg rating:3.0/5.0
Slides: 14
Provided by: csCor
Category:
Tags: class | review

less

Transcript and Presenter's Notes

Title: Review


1
Review
  • Multi-Dimensional Array
  • Searching and Sorting in arrays
  • Inheritance
  • Graphics

2
2-D Array and Table
  • Int e new int56

0
5
4
3
2
1





0
1
2
3
4
e31
3
of Rows and Columns
  • int e new int56
  • Get No of rows
  • e.length ?
  • Get No of columns
  • e0.length ?
  • e1.length ?

4
Print A Matrix
  • Matrix is 2-d Array (rectangular)
  • 1 2 3
  • 4 5 6
  • 7 8 9
  • print 1 2 3 4 5 6 7 8 9
  • public static void Print(int A)
  • int row A.length
  • int col A0.length
  • for (int I0 Iltrow I)
  • for (int j0 jltcol j)
  • System.out.prinln(AIj )

5
Matrix Addition
  • 1 2 3 1 1 1 2 3 4
  • 4 5 6 2 2 2 6 7 8
  • 4 6 4 3 3 3 7 9 7
  • A B C
  • formula Cij Aij Bij
  • public static int Add(int A, int B)

6
Matrix Multiplication just for your fun
  • 3 2 2 1 8 5
  • 2 1 1 1 5 3
  • formula Cij Ai Bj
  • public static int Multiplication(int A,
    intB)

7
Sequential or Binary Search
  • Can you perform sequential search on A1? A2?
  • Can you perform binary search on A1? A2?
  • A1
  • A2

8 6 9 4 7 1 2
1 2 4 6 7 8 9
8
Summary
  • Binary search
  • takes advantage of the characteristics of sorted
    array, can only be performed on a sorted array.
  • Its fast
  • Sequential search
  • can be performed on both unsorted and sorted
    array
  • Its slow

9
Selection Sort Select the smallest oneDemo
http//www-courses.cs.uiuc.edu/cs125/cs125/_nav/_
framepage/notesPage.html
10
Insertion Sort Maintain partial and sorted
arrayDemo http//www-courses.cs.uiuc.edu/cs125/
cs125/_nav/_framepage/notesPage.html
11
Sort Example
  • Sort students by height
  • Sort by height, but female student go first
  • Sort students by height, if there is a tie,
    smaller studentID stay in front.
  • Sort students by name
  • Sort using insertionsort algorithm

12
Inheritance
  • Constructor in child class will call constructor
    in parent class automatically
  • method overriding
  • method overloading

13
File I/O , GUI
  • see Kiris handout
  • TextFileInputDemo.java
  • TextFileOutputDemo.java
  • ButtonDemo.java
Write a Comment
User Comments (0)
About PowerShow.com