Lecture Data Structures & Algorithms: Chapter 5

Lecture Data Structures & Algorithms: Chapter 5 Linked Lists presented the Concept Of The Linked List, Single Linked List, Double Linked List, Circular Linked List. | Data Structures & Algorithms 1 Linked Lists Single Linked List Double Linked List Circular Linked List The Concept Of The Linked List The Concept Of The Linked List - The size requirement need not be known at compile time. - A linked list is a data structure that is used to model such a dynamic list of data items, so the study of the linked lists as one of the data structures is important. ARRAY Linked List Sequential mapping, elements are fixed distance apart. Makes insertion or deletion at any arbitrary position in an array a costly operation An element is required to be linked with a previous element of the list. Done by storing the address of the next element Data pNext 5 2 9 7 6 0 8 M[0] M[1] M[3] M[5] M[2] M[4] M[6] Data pNext Data pNext Data pNext 4 things when build Linked List 1. Structure 2. Make linking between elements: - First, Last, Middle element 3. How many node to take all list elements, How to take all list. 4. Basic operations: - Insert new element (every position) - Delete (every position) - Count, Search, Sort, DeAllocated - Data element - Link field element Single Linked List Data pNext Data pNext Data pNext Data pNext NULL 1. Structure struct Node { int data; Node *pNext; }; How to use node? Node node1; ; ; coutdata=20; node2->pNext=NULL; coutdata; delete node2; Compare??? What is the different? Delele and change address data pNext NULL data pNext data pNext data pNext Head Middle Last 2. The way to make link between elements First, last, middle element 3. How many node to take all list elements, how to take all list? data pNext NULL data pNext data pNext data pNext pHead Why? +from pHead, can we list all items? +from pHead, can we do everything with list: insert new, delete? +Do we need pTail? pTail 4. Basic operations: Initialize CreateNode SearchNode SizeOfList SumOfList SortList InsertFirst InsertLast InsertMid RemoveNode . | Data Structures & Algorithms 1 Linked Lists Single Linked List Double Linked List Circular Linked List The Concept Of The Linked List The Concept Of The Linked List - The size requirement need not be known at compile time. - A linked list is a data structure that is used to model such a dynamic list of data items, so the study of the linked lists as one of the data structures is important. ARRAY Linked List Sequential mapping, elements are fixed distance apart. Makes insertion or deletion at any arbitrary position in an array a costly operation An element is required to be linked with a previous element of the list. Done by storing the address of the next element Data pNext 5 2 9 7 6 0 8 M[0] M[1] M[3] M[5] M[2] M[4] M[6] Data pNext Data pNext Data pNext 4 things when build Linked List 1. Structure 2. Make linking between elements: - First, Last, Middle element 3. How many node to take all list elements, How to take all list. 4. Basic operations: - Insert new element (every position)

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.