• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 5 páginas
Resumen

Summary arrays

Document preview thumbnail
Vista previa 2 fuera de 5 páginas

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.

Vista previa del contenido

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.

Información del documento

Subido en
27 de mayo de 2023
Número de páginas
5
Escrito en
2022/2023
Tipo
Resumen
$13.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
0
Seguidores
0
Artículos
14
Última venta
-



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes