Array Data Structure

An array is a collection of similar types of elements arranged in contiguous memory allocation. An array is a compartment that can hold a fixed number of items, all of which must be of the same type. The majority of data structures use arrays to adopt their algorithms. The following are key terms to comprehend the notion of Array.

(i) Element – An element is any item that is stored in an array.

(ii) Index – Each element in an extensive range has an arithmetical index that serves to identify the aspect.

Basic Operations on array

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.

Traverse – This operation is used to iterate over the parts of an array.

C program –

#include <stdio.h>
main() {
   int A[] = {1,3,5,7,8};
   int c = 12, k = 3, n = 7;
   int i = 0, j = n;   
   printf("The original array elements are :\n");
   for(i = 0; i<n; i++) {
      printf("A[%d] = %d \n", i, A[i]);
   }
}

Insertion – The insert operation is used to add one or more attribute values to an array. A feature can be inserted at the end, or even any given indicators of the array depending on the requirement.

C program –

#include <stdio.h>

main() {
   int A[] = {1,3,5,7,8};
   int item = 10, k = 3, n = 7;
   int i = 0, j = n;
   
   printf("The original array elements are :\n");

   for(i = 0; i<n; i++) {
      printf("A[%d] = %d \n", i, A[i]);
   }

   n = n + 1;
	
   while( j >= k) {
A[j+1] = A[j];
      j = j - 1;
   }

A[k] = item;

   printf("The array elements after insertion :\n");

   for(i = 0; i<n; i++) {
      printf("A[%d] = %d \n", i, A[i]);
   }
}

Deletion – It pertains to the removal of respective elements from the array.

#include <stdio.h>

void main() {
   int A[] = {1,9,11,17,18};
   int k = 9, n = 11;
   int i, j;
   
   printf("The original array elements are :\n");
	
   for(i = 0; i<n; i++) {
      printf("A[%d] = %d \n", i, A[i]);
   }
    
   j = k;
	
   while( j < n) {
A[j-1] = A[j];
      j = j + 1;
   }
	
   n = n -1;
   
   printf("The array elements after deletion :\n");
	
   for(i = 0; i<n; i++) {
      printf("A[%d] = %d \n", i, A[i]);
   }
}

Searching – You can search for arrays using either its value or rather its index.

#include <stdio.h>

void main() {
   int A[] = {1,3,5,7,8};
   int item = 5, n = 5;
   int i = 0, j = 0;
   
   printf("The original array elements are :\n");
	
   for(i = 0; i<n; i++) {
      printf("A[%d] = %d \n", i, A[i]);
   }
    
   while( j < n){
      if( A[j] == item ) {
         break;
      }
		
      j = j + 1;
   }
	
   printf("Found element %d at position %d\n", item, j+1);
}

Update – The refresh operation refers to adjusting an existing array element at a given index.

#include <stdio.h>

void main() {
   int A[] = {1,3,5,7,8};
   int k = 3, n = 5, item = 10;
   int i, j;
   
   printf("The original array elements are :\n");
	
   for(i = 0; i<n; i++) {
      printf("A[%d] = %d \n", i, A[i]);
   }
    
   LA[k-1] = item;

   printf("The array elements after updation :\n");
	
   for(i = 0; i<n; i++) {
      printf("A[%d] = %d \n", i, A[i]);
   }
}

0

149 thoughts on “Array Data Structure”

  1. Hi there, I found your website by means of Google whilst searching for
    a comparable matter, your site came up, it appears to be like
    great. I have bookmarked it in my google bookmarks.

    Hello there, just became alert to your weblog via Google, and located
    that it is truly informative. I am gonna watch out for brussels.
    I’ll appreciate should you proceed this in future. A lot of other people will be benefited out of your writing.
    Cheers!

    0
  2. I as well as my friends came following the nice tips from your website then suddenly I got a horrible suspicion I had not expressed respect to the website owner for those tips. My guys are already consequently joyful to read them and now have without a doubt been enjoying these things. I appreciate you for turning out to be simply helpful and for pick out varieties of smart themes most people are really desirous to understand about. Our sincere regret for not saying thanks to sooner.

    0
  3. I have been surfing on-line more than 3 hours as of late,
    yet I never discovered any interesting article like yours.
    It is pretty worth sufficient for me. In my view, if all webmasters and bloggers made excellent content material as you did, the web
    might be much more useful than ever before.

    0
  4. You can definitely see your enthusiasm in the paintings you write. The world hopes for even more passionate writers such as you who are not afraid to mention how they believe. All the time follow your heart. “No man should marry until he has studied anatomy and dissected at least one woman.” by Honore’ de Balzac.

    0
  5. Thanks so much for giving everyone an extremely brilliant possiblity to read in detail from this blog. It is usually very superb and also stuffed with a good time for me personally and my office friends to search your site really three times every week to read through the latest tips you have got. And lastly, I’m also certainly pleased with the good creative ideas you serve. Certain 1 ideas on this page are undeniably the most suitable we have had.

    0
  6. Hey very cool website!! Man .. Excellent .. Amazing .. I’ll bookmark your website and take the feeds also…I am happy to find numerous useful info here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . .

    0
  7. Hey I am so delighted I found your weblog, I really
    found you by error, while I was researching on Askjeeve for something else, Nonetheless I am
    here now and would just like to say kudos for
    a remarkable post and a all round thrilling blog (I also love the theme/design),
    I don’t have time to browse it all at the minute but I have saved it
    and also included your RSS feeds, so when I have time I will
    be back to read a lot more, Please do keep up the excellent jo.

    0
  8. Do you have a spam issue on this website; I also am a blogger, and I was wondering your situation; we have created some nice methods and we are looking to exchange techniques with other folks, be sure to shoot me an e-mail if interested.

    0
  9. I was wondering if you ever thought of changing the page layout of your blog?
    Its very well written; I love what youve got to
    say. But maybe you could a little more in the way of content so people
    could connect with it better. Youve got an awful lot of text for only having 1
    or two pictures. Maybe you could space it out better?

    0
  10. Good day! This is kind of off topic but I need some help from an established blog.
    Is it very hard to set up your own blog?
    I’m not very techincal but I can figure things out pretty fast.
    I’m thinking about making my own but I’m not sure where to start.
    Do you have any points or suggestions? Cheers

    0
  11. I was curious if you ever thought of changing the structure of your site?
    Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could
    connect with it better. Youve got an awful lot of text for only having one or 2 pictures.
    Maybe you could space it out better?

    0
  12. It’s in fact very complicated in this full of activity life to listen news on Television, so I just use internet for that purpose,
    and obtain the hottest information.

    0
  13. It’s a pity you don’t have a donate button! I’d definitely donate to this fantastic blog! I guess for now i’ll settle for book-marking and adding your RSS feed to my Google account. I look forward to fresh updates and will share this blog with my Facebook group. Talk soon!

    0
  14. What i do not realize is in truth how you are not actually a lot more neatly-appreciated than you might be right now. You’re very intelligent. You already know therefore considerably when it comes to this matter, made me for my part imagine it from so many various angles. Its like men and women are not interested unless it is one thing to accomplish with Lady gaga! Your own stuffs outstanding. Always take care of it up!

    0
  15. I have been surfing online more than three hours lately, but I never found any attention-grabbing article like yours. It?¦s beautiful price sufficient for me. Personally, if all webmasters and bloggers made just right content material as you probably did, the internet shall be much more useful than ever before.

    0
  16. I am curious to find out what blog platform you have been utilizing? I’m having some minor security issues with my latest website and I’d like to find something more safeguarded. Do you have any recommendations?

    0
  17. We are a group of volunteers and opening a new scheme in our community. Your web site provided us with valuable info to work on. You have done a formidable job and our whole community will be thankful to you.

    0
  18. Hello this is kind of of off topic but I was wanting to know if blogs use WYSIWYG editors or if
    you have to manually code with HTML. I’m starting a blog soon but have no
    coding know-how so I wanted to get guidance from someone with experience.

    Any help would be enormously appreciated!

    0
  19. Thank you, I’ve just been looking for info approximately this topic for a long time and yours is the greatest I have discovered till now. However, what in regards to the conclusion? Are you sure in regards to the supply?

    0
  20. You can certainly see your expertise in the work you write. The world hopes for more passionate writers like you who aren’t afraid to say how they believe. Always follow your heart. “A simple fact that is hard to learn is that the time to save money is when you have some.” by Joe Moore.

    0
  21. I do love the way you have presented this particular situation plus it really does present us a lot of fodder for thought. However, from what precisely I have observed, I really wish when the actual feed-back pack on that individuals continue to be on point and don’t get started on a tirade associated with some other news du jour. Yet, thank you for this outstanding point and whilst I can not concur with the idea in totality, I respect your point of view.

    0
  22. I and my pals happened to be examining the great strategies located on the website then immediately I got an awful feeling I had not thanked the blog owner for those secrets. All of the ladies are already so joyful to read through all of them and have in actuality been taking advantage of them. Many thanks for getting considerably considerate as well as for selecting certain brilliant resources most people are really needing to discover. My very own honest regret for not expressing appreciation to earlier.

    0
  23. What is ZenCortex? ZenCortex is a cutting-edge dietary supplement meticulously crafted to provide essential nutrients that support and enhance healthy hearing

    0
  24. Thanks on your marvelous posting! I genuinely enjoyed reading it, you can be a great author.I will be sure to bookmark your blog and definitely will come back very soon. I want to encourage you to ultimately continue your great work, have a nice morning!

    0
  25. Great site. Plenty of helpful info here. I?¦m sending it to a few pals ans additionally sharing in delicious. And obviously, thank you for your sweat!

    0
  26. I will right away grab your rss feed as I can’t to find your email subscription link or newsletter service. Do you’ve any? Kindly allow me recognise in order that I could subscribe. Thanks.

    0
  27. Hello! I know this is somewhat off topic but I was wondering which blog platform are you using for this website? I’m getting tired of WordPress because I’ve had issues with hackers and I’m looking at options for another platform. I would be fantastic if you could point me in the direction of a good platform.

    0
  28. Hmm is anyone else having problems with the images on this blog loading? I’m trying to figure out if its a problem on my end or if it’s the blog. Any suggestions would be greatly appreciated.

    0
  29. Nice read, I just passed this onto a friend who was doing a little research on that. And he just bought me lunch since I found it for him smile So let me rephrase that: Thanks for lunch! “No one can wear a mask for very long.” by Seneca.

    0
  30. I together with my guys came looking through the great tips located on your web blog and so quickly came up with a terrible feeling I never expressed respect to the web site owner for those strategies. These boys were definitely certainly very interested to read them and have absolutely been taking pleasure in them. Appreciation for turning out to be considerably thoughtful and then for having certain exceptional resources most people are really desperate to understand about. My very own honest regret for not expressing gratitude to sooner.

    0
  31. Someone essentially help to make seriously posts I would state. This is the very first time I frequented your website page and thus far? I surprised with the research you made to make this particular publish incredible. Excellent job!

    0
  32. What i don’t realize is actually how you’re not really much more well-liked than you might be now. You are very intelligent. You realize thus significantly relating to this subject, produced me personally consider it from a lot of varied angles. Its like women and men aren’t fascinated unless it is one thing to do with Lady gaga! Your own stuffs nice. Always maintain it up!

    0
  33. Hello, you used to write fantastic, but the last few posts have been kinda boring?K I miss your great writings. Past few posts are just a little out of track! come on!

    0
  34. I was just seeking this information for a while. After 6 hours of continuous Googleing, at last I got it in your website. I wonder what is the lack of Google strategy that don’t rank this type of informative sites in top of the list. Usually the top web sites are full of garbage.

    0
  35. Very nice post. I just stumbled upon your weblog and wished to say that I’ve truly enjoyed browsing your blog posts. After all I will be subscribing to your rss feed and I hope you write again very soon!

    0
  36. It is the best time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I wish to suggest you some interesting things or suggestions. Maybe you can write next articles referring to this article. I wish to read more things about it!

    0
  37. Yesterday, while I was at work, my sister stole my iPad and tested to see if it can survive a 30 foot drop, just so she can be a youtube sensation. My apple ipad is now broken and she has 83 views. I know this is totally off topic but I had to share it with someone!

    0
  38. I have been browsing online more than three hours lately, but I never found any attention-grabbing article like yours. It is beautiful price sufficient for me. Personally, if all webmasters and bloggers made good content material as you probably did, the net might be a lot more useful than ever before.

    0
  39. I was curious if you ever considered changing the page layout of your website? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or two pictures. Maybe you could space it out better?

    0
  40. Whats Happening i’m new to this, I stumbled upon this I have discovered It absolutely useful and it has aided me out loads. I’m hoping to give a contribution & help other users like its aided me. Good job.

    0
  41. Have you ever thought about including a little bit more than just your articles? I mean, what you say is fundamental and everything. But imagine if you added some great images or video clips to give your posts more, “pop”! Your content is excellent but with images and video clips, this blog could undeniably be one of the best in its field. Very good blog!

    0
  42. I’d have to examine with you here. Which is not one thing I usually do! I take pleasure in reading a post that may make folks think. Additionally, thanks for permitting me to comment!

    0
  43. орта ғасырдағы араб мәдениеті, ежелгі араб мәдениеті тайота, тойота
    центр прайс лист 18 ғасырдағы қазақ-орыс қатынастары, қазақ орыс қарым қатынастары презентация полезные ископаемые северного казахстана,
    промышленность северного казахстана

    0
  44. үлкен отбасы перевод, родственники на казахском перевод паразитизм деген не, паразит құрттар көбеюі мәнерлеп оқу өлеңдер жинағы, мәнерлеп
    оқу әдістемесі 50 жас туған күнге тілек, 50 жаска
    тилек оз созимен

    0
  45. 1960 жылдары кабель зауыты салынған
    қала, трансформатор зауыты салынған қала махаббат қанатты сөздер,
    махаббат создер жигитке су элементі, су шаруашылығы рифленый лист алматы, лист рифленый 4 мм вес 1 м2

    0
  46. адамды қалай жақсы көруге болады, алла разылығы үшін жақсы
    көру перевод купить золото в
    алматы дешево, купить золото в ломбарде алматы центр перинатологии и детской кардиохирургии адрес
    в алматы, роддом на басенова
    директор ретроградный меркурий 2022: что нельзя делать, ретроградный меркурий 2022: даты

    0
  47. қой жасы, ерте туған қозы біржан сал қожағұлұлы қалдырған мұралары, біржан
    сал қожағұлұлы шығармалары кириллица алфавит перевод, онлайн перевод с кириллицы на латиницу кровать серагем цена алматы, корейские
    массажные кровати в алматы

    0
  48. Attractive section of content. I just stumbled upon your weblog and in accession capital to assert that I get in fact enjoyed account your blog posts. Anyway I’ll be subscribing to your augment and even I achievement you access consistently quickly.

    0
  49. Предлагаем услуги профессиональных инженеров офицальной мастерской.
    Еслли вы искали сервисный центр xiaomi, можете посмотреть на сайте: сервисный центр xiaomi в москве
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

    0

Leave a Comment

Your email address will not be published. Required fields are marked *