The document discusses arrays as a data structure. It defines an array, how arrays are stored in memory, different types of array indexing, how arrays are initialized, types of arrays, and advantages and disadvantages of using arrays.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
25 views10 pages
Soumyadeep Maiti - BCAC - 302
The document discusses arrays as a data structure. It defines an array, how arrays are stored in memory, different types of array indexing, how arrays are initialized, types of arrays, and advantages and disadvantages of using arrays.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10
ARRAY
Data Structure.. SUBJECT NAME : Data Structure
SUBJECT CODE :BCAC_302
STUDENT NAME : Soumyadeep Maiti
UNIV ROLL NO :22601221043
UNIV REG NO : 212261001210060
DEPARTMENT : B. C.A
SEMESTER :Third Sem
What is an array?
• A linear arrangement of data of the same types
of element. • An array has to be declared first with the maximum number of elements it can store • int marks[100]; • char name[20]; How is an array stored?
• Starting from a given memory location, the successive array
elements are allocated space in consecutive memory locations.
• x: starting address of the array in memory
• k: number of bytes allocated per array element • a[i] ➔ is allocated memory location at address x + i*k Types of indexing in an array: •0 (zero-based indexing): The first element of the array is indexed by a subscript of 0. •1 (one-based indexing): The first element of the array is indexed by the subscript of 1. •n (N-based indexing): The base index of an array can be freely chosen. Usually, programming languages allowing n-based indexing also allow negative index values, and other scalar data types like enumerations, or characters may be used as an array index. How an Array is initialized?
By default the array is uninitialized, and no
elements of the array are set to any value. However, for the proper working of the array, array initialization becomes important. Array initialization can be done by the following methods: Types of arrays : •One-dimensional Array
•Two-dimensional Array
•Multidimensional Array Use:
• An array element can be used wherever a
simple variable of the same type can be used. • Examples : scanf (“%d”, &marks[i]); marks[i] = (int) (sqrt(21.089)); Advantages of using arrays: •Arrays allow random access to elements. This makes accessing elements by position faster. •Arrays have better cache locality which makes a pretty big difference in performance. • Arrays represent multiple data items of the same type using a single name.
Disadvantages of using arrays:
You can’t change the size i.e. once you have declared the array you can’t change its size because of static memory allocation. Here Insertion(s) and deletion(s) are difficult as the elements are stored in consecutive memory locations and the shifting operation is costly too. Now if take an example of the implementation of data structure Stack using array there are some obvious flaws. Conclusion o This provides the basic knowledge on MATLAB. o In the MATLAB window by typing help all the commands can be found out. o In the MATLAB window go to help toolbox. o In that go to bioinformatics toolbox to perform jobs like ▪ Blast ▪ Sequence alignment ▪ Phylogenetic Analysis ▪ Micro array analysis
The Academic Performance of Grade 10 Mathematics Learners Exposed To Hybrid Learning and Printed Modular Distance Learning in San Andres District, Schools Division of Quezon