Содержание
- 2. Outline We will now look at our first abstract data structure Relation: explicit linear ordering Operations
- 3. Definition An Abstract List (or List ADT) is linearly ordered data where the programmer explicitly defines
- 4. Operations Operations at the kth entry of the list include: Access to the object Erasing an
- 5. Operations Given access to the kth object, gain access to either the previous or next object
- 6. Locations and run times The most obvious data structures for implementing an abstract list are arrays
- 7. Linked lists We will consider these for Singly linked lists Doubly linked lists 3.1.3
- 8. Singly linked list 3.1.3.1 * These assume we have already accessed the kth entry—an O(n) operation
- 9. Singly linked list 3.1.3.1 By replacing the value in the node in question, we can speed
- 10. Doubly linked lists 3.1.3.2 * These assume we have already accessed the kth entry—an O(n) operation
- 11. Doubly linked lists 3.1.3.2 Accessing the kth entry is O(n)
- 12. Other operations on linked lists 3.1.3.3 Other operations on linked lists include: Allocation and deallocating the
- 13. Arrays 3.1.4 We will consider these operations for arrays, including: Standard or one-ended arrays Two-ended arrays
- 14. Standard arrays 3.1.4 We will consider these operations for arrays, including: Standard or one-ended arrays Two-ended
- 15. Run times * Assume we have a pointer to this node
- 16. Data Structures In general, we will only use these basic data structures if we can restrict
- 17. Memory usage versus run times All of these data structures require Θ(n) memory Using a two-ended
- 18. Memory usage versus run times As well as determining run times, we are also interested in
- 19. Memory usage versus run times Warning: programmers often mistake this to suggest that given any solution
- 20. The sizeof Operator In order to determine memory usage, we must know the memory usage of
- 21. The sizeof Operator #include using namespace std; int main() { cout cout cout cout cout cout
- 22. Abstract Strings A specialization of an Abstract List is an Abstract String: The entries are restricted
- 23. Abstract Strings Strings also include DNA The alphabet has 4 characters: A, C, G, and T
- 24. Standard Template Library In this course, you must understand each data structure and their associated algorithms
- 25. Standard Template Library #include #include using namespace std; int main() { vector v( 10, 0 );
- 26. Summary In this topic, we have introduced Abstract Lists Explicit linear orderings Implementable with arrays or
- 27. References [1] Donald E. Knuth, The Art of Computer Programming, Volume 1: Fundamental Algorithms, 3rd Ed.,
- 29. Скачать презентацию