Bài giảng Nhập môn lập trình: Contiguous Storage cung cấp nội dung chính như: Introduction to contiguous storage, arrays, one-dimensional Arrays, declaration, memory Allocation, initialization accessing elements, traversing, arrays are parameters of functions, searching, sorting,. | NHẬP MÔN LẬP TRÌNH Contiguous Storage Arrays, Simple Data Structure Contiguous Storage Searching Sorting NHẬP MÔN LẬP TRÌNH Objectives • How to manage a group of data? – Store – Input – Output – Search – Sort – Contiguous Storage 2 NHẬP MÔN LẬP TRÌNH Content • Introduction to contiguous storage • Arrays • One-dimensional Arrays – – – – – – – – Declaration Memory Allocation Initialization Accessing elements Traversing 1-D Arrays are parameters of functions Searching Sorting • 2-D Arrays Contiguous Storage 3 NHẬP MÔN LẬP TRÌNH 1- Contiguous Storage • Commonly, a group of the same meaning elements are considered. • They are stored in a contiguous block of memory. • Ex: Group of 10 int numbers 40 bytes block is needed. • Data are considered can be a group of some items which belong to some different data types Contiguous memory block is partitioned into some parts which have different size, one part for an item. • Data structure: A structure of data stored. • Array is the simplest data structure which contains some items which belong to the same data type. • Common used operations on a group: Add, Search, Remove, Update, Sort Contiguous Storage 4 NHẬP MÔN LẬP TRÌNH 2- Arrays Array: A group of elements which belong to the same data type. Each element is identified by it’s position (index). index a (array) 0 5 1 4 2 8 3 15 4 90 a[3] element 5 27 6 34 7 21 8 152 9 80 a[i] is an integer column m m[1][3] row • Dimension: Direction that is used to perform an action on array. • Number of dimensions: Number of indexes are used to specify an element. • Common arrays: 1-D and 2-D arrays. • Name of an array: An array has it’s name. Contiguous .