Managing Collections of Data

Slides:



Advertisements
Similar presentations
Arrays.
Advertisements

1 Arrays  Arrays are objects that help us organize large amounts of information  Chapter 8 focuses on: array declaration and use passing arrays and array.
Chapter 9 Introduction to Arrays
Chapter 9: Advanced Array Concepts
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
Arrays Part 9 dbg. Arrays An array is a fixed number of contiguous memory locations, all containing data of the same type, identified by one variable.
Review of ICS 102. Lecture Objectives To review the major topics covered in ICS 102 course Refresh the memory and get ready for the new adventure of ICS.
1 Mr. Muhammad Hanif Lecturer Information Technology MBBS Campus Dadu University of SIndh.
Computer Programming TCP1224 Chapter 11 Arrays. Objectives Using Arrays Declare and initialize a one-dimensional array Manipulate a one-dimensional array.
IN THE NAME OF ALLAH WHO IS THE MOST BENEFICENT AND MOST MERCIFUL.
CSCI 3328 Object Oriented Programming in C# Chapter 7: Arrays 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
1 9/22/05CS360 Windows Programming Arrays, Collections, Hash Tables, Strings.
Arrays Dr. Jose Annunziato. Arrays Up to this point we have been working with individual primitive data types Arrays allow working with multiple instances.
UniMAP Sem2-10/11 DKT121: Fundamental of Computer Programming1 Arrays.
COMPUTER PROGRAMMING 2 ArrayLists. Objective/Essential Standard Essential Standard 3.00Apply Advanced Properties of Arrays Essential Indicator 3.02 Apply.
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 Multidimensional realities Image courtesy of
Chapter 9 Introduction to Arrays Fundamentals of Java.
1 Why do we need arrays? Problem - Input 5 test scores => int test1,test2,test3,test4,test5 100 test scores? 10,000 employees? A structured data type is.
KUKUM-06/07 EKT120: Computer Programming 1 Week 6 Arrays-Part 1.
C Programming Lecture 15 Two Dimensional Arrays. Two-Dimensional Arrays b The C language allows arrays of any type, including arrays of arrays. With two.
Chapter 5 Arrays F Introducing Arrays F Declaring Array Variables, Creating Arrays, and Initializing Arrays F Passing Arrays to Methods F Copying Arrays.
Chapter VII: Arrays.
Sections 10.1 – 10.4 Introduction to Arrays
Arrays Chapter 7.
Chapter 6: Using Arrays.
Lecture 5 of Computer Science II
Arrays.
Two-Dimensional Arrays
Chapter 7: Working with Arrays
Computer Programming BCT 1113
Array, Strings and Vectors
A simple way to organize data
Motivations Thus far, you have used one-dimensional arrays to model linear collections of elements. You can use a two-dimensional array to represent a.
C# Programming Arrays in C# Declaring Arrays of Different Types Initializing Array Accessing Array Elements Creating User Interfaces Using Windows Standards.
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
Arrays … The Sequel Applications and Extensions
Repeating Instructions And Advance collection
CSCI 3328 Object Oriented Programming in C# Chapter 7: Arrays
Lecture 10 List Richard Gesick.
The ArrayList Class An ArrayList is a complex data structure that allows you to add or remove objects from a list and it changes size automatically. The.
Chapter 8 Arrays Objectives
Chapter 5 Arrays Introducing Arrays
EKT150 : Computer Programming
© A+ Computer Science - Arrays and Lists © A+ Computer Science -
int [] scores = new int [10];
Declaration, assignment & accessing
Introduction To Programming Information Technology , 1’st Semester
Java Arrays & Strings.
Object Oriented Programming in java
Multidimensional Arrays
Cs212: Data Structures Computer Science Department Lecture 2: Arrays.
Chapter 7 Part 2 Edited by JJ Shepherd
MSIS 655 Advanced Business Applications Programming
Arrays.
CSCI 3328 Object Oriented Programming in C# Chapter 7: Arrays
Data Structures (CS212D) Week # 2: Arrays.
Arrays Chapter 7.
int [] scores = new int [10];
Multidimensional array
Arrays Week 2.
Abstract Data Types, Elementary Data Structures and Arrays
Chapter 8 Arrays Objectives
Dr. Sampath Jayarathna Cal Poly Pomona
C++ Array 1.
Arrays Imran Rashid CTO at ManiWeber Technologies.
Programming Fundamental
Arrays and Matrices Prof. Abdul Hameed.
Arrays.
Presentation transcript:

Managing Collections of Data Imran Rashid CTO at ManiWeber Technologies

Outline Simple Array Multidimensional Arrays Generic

Simple Array

datatype[] arrayName; Simple Array An array stores a fixed-size sequential collection of elements of the same type All arrays consist of contiguous memory locations A specific element in an array is accessed by an index The lowest address corresponds to the first element and the highest address to the last element Declaring Arrays datatype[] arrayName; double[] threeHeights;

double[] heights = new double[10]; Simple Array Initializing an Array Declaring an array does not initialize the it in the memory When the array variable is initialized, you can assign values to the array Array is a reference type, so you need to use the new keyword to create an instance of the array double[] heights = new double[10]; string[] colors = new string[7]; int[] ages = new int[3];

Simple Array Assigning Values to an Array double[] balance = new double[10]; balance[0] = 4500.0; double[] balance = { 2340.0, 4523.69, 3421.0 }; int[] marks = new int[5] { 99, 98, 92, 97, 95 }; int[] marks = new int[] { 99, 98, 92, 97, 95 }; int[] marks = new int[] { 99, 98, 92, 97, 95 }; int[] score = marks;

Simple Array Console.WriteLine() Array of Arguemnts Iterating Arrays foreach for Array Behaviors Sum() : int Average() : double Passing Arrays to Functions

Multidimensional Arrays

Multidimensional Arrays Multidimensional arrays are also called rectangular array Multidimensional Arrays Initializing Two-Dimensional Arrays string[ , ] names; int[ , , ] marks; int[ , ] a = new int[3, 4] { {0, 1, 2, 3} , /* initializers for row indexed by 0 */ {4, 5, 6, 7} , /* initializers for row indexed by 1 */ {8, 9, 10, 11} /* initializers for row indexed by 2 */ };

Multidimensional Arrays Example (Declaring) int[ , ] m = new int[3, 4]; Column 01 [0] Column 02 [1] Column 03 [2] Column 04 [3] Row 01 m[0][0] m[0][1] m[0][2] m[0][3] Row 02 m[1][0] m[1][1] m[1][2] m[1][3] Row 03 m[2][0] m[2][1] m[2][2] m[2][3]

Multidimensional Arrays Initializing Arrays (guess the addresses) int[ , ] m = new int[3, 4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; Column 01 [0] Column 02 [1] Column 03 [2] Column 04 [3] Row 01 1 2 3 4 Row 02 5 6 7 8 Row 03 9 10 11 12

Multidimensional Arrays Sections Array 3 X 3 top left, top center, top right middle left, middle center, middle right bottom left, bottom center, bottom right Tic Tac Toe Array 3 X 3 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2 0,0 0,1 0,2 0,0 1,0 2,0 0,1 1,1 2,1 0,2 1,2 2,2 1,0 1,1 1,2 2,0 2,1 2,2

Generic

List<int> intList = new List<int>(); Generic List An array has a fixed number of items as we seen before Once you declared it, can’t change the number of items You can set an item to null but if an array has 3 items it always has 3 items In contrast, the List class let you create resizable array It let you add and remove items as you need to and can accommodate large amount of data This will introduce a new style of programming known as generic data typing List<int> intList = new List<int>(); var intList = new List<int>();

Generic Adding Items Manually Iterating List List Behaviors foreach for List Behaviors Add(T) – at the end AddRange() – collection at the end Remove(T) – remove first occurrence RemoveAt(Index) – remove from a specific index Sort() – sorts all the elements Passing List to Functions

Q1: Difference b/w collection and generics ASSIGNMENT Submission Date 29/10/2018 & in written form Q1: Difference b/w collection and generics Q2: ArrayList with 2 examples Q3: Dictionary with 2 examples Q4: Hashtable with 2 examples

Any ?