CodeWithHarry
So I have a friend that wanted to build a PC So he approached me and
asked '' Harry , can you give me a blueprint to build PC ? '' '' So that
with that blueprint I can make someone build PC? '' '' I want to do
gaming and streaming. '' So I gave him this blueprint. I told him all the
main components of a PC. And even if he makes a mistake , It wo n't be a
big deal. We will study array ADT. Array as an Abstract Data Type. Arrays
as an abstract data type. In that , I will give you MRF. Not MRF tyres,
nor the bat one ; I 'll give you minimal. . . minimal Required
functionalities. And some operations , that you can define later on your
own. Let us understand this with the example of an array. Arrays can be
found in a lot of programming languages. Arrays are found in C, C++, Java
and Java. In Python, they are called 'lists' and in Java, they're called
lists. There are some minimal required functionalities in arrays. For
example, Get is done , Set is done. Along with that there can be a resize
functionality.
An array is a collection of elements. Accessible by an index. The memory
layout of the C programme is a code section. Inside the stack, there are
local variations of a function. Inside a function is a stack. Inside an
array is the heap. The kernel is the kernel of the kernels. In most
programming languages, the index of an array starts at 0 It has a reason
; when we start from 0 , We get a certain advantage but I wo n't go
there. But, you can search on the internet There 's a paper by jee-stars.
In that they 've explained what will happen if it starts from 1 or 0. How
calculations will become easy. If you say that you do n't want 38 , you
want a greater one Then you wo n't get it. When you requested a memory
till 38, then it is possible that some other application was given some
memory by the compiler. It will be doing its job with this memory.
Otherwise in the same programme It must have allocated a variable in
correspondence with that memory. So you 're saying that you want to
increase it So you can not make it larger in this array. You can increase
it in the linked list, we 'll talk about that ahead. If you skip the
practice set it 'll be over in 6 hours.
An array can not be resized. Directly I can not resize it , I ca n't
increase it. It wo n't get this block ; no. It can be. resized this way.
Why should we use an array ? Why did we make an array? We made the array
because Because at one point I have these 10 addresses. Get and Set is
very easy in the C language. The programming language gives them to you
by default. But we 'll implement this array ADT with the help of
structure structure. This is our abstract data type. We 'll build it
however we want to. And we'll add many more operations. In my ADT I will
provide the user with the ability to use my Add method. So that he/she
will be able to add lots of arrays directly. That why we use arrays.
Faster retrieval , faster updation. Where does the scam happen in the
array ? At the time of deletion and insertion. If I want to insert an
element , it becomes costly. Because I 'll have to move it. There are
some disadvantages too , but it varies from use case to use case. And you
'll get that by practising. And I will ensure that you get it.
In an abstract data type, abstraction means hiding the implementation
details. And you are being given an assurance ; a provision To carry out
these operations. Array ADT holds a collection of elements It can float ,
it can be int. It can be classes in C++. And it can also be structure in
C language. The array can be accessed and updated in O (1 ) time. Because