Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

Concept of Abstruct Data Type

Beoordeling
-
Verkocht
-
Pagina's
3
Geüpload op
19-03-2023
Geschreven in
2022/2023

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. 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. If I write C boilerplate here, this C thing comes automatically. If you do n't know where to get this code or If you don't know how to use it, Then you can refer to this video. The lesser the programme uses memory, The more optimised it 's assumed to be. For example, if Google is taking up too Chrome much RAM You 'd wish for it to take up less RAM. But keeping in mind the users ' experience , The team of Google Chrome must have taken some decisions To make. A custom My Array abstract ADT uses a pointer that points toward the total size, the used size and the first element. Assume that I want to store the marks scored by some kids. My array can not go beyond this Because the compiler has reserved the remaining memory for someone else. If your seat number is 0,1,2,3,4 or 5; you 've made your reservation on these seats in the train When the train runs and the chart is made , But then you say that you want seat number 6 ; Then you ca n't get it. This is how I felt it should be implemented. I 'm defining a few methods in this. There can be another implementation as well. I have written the function inside this Now I can use it. And once I get the structure instance , Then I can add a dot and access its total size or anything. and. . . = t size I 'll want that this t-size is passed And along with that , I 'd want that used size should also be passed. And what I also want is that I should set this pointer on my own. We 've even set that we have to use 20 blocks only. We 'll see if we ever want to use the 21st, we 'll add it if we need it, using the Insert operation. But for now, we must use only 20 blocks. So what will the createArray function do ? It will create this array. We put a star when we want the value of the address and call the ampersand the address of the operator. If you want the structure , you 'll have to put the address from the structure. And if you want to use 20 and want to make it 100. So what will it do ? This structure that you have passed by address i. e this is where you 've given the structure address , It will dereference that with a star. So I sent its address ; I said take the structure at this address. It replied , okay. I 'm only displaying all the elements being used of that array. So for that I 'll have to call for the createArray function. This will do what ? It will call on as much memory as I request in the heap. And it will update its pointer in this itself. That 's why this function is n't returning anything. It 's in my Python course but it 's very useful. So here instead of 'printf ' I 'll write 'scanf '. And here I will write scanf % d & n & n.

Meer zien Lees minder
Instelling
Vak








Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
19 maart 2023
Aantal pagina's
3
Geschreven in
2022/2023
Type
College aantekeningen
Docent(en)
Nil
Bevat
Alle colleges

Onderwerpen

$10.49
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
abhisekpaul20020

Maak kennis met de verkoper

Seller avatar
abhisekpaul20020 Haldia Institute of Technology
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
3 jaar
Aantal volgers
0
Documenten
10
Laatst verkocht
-

0.0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen