100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Class notes

array cs

Rating
-
Sold
-
Pages
2
Uploaded on
27-02-2023
Written in
2022/2023

best notes for comp science topic is array









Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
February 27, 2023
Number of pages
2
Written in
2022/2023
Type
Class notes
Professor(s)
Com
Contains
All classes

Content preview

1.1 Arrays in Data Structure | Declaration, Initialization,
Memory representation

be stored in memory now as you can see theory is stored in 20 bytes memory starting from the
0th byte and ending at the 19th byte. So theory is stored in consecutive bytes in memory. Now If
I want to access any of these elements, I will use the indexing operator, which is the square
bracket []. So I can say here [0] that is the first element of this array. Now if I want to access any
other element. I will use the indexing operator again and this time I will use the plus sign (+). So
I can say here [1] that is the second element of this array and so on until I reach the last element
of this array, which is [19]. So this is how you can access any of these elements of the array
using the indexing operator [] and then using the plus sign (+) see now Another way to initialize
an array at runtime is by using a pointer variable. See now suppose we have a pointer variable
called p that points to an area in memory that contains an array called [UNK] fine now at
runtime. We can say p->elements[0] that is referencing the first element of [UNK] See now
Another way to initialize an array at runtime is by using a const pointer variable. See now
suppose we have a const pointer variable called p that points to an area in memory that
contains an array called [UNK] fine now at runtime. We can say const p->elements[0] that is
referencing the first element of [UNK]. See now Another way to initialize an array at runtime is. a
dynamic pointer variable see now suppose we have a dynamic pointer variable called P that
points to an area in memory that contains an array called [UNK] fine. Now at runtime, we can
say p->elements[0] that is referencing the first element of [UNK], but what if we want to access
more than one element from this array at runtime. What would we do see now suppose we want
to access both [1] and [2] from this array at runtime. We can do this by using the two indexing
operators [] and (+) Like this see now another way to access more than one element from this
array at runtime is by using a compound assignment operator (=). Like this see now suppose we
want to access both [1] and [2] from this array, but we also want to assign them both to another
variable called V right so we. Do like this P = V[1] + V[2] see now one more way to access more
than one element from this array at runtime is THe data for this array is stored in 4 bytes
starting at offset 0. THe base address of this array is 100. THe address of the first element in
this array is 0. THe author suggests that in order to access an array's data, you need to know
CA$12.04
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
tanvipatel

Get to know the seller

Seller avatar
tanvipatel OTTAWA
View profile
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
3 year
Number of followers
0
Documents
4
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions