Array

Array

What is an Array?

An array is a collection of similar data elements stored at contiguous memory locations. It is the simplest data structure where each data element can be accessed directly by only using its index number.

For instance, if we want to store the marks scored by a student in 5 subjects, then there’s no need to define individual variables for each subject. Rather, we can define an array that will store the data elements at contiguous memory locations.

Array marks[5] define the marks scored by a student in 5 different subjects where each subject’s marks are located at a particular location in the array, i.e., marks[0] denote the marks scored in the first subject,?marks[1]?denotes the marks scored in 2nd subject and so on.

Need of using Array –

In programming, most of the cases need to store a large amount of data of a similar type. We need to define numerous variables to store such a huge amount of data. While writing the programs, it would be very tough to memorize all variable names. Instead, it is better to define an array and store all the elements in it.

Advantages of Array

  • ?Arrays represent multiple data elements of the same type using a single name.
  • Accessing or searching an element in an array is easy by using the index number.
  • ?An array can be traversed easily just by incrementing the index by 1.
  • Arrays allocate memory in contiguous memory locations for all its data elements.

Accessing Elements in an Array –?

To access any element of an array, we need the following details:

  1. Base Address of array.
  2. Size of an element in bytes.
  3. Which type of indexing array follows.

The address of any element of a 1D array can be calculated by using the below-given formula:

Byte address of an element A[i] = base address + size * (i – first index)

要查看或添加评论,请登录

NISHI KUMARI的更多文章

  • What is NULL ?

    What is NULL ?

    In Structured Query Language Null Or NULL is a special type of marker which is used to tell us about that a data value…

  • Delta Format

    Delta Format

    The Delta format is a storage format used in data lakes, particularly in the context of Azure Data Factory and Azure…

  • Amazon SageMaker

    Amazon SageMaker

    Amazon SageMaker is a fully managed machine learning (ML) service provided by Amazon Web Services (AWS). It enables…

  • What is SharePoint?

    What is SharePoint?

    SharePoint is a web-based collaborative platform developed by Microsoft, launched in 2001. It is primarily used for web…

  • What is Data Pipeline?

    What is Data Pipeline?

    A data pipeline is a series of processes and tools designed to collect, process, and deliver data from various sources…

  • What is Azure Logic Apps?

    What is Azure Logic Apps?

    Azure Logic Apps, from Microsoft Azure, is a cloud-based Platform-as-a-Service (PaaS) that is used to automate tasks…

  • What is Power Automate

    What is Power Automate

    Microsoft Power Automate is a comprehensive cloud-based automation platform designed to streamline and optimize…

  • Campaign Optimization Techniques

    Campaign Optimization Techniques

    Campaign optimization is a crucial aspect of any marketing strategy, whether it be for a small business or a…

  • What is Account Management?

    What is Account Management?

    Account management is a post-sales role that focuses on nurturing client relationships. Account managers have two…

  • What is Product Analytics?

    What is Product Analytics?

    Product analytics is the process of collecting and studying data on how people use your product. It tracks user…

社区洞察

其他会员也浏览了