TAILIEUCHUNG - Lecture Algorithms and data structures: Chapter 21 - Lists

In this lecture we will continue our study of trees by examining a few special kinds of trees. This topic quickly looks at a generalization of a binary tree, where each node has up to N children: Definition, perfect N-ary trees, complete N-ary trees, implementation using templates. | Review 1 Pseudo Code Basic elements of Pseudo code Basic operations of Pseudo code Flow Chart Symbols used in flow charts Examples List 2 List Data Structure List operations List Implementation Array Linked List The LIST Data Structure The List is among the most generic of data structures. Real life: shopping list, groceries list, list of people to invite to dinner List of presents to get 3 Lists A list is collection of items that are all of the same type (grocery items, integers, names) The items, or elements of the list, are stored in some particular order It is possible to insert new elements into various positions in the list and remove any element of the list 4 Lists List is a set of elements in a linear order. For example, data values a1, a2, a3, a4 can be arranged in a list: (a3, a1, a2, a4) In this list, a3, is the first element, a1 is the second element, and so on The order is important here; this is not just a random collection of elements, it is an ordered collection 5 Lists List is a set of elements in a linear order. For example, data values a1, a2, a3, a4 can be arranged in a list: (a3, a1, a2, a4) In this list, a3, is the first element, a1 is the second element, and so on The order is important here; this is not just a random collection of elements, it is an ordered collection 6 List Operations Useful operations createList(): create a new list (presumably empty) copy(): set one list to be a copy of another clear(); clear a list (remove all elments) insert(X, ?): Insert element X at a particular position in the list remove(?): Remove element at some position in the list get(?): Get element at a given position update(X, ?): replace the element at a given position with X find(X): determine if the element X is in the list length(): return the length of the list. 7 List Operations We need to decide what is meant by “particular position”; we have used “?” for this. There are two possibilities: Use the actual index of element: insert .

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.