SlideShare a Scribd company logo
4
Most read
5
Most read
9
Most read
Data Structures and Algorithms -
Arrays
Prof. Neeraj Bhargava
Kapil Chauhan
Department of Computer Science
School of Engineering & Systems Sciences
MDS University, Ajmer
Introduction
 Array is a container which can hold a fix number of items
and these items should be of the same type. Most of the
data structures make use of arrays to implement their
algorithms.
 Following are the important terms to understand the
concept of Array.
 Element − Each item stored in an array is called an
element.
 Index − Each location of an element in an array has a
numerical index, which is used to identify the element.
Array Representation
 Arrays can be declared in various ways in different
languages. For illustration, let's take C array
declaration.
Cont..
 Arrays can be declared in various ways in different
languages. For illustration, let's take C array
declaration.
Properties of the Array
 Each element is of same data type and carries a same
size i.e. int = 4 bytes.
 Elements of the array are stored at contiguous memory
locations where the first element is stored at the
smallest memory location.
Advantages of Array
 Array provides the single name for the group of
variables of the same type therefore, it is easy to
remember the name of all the elements of an array.
 Traversing an array is a very simple process, we just
need to increment the base address of the array in
order to visit each element one by one.
 Any element in the array can be directly accessed by
using the index.
Basic Operations
Following are the basic operations supported by an array.
 Traverse − print all the array elements one by one.
 Insertion − Adds an element at the given index.
 Deletion − Deletes an element at the given index.
 Search − Searches an element using the given index or
by the value.
 Update − Updates an element at the given index.
Program
 #include <windows.h>
 #include <stdio.h>
 #include <stdlib.h>
 #define NUM_EMPLOYEE 10

 int main(int argc, char *argv[]){
 int Salary[NUM_EMPLOYEE], lCount=0,gCount=0,i=0;
 printf("Enter employee salary (Max 10)n ");
 for (i=0; i<NUM_EMPLOYEE; i++){
 printf("nEnter employee salary: %d - ",i+1);
 scanf("%d",&Salary[i]);
 }

 for(i=0; i<NUM_EMPLOYEE; i++){
 if(Salary[i]<3000)
 lCount++;
 else
 gCount++;
 }

 printf("nThere are {%d} employee with salary more than 3000n",gCount);
 printf("There are {%d} employee with salary less than 3000n",lCount);
 printf("Press ENTER to continue...n");
 getchar();
 return 0;
 }
Assignment
 Explain Array in data structure with suitable example
and discuss basic operation.

More Related Content

What's hot (20)

PPTX
Arrays accessing using for loops
sangrampatil81
 
DOCX
Array andfunction
Girmachew Tilahun
 
PPTX
Array in C# 3.5
Gopal Ji Singh
 
PPTX
Arrays in java
Arzath Areeff
 
PPTX
Array vs array list
Ravi Shetye
 
PPT
Array
Hajar
 
PPTX
Array in-c
Samsil Arefin
 
PPTX
2CPP06 - Arrays and Pointers
Michael Heron
 
PDF
An Introduction to Programming in Java: Arrays
Martin Chapman
 
PPTX
12. arrays
M H Buddhika Ariyaratne
 
PPTX
ArrayList in JAVA
SAGARDAVE29
 
PDF
Arrays in Java
Naz Abdalla
 
PDF
Lecture 6 - Arrays
Syed Afaq Shah MACS CP
 
ODP
C++ arrays part1
Subhasis Nayak
 
PDF
Arrays Java
Jose Sumba
 
PPTX
Pointer to array and structure
sangrampatil81
 
PDF
Arrays in java
TharuniDiddekunta
 
PDF
Array and Collections in c#
Umar Farooq
 
PPTX
PPt. on An _Array in C
RohitAgrawal119182
 
PPT
Array in Java
Shehrevar Davierwala
 
Arrays accessing using for loops
sangrampatil81
 
Array andfunction
Girmachew Tilahun
 
Array in C# 3.5
Gopal Ji Singh
 
Arrays in java
Arzath Areeff
 
Array vs array list
Ravi Shetye
 
Array
Hajar
 
Array in-c
Samsil Arefin
 
2CPP06 - Arrays and Pointers
Michael Heron
 
An Introduction to Programming in Java: Arrays
Martin Chapman
 
ArrayList in JAVA
SAGARDAVE29
 
Arrays in Java
Naz Abdalla
 
Lecture 6 - Arrays
Syed Afaq Shah MACS CP
 
C++ arrays part1
Subhasis Nayak
 
Arrays Java
Jose Sumba
 
Pointer to array and structure
sangrampatil81
 
Arrays in java
TharuniDiddekunta
 
Array and Collections in c#
Umar Farooq
 
PPt. on An _Array in C
RohitAgrawal119182
 
Array in Java
Shehrevar Davierwala
 

Similar to Data structures and algorithms arrays (20)

PDF
Unit 2 dsa LINEAR DATA STRUCTURE
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
PDF
1-Intoduction ------------- Array in C++
ab6399671
 
PDF
DS Complete notes for Computer science and Engineering
RAJASEKHARV8
 
PDF
DATA STRUCTURES USING C -ENGGDIGEST
Swapnil Mishra
 
PPTX
DSA - Array.pptx
11STEM2PGROUP1
 
PPTX
Arrays_Data_Structures_Presentation.pptx
IndupriyaN
 
PDF
Data-Structure-using-C-Rajesh-Pandey.pdf
mohanaprakasht
 
PPTX
Arrays in Data
Afzal Badshah
 
PDF
Array (data structure using c++).PPT presentation
minedrugs777
 
PPT
Data Structures: A Foundation for Efficient Programming
MSridhar18
 
PPTX
Understanding of Arrays and its types along with implementation
VISHALYADAV809458
 
PDF
Data structure and algorithm notes
suman khadka
 
PPT
Arrays
SARITHA REDDY
 
PDF
Homework Assignment – Array Technical DocumentWrite a technical .pdf
aroraopticals15
 
PPTX
Data Structure.pptx
Sandhiya96308
 
PPTX
unit 2.pptx
researchgrad82
 
PPTX
Data Structures - Array presentation .pptx
IshanKapoor26
 
PDF
Cunit3.pdf
zeenatparveen24
 
PPTX
Data structure.pptx
SajalFayyaz
 
PDF
CONCEPT OF ARRAY IN DATA STRUCTURES CONCEPT OF ARRAY IN DATA STRUCTURES
MSridhar18
 
1-Intoduction ------------- Array in C++
ab6399671
 
DS Complete notes for Computer science and Engineering
RAJASEKHARV8
 
DATA STRUCTURES USING C -ENGGDIGEST
Swapnil Mishra
 
DSA - Array.pptx
11STEM2PGROUP1
 
Arrays_Data_Structures_Presentation.pptx
IndupriyaN
 
Data-Structure-using-C-Rajesh-Pandey.pdf
mohanaprakasht
 
Arrays in Data
Afzal Badshah
 
Array (data structure using c++).PPT presentation
minedrugs777
 
Data Structures: A Foundation for Efficient Programming
MSridhar18
 
Understanding of Arrays and its types along with implementation
VISHALYADAV809458
 
Data structure and algorithm notes
suman khadka
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
aroraopticals15
 
Data Structure.pptx
Sandhiya96308
 
unit 2.pptx
researchgrad82
 
Data Structures - Array presentation .pptx
IshanKapoor26
 
Cunit3.pdf
zeenatparveen24
 
Data structure.pptx
SajalFayyaz
 
CONCEPT OF ARRAY IN DATA STRUCTURES CONCEPT OF ARRAY IN DATA STRUCTURES
MSridhar18
 
Ad

More from chauhankapil (20)

PPTX
Gray level transformation
chauhankapil
 
PPTX
Elements of visual perception
chauhankapil
 
PPTX
JSP Client Request
chauhankapil
 
PPTX
Jsp server response
chauhankapil
 
PPTX
Markov decision process
chauhankapil
 
PPTX
RNN basics in deep learning
chauhankapil
 
PPTX
Introduction to generative adversarial networks (GANs)
chauhankapil
 
PPTX
Bayesian probabilistic interference
chauhankapil
 
PPTX
Jsp
chauhankapil
 
PPTX
Exception handling in java
chauhankapil
 
PPTX
Knowledge acquistion
chauhankapil
 
PPTX
Knowledge based system
chauhankapil
 
PPTX
Introduction of predicate logics
chauhankapil
 
PPTX
Types of inheritance in java
chauhankapil
 
PPTX
Representation of syntax, semantics and Predicate logics
chauhankapil
 
PPTX
Inheritance in java
chauhankapil
 
PPTX
Propositional logic
chauhankapil
 
PPTX
Constructors in java
chauhankapil
 
PPTX
Methods in java
chauhankapil
 
PPT
Circular linked list
chauhankapil
 
Gray level transformation
chauhankapil
 
Elements of visual perception
chauhankapil
 
JSP Client Request
chauhankapil
 
Jsp server response
chauhankapil
 
Markov decision process
chauhankapil
 
RNN basics in deep learning
chauhankapil
 
Introduction to generative adversarial networks (GANs)
chauhankapil
 
Bayesian probabilistic interference
chauhankapil
 
Exception handling in java
chauhankapil
 
Knowledge acquistion
chauhankapil
 
Knowledge based system
chauhankapil
 
Introduction of predicate logics
chauhankapil
 
Types of inheritance in java
chauhankapil
 
Representation of syntax, semantics and Predicate logics
chauhankapil
 
Inheritance in java
chauhankapil
 
Propositional logic
chauhankapil
 
Constructors in java
chauhankapil
 
Methods in java
chauhankapil
 
Circular linked list
chauhankapil
 
Ad

Recently uploaded (20)

PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
PDF
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
Design Thinking basics for Engineers.pdf
CMR University
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 

Data structures and algorithms arrays

  • 1. Data Structures and Algorithms - Arrays Prof. Neeraj Bhargava Kapil Chauhan Department of Computer Science School of Engineering & Systems Sciences MDS University, Ajmer
  • 2. Introduction  Array is a container which can hold a fix number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms.  Following are the important terms to understand the concept of Array.  Element − Each item stored in an array is called an element.  Index − Each location of an element in an array has a numerical index, which is used to identify the element.
  • 3. Array Representation  Arrays can be declared in various ways in different languages. For illustration, let's take C array declaration.
  • 4. Cont..  Arrays can be declared in various ways in different languages. For illustration, let's take C array declaration.
  • 5. Properties of the Array  Each element is of same data type and carries a same size i.e. int = 4 bytes.  Elements of the array are stored at contiguous memory locations where the first element is stored at the smallest memory location.
  • 6. Advantages of Array  Array provides the single name for the group of variables of the same type therefore, it is easy to remember the name of all the elements of an array.  Traversing an array is a very simple process, we just need to increment the base address of the array in order to visit each element one by one.  Any element in the array can be directly accessed by using the index.
  • 7. Basic Operations Following are the basic operations supported by an array.  Traverse − print all the array elements one by one.  Insertion − Adds an element at the given index.  Deletion − Deletes an element at the given index.  Search − Searches an element using the given index or by the value.  Update − Updates an element at the given index.
  • 8. Program  #include <windows.h>  #include <stdio.h>  #include <stdlib.h>  #define NUM_EMPLOYEE 10   int main(int argc, char *argv[]){  int Salary[NUM_EMPLOYEE], lCount=0,gCount=0,i=0;  printf("Enter employee salary (Max 10)n ");  for (i=0; i<NUM_EMPLOYEE; i++){  printf("nEnter employee salary: %d - ",i+1);  scanf("%d",&Salary[i]);  }   for(i=0; i<NUM_EMPLOYEE; i++){  if(Salary[i]<3000)  lCount++;  else  gCount++;  }   printf("nThere are {%d} employee with salary more than 3000n",gCount);  printf("There are {%d} employee with salary less than 3000n",lCount);  printf("Press ENTER to continue...n");  getchar();  return 0;  }
  • 9. Assignment  Explain Array in data structure with suitable example and discuss basic operation.