Introduction To Data Structures and Algorithms - Lecture 1
Introduction To Data Structures and Algorithms - Lecture 1
1.1 Pointer
A pointer is a variable that stores a memory address. Pointers are used to store the addresses of
other variables or memory items. A pointer with the value 0 or NULL points to nothing and is
known as a null pointer.
int y = 5, *yPtr;
yPtr = &y;
here *yPtr is a pointer variable that stores the memory address of y. here & sign is used to denote
the memory location of y.
Using * in this manner is called dereferencing a pointer. The dereferenced pointer may also be
used to receive an input value as in it.
2
1.3.2 Pass by reference
By passing value means that we are passing the address actual parameters to the function. Any
changes made to the passed values will be applied to the actual variables. It is memory efficient
way of passing value at big level.
3
Figure 1.3 pointers with arrays
4
1.5 Arithmetic operations at Pointers
5
1.5.2 Decrement operator