SlideShare a Scribd company logo
UNIT 1- LINEAR DATA
STRUCTURES
ARRAY BASED
IMPLEMENTATION
Introduction
• An Array is a collection of memory locations.
• The memory locations cannot be split from
each other, so if there is some empty space, it
just goes waste.
• Arrays cannot be interchanged.
• A array is a collection of variables of same
type.
• Some points to be noted about an array:
1. It is a continuous chunk of memory with equally
sized blocks.
2. The subscript always begins with ‘0’ and goes until
‘n-1’ which is also continuous.
3.Any memory location can be directly accessed using
its subscript.
4. Static arrays have issues, such as memory wastage
and memory leak, and also have constraints over the
size. These are overcome by using dynamic arrays.
5. Since it is a continuous chunk of memory, it has
internal issues such as fragmentation and memory
leaks.
Why do we study Arrays?
• The array structure looks very similar to Python's list
structure.
• But there are two major differences between the array and
the list.
1. array has a limited number of operations whereas Lists
provides a large number of operations for working with the
contents of the list.
2. lists can grow and shrink during execution as elements are
added or removed while the size of an array cannot be
changed after it has been created.
• The array is best suited for problems requiring a sequence
in which the maximum number of elements are known up
front, whereas the list is the better choicewhen the size of
the sequence needs to change after it has been created.
Array Abstract Data Type
• Definition: A one-dimensional array is a
collection of contiguous elements in which
individual elements are identified by a unique
integer subscript starting with zero. Once an
array is created, its size cannot be changed.
• Array( size ): Creates a one-dimensional array consisting of
size elements with each element initially set to None. size
must be greater than zero.
• length (): Returns the length or number of elements in the
array.
• getitem ( index ): Returns the value stored in the array at
element position index. The index argument must be within
the valid range. Accessed using the subscript operator.
• setitem ( index, value ): Modifies the contents of the array
element at position index to contain value. The index must
be within the valid range. Accessed using the subscript
operator.
• clearing( value ): Clears the array by setting every element
to value.
• iterator (): Creates and returns an iterator that can be used
to traverse the elements of the array.
Basic operations of Arrays
Array( size ):
Creates a one-dimensional array consisting of size elements with each
element initially set to None. size must be greater than zero.
length (): Returns the length or number of elements in the array.
getitem ( index )
Returns the value stored in the array at element position index. The
index argument must be within the valid range. Accessed using the
subscript operator.
setitem ( index, value )
Modifies the contents of the array element at position index to contain
value. The index must be within the valid range. Accessed using the
subscript operator.
clearing( value ) Clears the array by setting every element to value.
iterator ()
Creates and returns an iterator that can be used to traverse the elements
of the array.
The ctypes Module
• Many of the data types and classes available in Python are actually
implemented using appropriate types from the C language.
• While Python does not provide the array structure as part of the
language itself, it now includes the ctypes module as part of the
Python Standard Library.
• The ctypes module provides the capability to create hardware-
supported arrays just like the ones used to implement Python's
string, list, tuple, and dictionary collection types.
• But the ctypes module is not meant for everyday use in Python
programs.
• Thus, the technique provided by the module for creating an array
should not typically be used directly within a Python program.
• But we can use it within our Array class to provide the functionality
defined by the Array ADT.
Concept of Arrays
Syntax of Arrays
Creating an Array in Python
• In Python, arrays are different from lists; lists can have array
items of data types, whereas arrays can only have items of the
same data type.
• Python has a separate module for handling arrays called array,
which you need to import before you start working on them.
Ways to create Arrays
• You can declare an array in Python while initializing it using
the following syntax.
• Identifier: specify a name like
usually, you do for variables
• Module: Python has a special
module for creating arrays,
called "array" – you must
import it before using it
• Method: the array module has
a method for initializing the
array. It takes two arguments,
typecode, and elements.
• Type Code: specify the data
type using the typecodes
available.
• Elements: specify the array
elements within the square
brackets, for example
[130,450,103]
Accessing an Array value
Array Operations - Insertion
Array Operations- Deletion
Array Operations - Searching
Array Operations- Update
Array Operations - Traverse

More Related Content

What's hot

Different Sorting tecniques in Data Structure
Different Sorting tecniques in Data StructureDifferent Sorting tecniques in Data Structure
Different Sorting tecniques in Data Structure
Tushar Gonawala
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
Kathirvel Ayyaswamy
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
Ankit Rai
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
Afaq Mansoor Khan
 
Stacks, Queues, Deques
Stacks, Queues, DequesStacks, Queues, Deques
Stacks, Queues, Deques
A-Tech and Software Development
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
sinhacp
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
Dhrumil Panchal
 
Arrays
ArraysArrays
Avl trees
Avl treesAvl trees
Avl trees
Mannan Masood
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
Self-Employed
 
Stack - Operations and Applications
Stack - Operations and ApplicationsStack - Operations and Applications
Stack - Operations and Applications
Sagacious IT Solution
 
Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arora
kulachihansraj
 
SQL Functions
SQL FunctionsSQL Functions
SQL Functions
ammarbrohi
 
Pilas y colas
Pilas y colasPilas y colas
Pilas y colas
Eliezer Cordova
 
Mysql joins
Mysql joinsMysql joins
Java Linked List Tutorial | Edureka
Java Linked List Tutorial |  EdurekaJava Linked List Tutorial |  Edureka
Java Linked List Tutorial | Edureka
Edureka!
 
Linked List
Linked ListLinked List
Linked List
Ashim Lamichhane
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
أحمد محمد
 
Stack and its operations
Stack and its operationsStack and its operations
Stack and its operations
V.V.Vanniaperumal College for Women
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
Raveena Thakur
 

What's hot (20)

Different Sorting tecniques in Data Structure
Different Sorting tecniques in Data StructureDifferent Sorting tecniques in Data Structure
Different Sorting tecniques in Data Structure
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
 
Stacks, Queues, Deques
Stacks, Queues, DequesStacks, Queues, Deques
Stacks, Queues, Deques
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
 
Arrays
ArraysArrays
Arrays
 
Avl trees
Avl treesAvl trees
Avl trees
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
Stack - Operations and Applications
Stack - Operations and ApplicationsStack - Operations and Applications
Stack - Operations and Applications
 
Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arora
 
SQL Functions
SQL FunctionsSQL Functions
SQL Functions
 
Pilas y colas
Pilas y colasPilas y colas
Pilas y colas
 
Mysql joins
Mysql joinsMysql joins
Mysql joins
 
Java Linked List Tutorial | Edureka
Java Linked List Tutorial |  EdurekaJava Linked List Tutorial |  Edureka
Java Linked List Tutorial | Edureka
 
Linked List
Linked ListLinked List
Linked List
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Stack and its operations
Stack and its operationsStack and its operations
Stack and its operations
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 

Similar to Unit 1 array based implementation

Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxQ-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
kalai75
 
DS Module1 (1).pptx
DS Module1 (1).pptxDS Module1 (1).pptx
DS Module1 (1).pptx
AnuJoseph95
 
Collections Training
Collections TrainingCollections Training
Collections Training
Ramindu Deshapriya
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
MamataAnilgod
 
Unit 2 linear data structures
Unit 2   linear data structuresUnit 2   linear data structures
Unit 2 linear data structures
Senthil Murugan
 
Week 11.pptx
Week 11.pptxWeek 11.pptx
Week 11.pptx
CruiseCH
 
Java Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptxJava Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptx
rangariprajwal4554
 
Lesson 11 one dimensional array
Lesson 11 one dimensional arrayLesson 11 one dimensional array
Lesson 11 one dimensional array
MLG College of Learning, Inc
 
java.pdf
java.pdfjava.pdf
java.pdf
RAJCHATTERJEE24
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
Haitham El-Ghareeb
 
linked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate studentslinked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate students
SazzadulIslam42
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
Nikhil Pandit
 
STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
Collections
CollectionsCollections
Collections
Marwa Dosoky
 
Java Unit 2 (Part 2)
Java Unit 2 (Part 2)Java Unit 2 (Part 2)
Java Unit 2 (Part 2)
SURBHI SAROHA
 
MODULE-2.pptx
MODULE-2.pptxMODULE-2.pptx
MODULE-2.pptx
ASRPANDEY
 
Standard template library
Standard template libraryStandard template library
Standard template library
ThamizhselviKrishnam
 
Java util
Java utilJava util
Java util
Srikrishna k
 
Standard template library
Standard template libraryStandard template library
Standard template library
Sukriti Singh
 
ArrayList class and useful methods.pptx
ArrayList class and useful methods.pptxArrayList class and useful methods.pptx
ArrayList class and useful methods.pptx
Abid523408
 

Similar to Unit 1 array based implementation (20)

Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxQ-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
 
DS Module1 (1).pptx
DS Module1 (1).pptxDS Module1 (1).pptx
DS Module1 (1).pptx
 
Collections Training
Collections TrainingCollections Training
Collections Training
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
Unit 2 linear data structures
Unit 2   linear data structuresUnit 2   linear data structures
Unit 2 linear data structures
 
Week 11.pptx
Week 11.pptxWeek 11.pptx
Week 11.pptx
 
Java Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptxJava Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptx
 
Lesson 11 one dimensional array
Lesson 11 one dimensional arrayLesson 11 one dimensional array
Lesson 11 one dimensional array
 
java.pdf
java.pdfjava.pdf
java.pdf
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
linked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate studentslinked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate students
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
 
STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
STRINGS IN JAVA
 
Collections
CollectionsCollections
Collections
 
Java Unit 2 (Part 2)
Java Unit 2 (Part 2)Java Unit 2 (Part 2)
Java Unit 2 (Part 2)
 
MODULE-2.pptx
MODULE-2.pptxMODULE-2.pptx
MODULE-2.pptx
 
Standard template library
Standard template libraryStandard template library
Standard template library
 
Java util
Java utilJava util
Java util
 
Standard template library
Standard template libraryStandard template library
Standard template library
 
ArrayList class and useful methods.pptx
ArrayList class and useful methods.pptxArrayList class and useful methods.pptx
ArrayList class and useful methods.pptx
 

More from LavanyaJ28

Cs1301 syllabus
Cs1301  syllabusCs1301  syllabus
Cs1301 syllabus
LavanyaJ28
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
LavanyaJ28
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using python
LavanyaJ28
 
Searching,sorting
Searching,sortingSearching,sorting
Searching,sorting
LavanyaJ28
 
Hashing
HashingHashing
Hashing
LavanyaJ28
 
Graphs
GraphsGraphs
Graphs
LavanyaJ28
 
Unit 3 trees
Unit 3   treesUnit 3   trees
Unit 3 trees
LavanyaJ28
 
Heap types & Trees
Heap types & TreesHeap types & Trees
Heap types & Trees
LavanyaJ28
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
LavanyaJ28
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
LavanyaJ28
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack
LavanyaJ28
 
Stack and queue
Stack and queueStack and queue
Stack and queue
LavanyaJ28
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked list
LavanyaJ28
 
Unit 1 Basic concepts to DS
Unit 1 Basic concepts to DSUnit 1 Basic concepts to DS
Unit 1 Basic concepts to DS
LavanyaJ28
 
Unit 1 polynomial manipulation
Unit 1   polynomial manipulationUnit 1   polynomial manipulation
Unit 1 polynomial manipulation
LavanyaJ28
 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data types
LavanyaJ28
 

More from LavanyaJ28 (16)

Cs1301 syllabus
Cs1301  syllabusCs1301  syllabus
Cs1301 syllabus
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using python
 
Searching,sorting
Searching,sortingSearching,sorting
Searching,sorting
 
Hashing
HashingHashing
Hashing
 
Graphs
GraphsGraphs
Graphs
 
Unit 3 trees
Unit 3   treesUnit 3   trees
Unit 3 trees
 
Heap types & Trees
Heap types & TreesHeap types & Trees
Heap types & Trees
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked list
 
Unit 1 Basic concepts to DS
Unit 1 Basic concepts to DSUnit 1 Basic concepts to DS
Unit 1 Basic concepts to DS
 
Unit 1 polynomial manipulation
Unit 1   polynomial manipulationUnit 1   polynomial manipulation
Unit 1 polynomial manipulation
 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data types
 

Recently uploaded

Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
Aditya Rajan Patra
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
enizeyimana36
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 

Recently uploaded (20)

Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 

Unit 1 array based implementation

  • 1. UNIT 1- LINEAR DATA STRUCTURES ARRAY BASED IMPLEMENTATION
  • 2. Introduction • An Array is a collection of memory locations. • The memory locations cannot be split from each other, so if there is some empty space, it just goes waste. • Arrays cannot be interchanged. • A array is a collection of variables of same type.
  • 3. • Some points to be noted about an array: 1. It is a continuous chunk of memory with equally sized blocks. 2. The subscript always begins with ‘0’ and goes until ‘n-1’ which is also continuous. 3.Any memory location can be directly accessed using its subscript. 4. Static arrays have issues, such as memory wastage and memory leak, and also have constraints over the size. These are overcome by using dynamic arrays. 5. Since it is a continuous chunk of memory, it has internal issues such as fragmentation and memory leaks.
  • 4. Why do we study Arrays? • The array structure looks very similar to Python's list structure. • But there are two major differences between the array and the list. 1. array has a limited number of operations whereas Lists provides a large number of operations for working with the contents of the list. 2. lists can grow and shrink during execution as elements are added or removed while the size of an array cannot be changed after it has been created. • The array is best suited for problems requiring a sequence in which the maximum number of elements are known up front, whereas the list is the better choicewhen the size of the sequence needs to change after it has been created.
  • 5. Array Abstract Data Type • Definition: A one-dimensional array is a collection of contiguous elements in which individual elements are identified by a unique integer subscript starting with zero. Once an array is created, its size cannot be changed.
  • 6. • Array( size ): Creates a one-dimensional array consisting of size elements with each element initially set to None. size must be greater than zero. • length (): Returns the length or number of elements in the array. • getitem ( index ): Returns the value stored in the array at element position index. The index argument must be within the valid range. Accessed using the subscript operator. • setitem ( index, value ): Modifies the contents of the array element at position index to contain value. The index must be within the valid range. Accessed using the subscript operator. • clearing( value ): Clears the array by setting every element to value. • iterator (): Creates and returns an iterator that can be used to traverse the elements of the array.
  • 7. Basic operations of Arrays Array( size ): Creates a one-dimensional array consisting of size elements with each element initially set to None. size must be greater than zero. length (): Returns the length or number of elements in the array. getitem ( index ) Returns the value stored in the array at element position index. The index argument must be within the valid range. Accessed using the subscript operator. setitem ( index, value ) Modifies the contents of the array element at position index to contain value. The index must be within the valid range. Accessed using the subscript operator. clearing( value ) Clears the array by setting every element to value. iterator () Creates and returns an iterator that can be used to traverse the elements of the array.
  • 8. The ctypes Module • Many of the data types and classes available in Python are actually implemented using appropriate types from the C language. • While Python does not provide the array structure as part of the language itself, it now includes the ctypes module as part of the Python Standard Library. • The ctypes module provides the capability to create hardware- supported arrays just like the ones used to implement Python's string, list, tuple, and dictionary collection types. • But the ctypes module is not meant for everyday use in Python programs. • Thus, the technique provided by the module for creating an array should not typically be used directly within a Python program. • But we can use it within our Array class to provide the functionality defined by the Array ADT.
  • 11. Creating an Array in Python • In Python, arrays are different from lists; lists can have array items of data types, whereas arrays can only have items of the same data type. • Python has a separate module for handling arrays called array, which you need to import before you start working on them.
  • 12. Ways to create Arrays • You can declare an array in Python while initializing it using the following syntax.
  • 13. • Identifier: specify a name like usually, you do for variables • Module: Python has a special module for creating arrays, called "array" – you must import it before using it • Method: the array module has a method for initializing the array. It takes two arguments, typecode, and elements. • Type Code: specify the data type using the typecodes available. • Elements: specify the array elements within the square brackets, for example [130,450,103]
  • 15. Array Operations - Insertion
  • 17. Array Operations - Searching
  • 19. Array Operations - Traverse