Computer Programming 2 Lecture 1: Advanced Array Data Structure Using Methods Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER.

Slides:



Advertisements
Similar presentations
1 Arrays, Strings and Collections [1] Rajkumar Buyya Grid Computing and Distributed Systems (GRIDS) Laboratory Dept. of Computer Science and Software Engineering.
Advertisements

Arrays.
An Array A sequence of elements of a particular type Each element in the array has an index which gives its position in the sequence An array is declared.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Arrays Chapter 6. Outline Array Basics Arrays in Classes and Methods Sorting Arrays Multidimensional Arrays.
ECE122 L14: Two Dimensional Arrays March 27, 2007 ECE 122 Engineering Problem Solving with Java Lecture 14 Two Dimensional Arrays.
1 2-D Arrays Overview l Why do we need Multi-dimensional array l 2-D array declaration l Accessing elements of a 2-D array l Declaration using Initializer.
1 More on Arrays Passing arrays to or from methods Arrays of objects Command line arguments Variable length parameter lists Two dimensional arrays Reading.
Chapter 9 Introduction to Arrays
Arrays (Part II). Two- and Multidimensional Arrays Two-dimensional array: collection of a fixed number of components (of the same type) arranged in two.
More Arrays Length, constants, and arrays of arrays By Greg Butler.
Prepared by MURLI MANOHAR PGT (COMPUTER SCIENCE) KV,B.E.G., PUNE.
Java Unit 9: Arrays Declaring and Processing Arrays.
03/16/ What is an Array?... An array is an object that stores list of items. Each slot of an array holds an individual element. Characteristics.
Computer Programming 2 Lecture 2: Advanced Array Data Structure Using Methods Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 6 Introduction to classes and objects.
Chapter 9: Advanced Array Concepts
Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 1: Course overview.
Relational Database Design by ER- and EER-to- Relational Mapping
Computer Programming 2 Lecture 3: Methods in Advanced & Practices Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER EDUCATION.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 7 Decision Making : selection statements.
1 Lecture # 4. * An array is a group of contiguous or related data items that share a common name. * Each value is stored at a specific position * Position.
Arrays and Strings Introducing Arrays Declaring Arrays Creating Arrays Initializing Arrays Array of Objects Copying Arrays Multidimensional Arrays Command-Line.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Two dimensional arrays in Java Computer Science 3 Gerb Objective: Use matrices in Java.
Computer Programming 2 Lecture 5: String Processing Part b: Class StringTokenizer Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION.
© 2004 Pearson Addison-Wesley. All rights reserved October 13, D Arrays ComS 207: Programming I (in Java) Iowa State University, FALL 2006 Instructor:
Computer Programming 12 Mr. Jean April 24, The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays.
Arrays  Array is a collection of same type elements under the same variable identifier referenced by index number.  Arrays are widely used within programming.
Introduction To Programming Information Technology , 1’st Semester
DT249-Information Systems Research Practice Programming Revision Lecture 2 Lecturer: Patrick Browne.
Data Structure CS 322. What is an array? Initializing arrays Accessing the values of an array Multidimensional arrays LAB#1 : Arrays.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Computer Programming 2 Lecture 10: File streaming (1) Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Computer Programming 2 Lecture 9: Object Oriented Programming Array Of Objects Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION &
Computer Programming 2 Lecture 8: Object Oriented Programming Creating Classes & Objects Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Arrays.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Arrays.
Module 1: Array ITEI222 - Advance Programming Language.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Arrays in java Unit-1 Introduction to Java. Array There are situations where we might wish to store a group of similar type of values in a variable. Array.
Arrays (part 2) 1 -Based on slides from Deitel & Associates, Inc. - Revised by T. A. Yang.
 Introducing Arrays  Declaring Array Variables, Creating Arrays, and Initializing Arrays  Copying Arrays  Multidimensional Arrays  Search and Sorting.
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
C++ Array 1. C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used.
Lecture #15 ARRAYS By Shahid Naseem (Lecturer). 2 ARRAYS DEFINITION An array is a sequence of objects of same data type. The objects in an array are also.
Introduction to programming in java Lecture 22 Arrays – Part 2 and Assignment No. 3.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 7A Arrays (Concepts)
Chapter 9 Introduction to Arrays Fundamentals of Java.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Presented By: Mahmoud Rafeek Alfarra
Presented By: Mahmoud Rafeek Alfarra
Introduction To Programming Information Technology , 1’st Semester
Part a: Fundamentals & Class String
2D Arrays October 12, 2007 ComS 207: Programming I (in Java)
Presented By: Mahmoud Rafeek Alfarra
Introduction To Programming Information Technology , 1’st Semester
Introduction To Programming Information Technology , 1’st Semester
class PrintOnetoTen { public static void main(String args[]) {
Presented By: Mahmoud Rafeek Alfarra
Arrays in Java.
Introduction To Programming Information Technology , 1’st Semester
C++ Array 1.
Presented By: Mahmoud Rafeek Alfarra
Presentation transcript:

Computer Programming 2 Lecture 1: Advanced Array Data Structure Using Methods Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY (CST) KHANYOUNIS- PALESTINE

و من يتقِ الله... قال ربي سبحـانه : و لو أن أهل القرى أمنوا و اتقوا لفتحنا عليهم بركات من السماء و الأرض. Mahmoud Rafeek Alfarra 2 Downloaded from شريحـة ثابتـة لعلنا نحسن من خلالها أخلاقنـا و أفعالنا لنفوز يوم الامتحان الحقيقي

Out Lines Mahmoud Rafeek Alfarra Downloaded from Downloaded from 3 Revision about Array data structure Example: Store the even elements in array What is Multidimensional Arrays? Applications !! Example: X O’s Project.

Revision about Array data structure Mahmoud Rafeek Alfarra Downloaded from Downloaded from 4 An array is a special type of object that can hold an ordered collection of elements. The type of the elements of the array is called the base type of the array; the number of elements it holds is a fixed attribute called its length. Java supports arrays of all primitive and reference types.

Revision about Array data structure Mahmoud Rafeek Alfarra Downloaded from Downloaded from 5 Arrays are static data structure (which means ?!!).

Revision about Array data structure Mahmoud Rafeek Alfarra Downloaded from Downloaded from 6 To Create & initialize the one dim. array: basetype [] arrayname = new basetype [length]; Arrayname[0] = val1; Arrayname[1] = val2; Arrayname[…] = val n ; Or basetype [] arrayname = { val1, val2, val3, … };

Revision about Array data structure Mahmoud Rafeek Alfarra Downloaded from Downloaded from 7 Examples: int [] salary = new int [3]; salary[0] = 487; salary[1] = 600; salary[2] = 894; Or int [] salary = { 487, 600, 894 };

Example : Store even elements in array Mahmoud Rafeek Alfarra Downloaded from Downloaded from 8 Using Procedural programming, Write a program to store the even numbers from int To int in array. Then, print the summation of the array’s elements.

Mahmoud Rafeek Alfarra Downloaded from Downloaded from 9 import javax.swing.JOptionPane; public class SumEvenArray { public static void even (int low, int high){ int size = (high - low)/2 +2; int [] evenarr = new int [size]; int len=0; for (int i = low; i<=high; i++) { if (i%2==0){ evenarr[len] = i; len++;} } sumarr(evenarr); } public static void sumarr(int [] evenarr) { int sum=0; for (int i =0; i<evenarr.length; i++) sum= sum+evenarr[i]; JOptionPane.showMessageDialog(null, "Sum is: "+sum); } public static void main(String[] args) { even(100, 110); } }

What is Multidimensional Arrays? Mahmoud Rafeek Alfarra Downloaded from Downloaded from 10 Multidimensional arrays with two dimensions are often used to represent tables of values consisting of information arranged in rows and columns. To identify a particular table element, we must specify two indices. By convention, the first identifies the element's row and the second its column.

What is Multidimensional Arrays? Mahmoud Rafeek Alfarra Downloaded from Downloaded from 11 To Create & initialize the two dim. array: basetype [] [] arrayname = new basetype [r][c]; Arrayname[0] [0]= val1; Arrayname[0] [1] = val2; Arrayname[…][…] = val n ; Or basetype [] [] arrayname = { {val1, val2}, {val3, …} };

What is Multidimensional Arrays? Mahmoud Rafeek Alfarra Downloaded from Downloaded from 12 To Create & initialize the two dim. array: int [] [] table = new int [3][2]; table[0] [0]= 3; table[0] [1] = 5; table[0] [2] = 4; table[…][…] = val n ; Or int [] [] table = { {3, 5, 4}, {valn, …} };

What is Multidimensional Arrays? Mahmoud Rafeek Alfarra Downloaded from Downloaded from 13 Java does not support multidimensional arrays directly, but it does allow the programmer to specify one-dimensional arrays whose elements are also one-dimensional arrays.

Example : Mahmoud Rafeek Alfarra Downloaded from Downloaded from 14 Using Procedural programming, Write a program to store the following figure (multiple of 1, 2, 3, 4 by its successors to three times)

Lets thinking now … Mahmoud Rafeek Alfarra Downloaded from Downloaded from ? How To

Next Lecture … Mahmoud Rafeek Alfarra Downloaded from Downloaded from 16 Continue Array’s Application