Array as An Abstract Data Type in Data Structures
ByAnonymous–
Abstract Data Type is a new data type upon which we have defined our set of operations and
values. We can directly link it with object-ended programming. So what have I done ? I 've made
a OneNote Notebook. And here, by the name of 'Algorithms. 1' An integer is not an abstract data
type, it is a primitive data type. Like an integer, I can also make my own data type , Assume that I
want to make a data type called 'my array' The C language is a special type of array. It must have
a total size. total_size. And after that, it must have an address , Base address. Base address is
the pointer. This My Array ADT that's being made The representation of the set of values This is
it. I 'll do it like this. And I'll write here + , meaning the set. of operations. Here I can define some
operations. What can those operations be ? Those operations can be anything. It 's my choice ;
whatever I choose to keep. So we can define a lot of these types of operations And we can make
our custom data types. So I have made a My Array abstract data type.
This is Stack And this is Heap. Stack is the static memory; Heap is the dynamic memory. If I
want to make an array, I can either I make the array in the stack Like if this is the stack of the
main function , okay. This is the heap of my main function. I 'll write Main here. Or I make an
integer pointer here. I request some memory , And make its previous address point , And here
with my array , I can request Its indices will be 0,1,2,3,4. . . Okay ? In this manner, I can add some
values to it 7,8,12,27,88. . . It 's my choice ; whatever I choose to put. So in this way I can make
this array. If we have to make an array of size 'n ' , So n multiplied by ; meaning star Then the size
of operator , and after that, int. In which we will define the total size , the use size , use size, the
base address and after that , We will define some of our operations on it. Figure out once you
see it When I give you the notebook. And here I 'll write ; this is the 'representation ' And after
that, we 'll have 'operations ' So this is operations. Operations.
An array is contiguous blocks of memory, i. e the capacity to store 6 elements. The base
address will be the address of that first element , That the array is pointing towards So this is a
pointer that will store its address Whatever is my first element, the one with 0th index. The
advantage I 'll get is If I ever want to make insertions in this array Then I can move them a little ,
all the elements. But if I define the array as big as I can I might have to make another completely
new array. And I think moving things a bit is better. We can implement this in any programming
language. The capacity of arrays is. . . In that , the updation and access are very fast. So in
arrays , the biggest advantage is this : It is the fact that you can access the element ; You can
calculate from the base address. Assume there is a field in which Starting from 1, at every
kilometre , at every milestone there is. . . a milestone 3. . . 4. . . 5. . . Okay ? Assume this is from
Delhi. . . This is our Delhi and assume there 's a route from here And from here, how many
kilometres away from here. We 'll set up our coding environment And we 'll implement My Array
on a structure.
ByAnonymous–
Abstract Data Type is a new data type upon which we have defined our set of operations and
values. We can directly link it with object-ended programming. So what have I done ? I 've made
a OneNote Notebook. And here, by the name of 'Algorithms. 1' An integer is not an abstract data
type, it is a primitive data type. Like an integer, I can also make my own data type , Assume that I
want to make a data type called 'my array' The C language is a special type of array. It must have
a total size. total_size. And after that, it must have an address , Base address. Base address is
the pointer. This My Array ADT that's being made The representation of the set of values This is
it. I 'll do it like this. And I'll write here + , meaning the set. of operations. Here I can define some
operations. What can those operations be ? Those operations can be anything. It 's my choice ;
whatever I choose to keep. So we can define a lot of these types of operations And we can make
our custom data types. So I have made a My Array abstract data type.
This is Stack And this is Heap. Stack is the static memory; Heap is the dynamic memory. If I
want to make an array, I can either I make the array in the stack Like if this is the stack of the
main function , okay. This is the heap of my main function. I 'll write Main here. Or I make an
integer pointer here. I request some memory , And make its previous address point , And here
with my array , I can request Its indices will be 0,1,2,3,4. . . Okay ? In this manner, I can add some
values to it 7,8,12,27,88. . . It 's my choice ; whatever I choose to put. So in this way I can make
this array. If we have to make an array of size 'n ' , So n multiplied by ; meaning star Then the size
of operator , and after that, int. In which we will define the total size , the use size , use size, the
base address and after that , We will define some of our operations on it. Figure out once you
see it When I give you the notebook. And here I 'll write ; this is the 'representation ' And after
that, we 'll have 'operations ' So this is operations. Operations.
An array is contiguous blocks of memory, i. e the capacity to store 6 elements. The base
address will be the address of that first element , That the array is pointing towards So this is a
pointer that will store its address Whatever is my first element, the one with 0th index. The
advantage I 'll get is If I ever want to make insertions in this array Then I can move them a little ,
all the elements. But if I define the array as big as I can I might have to make another completely
new array. And I think moving things a bit is better. We can implement this in any programming
language. The capacity of arrays is. . . In that , the updation and access are very fast. So in
arrays , the biggest advantage is this : It is the fact that you can access the element ; You can
calculate from the base address. Assume there is a field in which Starting from 1, at every
kilometre , at every milestone there is. . . a milestone 3. . . 4. . . 5. . . Okay ? Assume this is from
Delhi. . . This is our Delhi and assume there 's a route from here And from here, how many
kilometres away from here. We 'll set up our coding environment And we 'll implement My Array
on a structure.