TAILIEUCHUNG - Lecture Algorithms and data structures (CSC112) - Chapter 22

In computer science, a balanced trees is a self-balancing tree data structure that keeps data sorted and allows searches, sequential access, insertions, and deletions in logarithmic time. In this topic, we will: Introduce the idea of balance and a few examples. | Review 1 List Data Structure List operations List Implementation Array Linked List Pointer 2 Pointer Pointer Variables Dynamic Memory Allocation Functions What is a Pointer? A Pointer provides a way of accessing a variable without referring to the variable directly. The mechanism used for this purpose is the address of the variable. A variable that stores the address of another variable is called a pointer variable. 3 Pointer Variables Pointer variable: A variable that holds an address Can perform some tasks more easily with an address than by accessing memory via a symbolic name: Accessing unnamed memory locations Array manipulation etc. 4 Why Use Pointers? To operate on data stored in an array To enable convenient access within a function to large blocks data, such as arrays, that are defined outside the function. To allocate space for new variables dynamically–that is during program execution 5 Pointer Data Types and Pointer Variables Pointer variable: variable whose content is a memory address Syntax to declare pointer variable: dataType *identifier; Address of operator: Ampersand, & Dereferencing operator/Indirection operator: Asterisk, * 6 The Address-Of Operator (&) The address-of operator, &, is a unary operator that obtains the address in memory where a variable is stored. int number = 1234; int*pnumber= &number; //stores address of //number in pnumber char a = „a‟; char *pa = &a;//stores address of a in pa. 7 The Indirection Operator How pointer variable is used to access the contents of memory location? The indirection operator, *is used for this purpose. cout<< *pnumber; 8 The Indirection Operator int x= 4; 4 x 1310 px Addresses 1310 1312 1314 1316 cout<<“The number is:”<

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.