INTRODUCTION OF ARRAY. Topics To Be Discussed………………………. Introduction Types of array One Dimensional Array Internal representation of one-dimensional array.

Slides:



Advertisements
Similar presentations
UNIT IV.
Advertisements

Etter/Ingber Arrays and Matrices. Etter/Ingber One-Dimensional Arrays 4 An array is an indexed data structure 4 All variables stored in an array are of.
One Dimensional Arrays
Chapter 6 Data Structures
Arrays and records Programming Language Design and Implementation
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Arrays.
Lecture # 02 07/02/2013Dr. Muhammad Umair 1. 07/02/2013Dr. Muhammad Umair 2  Numeric  Integer Numbers  0,10,15,4563 etc.  Fractional Number  10.5,
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Introduction to Arrays.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 8 Arrays.
CMSC 250 Discrete Structures Summation: Sequences and Mathematical Induction.
Structured Data Types and Encapsulation Mechanisms to create new data types: –Structured data Homogeneous: arrays, lists, sets, Non-homogeneous: records.
Introduction to Programming with C++ Fourth Edition
C++ for Engineers and Scientists Third Edition
Introduction of Arrays. Arrays Array form an important part of almost all programming language. It provides a powerful feature and can be used as such.
Chapter 8 Arrays and Strings
Arrays. Objectives Learn about arrays Explore how to declare and manipulate data into arrays Learn about “array index out of bounds” Become familiar with.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
ARRAYS, RECORDS AND POINTER
Chapter 7: Arrays. In this chapter, you will learn about: One-dimensional arrays Array initialization Declaring and processing two-dimensional arrays.
Introduction to Data Structures. Definition Data structure is representation of the logical relationship existing between individual elements of data.
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
Array.
Chapter 8 Arrays and Strings
COSC 1P03 Introduction to Data Structures 1.1 COSC 1P03  Audience  planning to major in COSC (prereq. 1P02 60%)  Lectures (AS202, AS217), labs (J301),
Chapter 2 ARRAYS.
Course Teacher: Moona Kanwal
Arrays.
Lecture 4 on Data Structure Array. Prepared by, Jesmin Akhter, Lecturer, IIT, JU Searching : Linear search Searching refers to the operation of finding.
Data Strcutures.
ARRAYS 1 Week 2. Data Structures  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently 
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
Java Script: Arrays (Chapter 11 in [2]). 2 Outline Introduction Introduction Arrays Arrays Declaring and Allocating Arrays Declaring and Allocating Arrays.
Course Title Object Oriented Programming with C++ Course instructor ADEEL ANJUM Chapter No: 05 ARRAY 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER) 1.
CHAPTER: 12. Array is a collection of variables of the same data type that are referenced by a common name. An Array of 10 Elements of type double.
Computer Science: A Structured Programming Approach Using C1 8-7 Two-Dimensional Arrays The arrays we have discussed so far are known as one- dimensional.
Lecture -3 on Data structures Array. Prepared by, Jesmin Akhter, Lecturer, IIT, JU Array Data structures are classified as either linear or nonlinear.
Week # 2: Arrays.  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently  Types of data.
IN THE NAME OF ALLAH WHO IS THE MOST BENEFICENT AND MOST MERCIFUL.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
Review Sorting algorithms Selection Sort Insertion Sort Bubble Sort Merge Sort Quick Sort.
Computer Science: A Structured Programming Approach Using C1 8-7 Two-Dimensional Arrays The arrays we have discussed so far are known as one- dimensional.
1 Arrays of Arrays Quick review … arrays Arrays of arrays ≡ multidimensional array Example: times table Representation in memory Ragged arrays Example:
Arrays An array is an indexed data structure which is used to store data elements of the same data type. An array is an indexed data structure which is.
1. 2  Introduction  Array Operations  Number of Elements in an array One-dimensional array Two dimensional array Multi-dimensional arrays Representation.
REEM ALMOTIRI Information Technology Department Majmaah University.
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.
© Janice Regan, CMPT 128, January CMPT 128: Introduction to Computing Science for Engineering Students Introduction to Arrays.
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.
Two dimensional arrays A two dimensional m x n array A is a collection of m. n elements such that each element is specified by a pair of integers (such.
MULTI-DIMENSIONAL ARRAYS 1. Multi-dimensional Arrays The types of arrays discussed so far are all linear arrays. That is, they all dealt with a single.
Arrays (Chapter 5)‏ Definition Applications One-Dimensional –Declaration –Initialization –Use Multidimensional.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
© 2004 Pearson Addison-Wesley. All rights reserved7-1 Array review Array of primitives int [] count; count = new int[10]; Array of objects Grade [] cs239;
1. Traversing a linear array Here A is a linear array with lower bound LB and upper bound UB. This algorithm traverses A applying an operation PROCESS.
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.
Lecture # 20 Sequence & Series
Array, Strings and Vectors
Operation performed by Linear Structure
Arrays.
Algorithms & Arrays.
Visual Basic .NET BASICS
ARRAYS, RECORDS AND POINTER
Data Structures (CS212D) Week # 2: Arrays.
Arrays Week 2.
Arrays and records Programming Language Design and Implementation
Arrays and records Programming Language Design and Implementation
Arrays and records Programming Language Design and Implementation
Arrays and records Programming Language Design and Implementation
Presentation transcript:

INTRODUCTION OF ARRAY

Topics To Be Discussed………………………. Introduction Types of array One Dimensional Array Internal representation of one-dimensional array Example 1 Example 2

Array An array is a fine, ordered set of homogeneous elements. By homogeneous we mean that all the elements of the set of same type. By ordered set, we mean that all the element of the set has unique position and can be accesses by referring to its position within the set. So basic properties of array are: 1. Homogeneity of its elements 2. Ordering imposed on elements 3. Finite number of elements.

An array is a set of elements of the same data type represented by a single name. Each individual array element can be referred to by specifying the array name followed by a index or subscript enclosed in brackets. For example marks is A name of array containing n elements, then the individual array element will be Marks[1],marks[2],……………m, MARKS[N]

Types of Arrays There are two type of arrays : Linear Array or One-Dimensional Array : An array in which each elements can be referred by one subscript of index is known as one-dimensional array or linear arrays. One Dimensional arrays are also known as vectors Multi Dimensional Array: An array in which each element can be referenced by more than one subscripts is known as multi-dimensional array. In two dimensional array, each element of the array can be referenced by two subscripts

One Dimensional Array One Dimensional array is a linear data structure in which the position of an element within array can be given by just one index or subscript. For example, if we have 5 students with roll no 1,2,3,4,5 and their marks are 70,80,90,85,75 then with one dimensional array named MARKS is shown in following figure:

INDEX CONTENTS LB UB 5 In this example, the individual elements are identified by MARKS[1],MARKS[2],……… MARKS[5]. The index or the subscript, which identifies the position has values from 1 to

Lower Bound(LB) Lower bound is the smallest number that an index can have. In this example LB = 1. Upper Bound(UB) Upper bound is the smallest number that an index can have. In this example UB = 5. Length and Size of the Array Length of the array can be obtained by the following formula : Length = UB – LB + 1

In this example Index Set The set of all possible values of index is known as Index Set. Index Set is denoted by I. in this example: I={1,2,3,4,5} Value Set All array elements have some values. The set of values of array elements is known as value set and is denoted by T. In this example T = {70,80,90,85,75} Length = 5 – 1 +1 = 6

Example Consider an array A[105 : 112]. Find the number of elements in this array. Length = UB – LB + 1 = 112 – = 8

Internal Representation of One-Dimensional array With in computer’s memory array are represent using sequential representation. Address of first element is known as base address and address of other element can be obtained by adding world length to base address. Lo A [1] Lo + C A [2] Lo + 2C A [3] Lo + (I-1)C A [ I ]

Since the elements of an array are stored in successive memory locations, the address of Kth element of an array can be obtained if we know : 1. Address of the first element of the array. The address of the first element of the array is known as base address denoted by Lo 2. Number of memory locations required to store one element denoted by C Formula to calculate the address of the Kth element is : Lo + (K - 1)*C If Lower Bound = 1 Lo + (K - LB)*C If lower Bound ≠1

EXAMPLE - 1 Consider A linear array A[16:30]. If Base = 100 and world length = 4 then calculate the address of A[27]. Solution : A [27] = Lo+(K-LB)*C = )*4 = 144

EXAMPLE - 2 Assume that a linear array with LB=1. if address of A{25]=375 and address of A[30]=390, then find the address of A[16]. Solution: Formula for the address of Kth element is A[K] = Lo+(K-LB)*W Given A[25] = Lo+(25-1)*C=375 Lo+24C = 375 A[30] = Lo+(30-1)*C=290 Lo+29C = C= -15 C= 3

Lo+24C =375 Lo+24*3=375 Lo+72=375 Lo= Lo=303 A[16] = ? A[16] = Lo+(K-LB)*W = 303+(16-1)*3 = = 348

THANKS