Array
Array is a collection of similar data elements (homogenous data type). Value of array stored in consecutive memory locations and are referenced by an index. Index starts from zero (0) and ends with index-1.
- One Dimensional Array
Syntax: type var[index];
Declaration: int a[10];
Accessing:
a[0] = 8;
a[1] = 10;
a[2] = 6;
a[3] = 2;
- Two Dimensional Array
Syntax: type var[index1][index2];
Declaration: int a[10][20];
Accessing:
a[0][12] = 8;
a[1][2] = 10;
a[2][11] = 6;
a[3][8] = 2;
- Multi Dimensional Array
Syntax: type var[index1][index2][index3][...];
Declaration: int a[10][20][12][9];
Accessing:
a[0][12][0][5] = 8;
a[1][11][6][8] = 10;
a[2][14][5][2] = 32;
a[3][2][7][5] = 24;
The maximum dimension of multi dimensional array is nineteen (19).
Operations that can be performed on arrays are: traversal, insertion, searching, deletion, merging, and sorting.
Pointer
Pointer is a
data type whose value refers to another value stored
elsewhere in computer memory using
its address.
The two most important operators used with pointer type are:
The two most important operators used with pointer type are:
• & the address operator
• * the
dereferencing operator
The difference between single pointer and double pointer:
Variable with single pointer points to the value of another variable which address it
stores. Meanwhile, variable with double pointer points to the value of another variable
which address is already being stored in other variables.
Introduction to Data Structure
Array
The lack of using array: memory that needed is much bigger.
Linked lists
The benefit of using linked lists is dynamic allocation. With dynamic allocation, the memory that used will be added as soon as it used.
The difference between queue and stack:
queue: first in, first out.
stack: first in, last out.
The elements that added at one end called the rear and removed on the other end called the front.
Binary trees will be disscussed after the midterm exam.
Introduction to Data Structure
Why we should learn data structure?
Social media holds the important role in these days on the internet. The basic of social media is data.When we use the search engine, such as google, then the ads that shows up are based on what we search, our interest. This happens because our search data were stored using data structure.
Tidak ada komentar:
Posting Komentar