DSA Unit-1 (2nd)
DSA Unit-1 (2nd)
STRUCTURES
UNIT - I
Arrays, Pointers and Strings
CO1: Apply appropriate constructs of Programming language, coding standards
for application development
UNIT I: CONTENT
Introduction to Data Structures:
Introduction and Definition of Data Structure, Classification of Data, Arrays, Various types of
Data Structure, Static and Dynamic Memory Allocation, Function, Recursion. [CO5]
Pointer, Pointer to Structure, various Programs for Array and Pointer. Strings. Introduction to
Strings, Definition, Library Functions of Strings. [CO1]
Arrays, Pointers and Strings: Introduction to Arrays, Definition
An array is a collection of items of the same variable type that are stored at contiguous
memory locations.
It’s one of the most popular and simple data structures and is often used to implement other
data structures.
Store collection of primitive data type.
Each item in an array is indexed starting with 0 .
Each element in an array is accessed through its index.
C arrays are static
Need of Array Data Structures
Need of Array Data Structures
Arrays are a fundamental data structure in computer science. They are used in a wide variety of
applications, including:
• Storing data for processing
• Implementing data structures such as stacks and queues
• Representing data in tables and matrices
• Creating dynamic data structures such as linked lists and trees
Arrays, Pointers and Strings: One Dimensional Array and MultiDimensional Arrays
return 0;
}
Arrays, Pointers and Strings: Pointer, Pointer to Structure
Arrays and Pointers are closely related to each other such that we can use pointers to
perform all the possible operations of the array.
The array name is a constant pointer to the first element of the array and the array
decays to the pointers when passed to the function.
Arrays, Pointers and Strings: various Programs for Array and Pointer
#include <stdio.h>
int main()
{
int arr[5] = { 10, 20, 30, 40, 50 };
int* ptr = &arr[0];
// comparing address of first element and address stored inside array name
printf("Address Stored in Array name: %p\nAddress of "
"1st Array Element: %p\n",
arr, &arr[0]);