Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary arrays

Rating
-
Sold
-
Pages
5
Uploaded on
27-05-2023
Written in
2022/2023

In these comprehensive notes on data structures in C, you will gain a deep understanding of the fundamental concepts and practical implementation techniques. Whether you're a beginner or an experienced programmer, these notes will equip you with the knowledge and skills to design and manipulate data structures effectively. Explore topics such as arrays, linked lists, stacks, queues, trees, graphs, and more, as you discover how to optimize memory usage and enhance program efficiency. With clear explanations, examples, and code snippets, these notes will empower you to build efficient solutions and elevate your proficiency in data structure manipulation using the C programming language.

Show more Read less
Institution
Course

Content preview

ARRAY
An array is like a row of boxes, each holding a different item.
Each box has a number, starting from 0, to identify its position.
You can quickly find and change the items by using their box
numbers.


Arrays are helpful when you want to keep things organized. For
example, you can use an array to store a list of numbers or
names. It's a simple way to store and access data in a structured
manner. However, remember that arrays have a fixed size, so you
need to know the maximum number of items in advance, and you
can't easily change the size later on.

LINEAR ARRAY MEMORY REPRESENTATION

. In a linear array memory representation, the elements of the
array are stored one after another in a straight line in the
computer's memory.


For example, let's consider an array [10, 20, 30]. Each element
occupies a fixed amount of memory space (let's say 4 bytes).


The memory representation would look like this:


Memory Address | Value
--------------------------------
1000 | 10
1004 | 20
1008 | 30


In this representation, the first element (10) is stored at memory
address 1000, the second element (20) is at address 1004 (4
bytes higher), and the third element (30) is at address 1008
(another 4 bytes higher).

, By using the index of an element, you can calculate its memory
address using the formula:


Memory Address = Starting Address + (Index * Size of Each
Element)


For instance, to find the second element (20), we would calculate:


Memory Address = 1000 + (1 * 4) = 1004


So, the value 20 is stored at memory address 1004.


This linear array memory representation enables us to quickly
access any element by computing its memory address based on
its index.
Syntax
DataType arrayName[arraySize];
DataType: The data type of the elements in the array (e.g., int,
float, char).
arrayName: The name given to the array.
arraySize: The number of elements that the array can hold.

INSERTION AND DELETION OPERATION

Insertion and deletion are common operations performed on
arrays. Here's a simple explanation of these operations:


Insertion:
1. To insert an element at a specific position in an array, we need
to shift the existing elements to make room for the new element.
2. If we want to insert an element at the beginning of the array,
we shift all the existing elements one position to the right.

Written for

Course

Document information

Uploaded on
May 27, 2023
Number of pages
5
Written in
2022/2023
Type
SUMMARY

Subjects

$13.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
anjithaav

Get to know the seller

Seller avatar
anjithaav university institute of technology
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
14
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions