100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Class notes 22ee303 (Cs101) $7.99   Add to cart

Class notes

Class notes 22ee303 (Cs101)

 0 view  0 purchase
  • Course
  • Institution

it gives a brilliant introduction to the usage and needs of arrays that are important for storing, manipulating and gaining knowledge about data manipulation and accessing the data structures. Happy learning! continuous notes are uploaded on the regular basis

Preview 1 out of 2  pages

  • October 9, 2024
  • 2
  • 2024/2025
  • Class notes
  • Jenny
  • All classes
avatar-seller
Arrays and Memory Representation
Arrays form the core data structure in computer science. Their role is to help store and
manipulate large numbers of data values. This chapter explains how arrays are stored in
memory and how this understanding can be used to improve the performance of our
programs.

Memory Representation
The first step toward comprehension of how arrays are stored in memory is to understand
the basic operations of memory itself. Memory consists of a vast array of bytes, each
uniquely addressed. When any variable is declared, the operating system reserves a given
block of memory for the variable and maintains the address of the location in a register.
For instance, let us take the declaration of the integer variable x and its initial assignment as
5.
int x = 5;
This could store the address of 0x1000 in variable x but keep value 5 at that particular
address.

Arrays
An array is defined to be a set of variables that have the same data type, aligned in memory
and located in contiguous memory addresses. Thereby, when a programmer declares an
array of integers using the syntax int arr[10], the operating system assigns a sufficient
segment of memory for ten integers so that each integer will occupy successive memory
locations.
For instance, say an integer array is declared: int arr[10] = {1, 2, 3, 4, 5}. The OS might assign
the address 0x2000 to store the address of arr and write the corresponding values in the
following way:
Number | Value | \n--- | --- | \n0x2000 | 1 | \n0x2001 | 2 | \n0x2002 | 3 | \n0x2003 | 4
| \n0x2004 | 5 |
The elements of an array may be referenced using indices, which are integers, starting at
zero, increasing by one for every successive element. So the first element of an array is
accessed by arr[0], the second by arr[1], and so on.
Accessing Arrays Accessing elements from an array is one of the most common operations in
programming, yet also one of the slowest if not done very carefully, as access to elements
involves reading from and writing to physical locations within the memory that is used by a
computer.
In other words, there is an alternative method of improving the access efficiency of the array
called blocking, that is, partitioning of an array into blocks or segments and then accessing
these segments sequentially. This ensures less number of memory accesses.

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller shabanas. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $7.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

78861 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$7.99
  • (0)
  Add to cart