Introduction to Data Structures
Arrays
An array is an indexed set of variables, such as
dancer[1], dancer[2], dancer[3],… It is like a set of
boxes that hold things.
A list is a set of items.
An array is a set of
variables that each
store an item.
Arrays and Lists
You can see the difference between arrays and
lists when you delete items.
Arrays and Lists
In a list, the missing spot is filled in when
something is deleted.
Arrays and Lists
In an array, an empty variable is left behind
when something is deleted.
Arrays
Arrays can be created in a similar manner, but
more often they are created using the array
visualization object from the Alice local gallery.
The Array Visualization object
has special properties and
methods for manipulating
the elements in an array.
Arrays
Alice has a set of built-in functions that can be
performed on arrays.
Introducing Arrays
Array is a data structure that represents a collection
of the same types of data.
myList[0]
myList[1]
myList[2]
myList[3]
myList[4]
myList[5]
myList[6]
myList[7]
myList[8]
myList[9]
double[] myList = new double[10];
myList reference
An Array of 10
Elements
of type double
Declaring Array Variables
• datatype[] arrayname;
Example:
double[] myList;
• datatype arrayname[];
Example:
double myList[];
Creating Arrays
arrayName = new datatype[arraySize];
Example:
myList = new double[10];
myList[0] references the first element in the
array.
myList[9] references the last element in the
array.
Declaring and Creating
in One Step
• datatype[] arrayname = new
datatype[arraySize];
double[] myList = new double[10];
• datatype arrayname[] = new
datatype[arraySize];
double myList[] = new double[10];
The Length of Arrays
• Once an array is created, its size is fixed. It
cannot be changed. You can find its size
using
arrayVariable.length
For example,
myList.length returns 10
Initializing Arrays
• Using a loop:
for (int i = 0; i < myList.length; i++)
myList[i] = i;
• Declaring, creating, initializing in one step:
double[] myList = {1.9, 2.9, 3.4, 3.5};
This shorthand syntax must be in one
statement.
Declaring, creating, initializing
Using the Shorthand Notation
double[] myList = {1.9, 2.9, 3.4, 3.5};
This shorthand notation is equivalent to the
following statements:
double[] myList = new double[4];
myList[0] = 1.9;
myList[1] = 2.9;
myList[2] = 3.4;
myList[3] = 3.5;

More Related Content

PPTX
Array
PPT
Javascript - Getting Good with Loop and Array
PPTX
Javascript - Array - Creating Array
PPTX
Binary Heap Tree, Data Structure
PPTX
Types of Arrays
PPT
Heap tree
PPTX
Presentation on Heap Sort
PPTX
Heap Sort in Design and Analysis of algorithms
Array
Javascript - Getting Good with Loop and Array
Javascript - Array - Creating Array
Binary Heap Tree, Data Structure
Types of Arrays
Heap tree
Presentation on Heap Sort
Heap Sort in Design and Analysis of algorithms

What's hot (20)

PPTX
Array in php
PPTX
Javascript - Array - Writing
PPTX
Chap 3php array part1
PPTX
Apex collection patterns
PPTX
Array in-c
PPTX
How to Create an Array & types in PHP
PPTX
Heap Sort Algorithm
PPT
Comp102 lec 8
PDF
Arrays in C++
PPTX
Heap Data Structure
PPTX
PHP array 1
PPTX
Heapsort using Heap
PPTX
Array in c language
PPTX
Mod 12
PPTX
Heap sort
PDF
PHP Basic & Arrays
PDF
4.1 PHP Arrays
PPTX
Array in php
PPT
Heapsort ppt
Array in php
Javascript - Array - Writing
Chap 3php array part1
Apex collection patterns
Array in-c
How to Create an Array & types in PHP
Heap Sort Algorithm
Comp102 lec 8
Arrays in C++
Heap Data Structure
PHP array 1
Heapsort using Heap
Array in c language
Mod 12
Heap sort
PHP Basic & Arrays
4.1 PHP Arrays
Array in php
Heapsort ppt
Ad

Viewers also liked (16)

PPT
PDF
Difference between dtd and xsd
PPTX
Effective business communication
PPTX
TCS Job Interview Questions
PPT
Uml Omg Fundamental Certification 2
PPTX
Difference Between Sql - MySql and Oracle
PDF
The Graph Traversal Programming Pattern
PPT
Stack a Data Structure
PPTX
Relational database management system (rdbms) i
PPT
Introduction of data structure
PPTX
RDBMS.ppt
PPTX
Data Structure
PPT
Lecture 1 data structures and algorithms
PPTX
Rdbms
PPTX
Data Types - Premetive and Non Premetive
PPT
Fundamentals of data structures
Difference between dtd and xsd
Effective business communication
TCS Job Interview Questions
Uml Omg Fundamental Certification 2
Difference Between Sql - MySql and Oracle
The Graph Traversal Programming Pattern
Stack a Data Structure
Relational database management system (rdbms) i
Introduction of data structure
RDBMS.ppt
Data Structure
Lecture 1 data structures and algorithms
Rdbms
Data Types - Premetive and Non Premetive
Fundamentals of data structures
Ad

Similar to Array1 (20)

PPT
Chap09
PPTX
Arrays in Data Structure and Algorithm
PPTX
Chapter 7.1
PDF
Lecture 6 - Arrays
PPT
Arrays Basicfundamentaldatastructure.ppt
PDF
Java Arrays
PPT
Mesics lecture 8 arrays in 'c'
PPT
Array
PPT
arrayy.ppt
PPT
JavaYDL6
PPTX
ch 7 single dimension array in oop .pptx
PPTX
PPT
9781439035665 ppt ch09
DOCX
Class notes(week 4) on arrays and strings
PPTX
Arrays in programming
PPT
Data Structure Midterm Lesson Arrays
PDF
Java chapter 6 - Arrays -syntax and use
PPTX
Array lecture
PPTX
Introduction to Data Structures & Algorithms
PPTX
Arrays in CPP
Chap09
Arrays in Data Structure and Algorithm
Chapter 7.1
Lecture 6 - Arrays
Arrays Basicfundamentaldatastructure.ppt
Java Arrays
Mesics lecture 8 arrays in 'c'
Array
arrayy.ppt
JavaYDL6
ch 7 single dimension array in oop .pptx
9781439035665 ppt ch09
Class notes(week 4) on arrays and strings
Arrays in programming
Data Structure Midterm Lesson Arrays
Java chapter 6 - Arrays -syntax and use
Array lecture
Introduction to Data Structures & Algorithms
Arrays in CPP

More from Rajendran (20)

PPT
Element distinctness lower bounds
PPT
Scheduling with Startup and Holding Costs
PPT
Divide and conquer surfing lower bounds
PPT
Red black tree
PPT
Hash table
PPT
Medians and order statistics
PPT
Proof master theorem
PPT
Recursion tree method
PPT
Recurrence theorem
PPT
Master method
PPT
Master method theorem
PPT
Hash tables
PPT
Lower bound
PPT
Master method theorem
PPT
Greedy algorithms
PPT
Longest common subsequences in Algorithm Analysis
PPT
Dynamic programming in Algorithm Analysis
PPT
Average case Analysis of Quicksort
PPT
Np completeness
PPT
computer languages
Element distinctness lower bounds
Scheduling with Startup and Holding Costs
Divide and conquer surfing lower bounds
Red black tree
Hash table
Medians and order statistics
Proof master theorem
Recursion tree method
Recurrence theorem
Master method
Master method theorem
Hash tables
Lower bound
Master method theorem
Greedy algorithms
Longest common subsequences in Algorithm Analysis
Dynamic programming in Algorithm Analysis
Average case Analysis of Quicksort
Np completeness
computer languages

Recently uploaded (20)

PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PPTX
Core Concepts of Personalized Learning and Virtual Learning Environments
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
Education and Perspectives of Education.pptx
PDF
English Textual Question & Ans (12th Class).pdf
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
advance database management system book.pdf
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
Empowerment Technology for Senior High School Guide
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
HVAC Specification 2024 according to central public works department
PDF
Mucosal Drug Delivery system_NDDS_BPHARMACY__SEM VII_PCI.pdf
PDF
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PPTX
Computer Architecture Input Output Memory.pptx
What if we spent less time fighting change, and more time building what’s rig...
B.Sc. DS Unit 2 Software Engineering.pptx
Core Concepts of Personalized Learning and Virtual Learning Environments
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Education and Perspectives of Education.pptx
English Textual Question & Ans (12th Class).pdf
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
advance database management system book.pdf
Introduction to pro and eukaryotes and differences.pptx
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Empowerment Technology for Senior High School Guide
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
HVAC Specification 2024 according to central public works department
Mucosal Drug Delivery system_NDDS_BPHARMACY__SEM VII_PCI.pdf
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
Environmental Education MCQ BD2EE - Share Source.pdf
Computer Architecture Input Output Memory.pptx

Array1

  • 1. Introduction to Data Structures
  • 2. Arrays An array is an indexed set of variables, such as dancer[1], dancer[2], dancer[3],… It is like a set of boxes that hold things. A list is a set of items. An array is a set of variables that each store an item.
  • 3. Arrays and Lists You can see the difference between arrays and lists when you delete items.
  • 4. Arrays and Lists In a list, the missing spot is filled in when something is deleted.
  • 5. Arrays and Lists In an array, an empty variable is left behind when something is deleted.
  • 6. Arrays Arrays can be created in a similar manner, but more often they are created using the array visualization object from the Alice local gallery. The Array Visualization object has special properties and methods for manipulating the elements in an array.
  • 7. Arrays Alice has a set of built-in functions that can be performed on arrays.
  • 8. Introducing Arrays Array is a data structure that represents a collection of the same types of data. myList[0] myList[1] myList[2] myList[3] myList[4] myList[5] myList[6] myList[7] myList[8] myList[9] double[] myList = new double[10]; myList reference An Array of 10 Elements of type double
  • 9. Declaring Array Variables • datatype[] arrayname; Example: double[] myList; • datatype arrayname[]; Example: double myList[];
  • 10. Creating Arrays arrayName = new datatype[arraySize]; Example: myList = new double[10]; myList[0] references the first element in the array. myList[9] references the last element in the array.
  • 11. Declaring and Creating in One Step • datatype[] arrayname = new datatype[arraySize]; double[] myList = new double[10]; • datatype arrayname[] = new datatype[arraySize]; double myList[] = new double[10];
  • 12. The Length of Arrays • Once an array is created, its size is fixed. It cannot be changed. You can find its size using arrayVariable.length For example, myList.length returns 10
  • 13. Initializing Arrays • Using a loop: for (int i = 0; i < myList.length; i++) myList[i] = i; • Declaring, creating, initializing in one step: double[] myList = {1.9, 2.9, 3.4, 3.5}; This shorthand syntax must be in one statement.
  • 14. Declaring, creating, initializing Using the Shorthand Notation double[] myList = {1.9, 2.9, 3.4, 3.5}; This shorthand notation is equivalent to the following statements: double[] myList = new double[4]; myList[0] = 1.9; myList[1] = 2.9; myList[2] = 3.4; myList[3] = 3.5;

Editor's Notes

  • #3: The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
  • #4: The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
  • #5: The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
  • #6: The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
  • #7: The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.
  • #8: The Redo button will reverse the last use of the Undo button, restoring the previous action. The Ctrl-Y keyboard shortcut also can be used in place of the Redo button.