• Bài giảng ECE 250 Algorithms and Data Structures - 5.03. Complete binary treesBài giảng ECE 250 Algorithms and Data Structures - 5.03. Complete binary trees

    Array storage Question: why not store any tree as an array using breadth-first traversals? – There is a significant potential for a lot of wasted memory Consider this tree with 12 nodes would require an array of size 32 – Adding a child to node K doubles the required memory

    pdf21 trang | Chia sẻ: vutrong32 | Ngày: 17/10/2018 | Lượt xem: 1181 | Lượt tải: 3

  • Bài giảng ECE 250 Algorithms and Data Structures - 5.02. Perfect binary treesBài giảng ECE 250 Algorithms and Data Structures - 5.02. Perfect binary trees

    Applications Perfect binary trees are considered to be the ideal case – The height and average depth are both (ln(n)) We will attempt to find trees which are as close as possible to perfect binary trees

    pdf20 trang | Chia sẻ: vutrong32 | Ngày: 17/10/2018 | Lượt xem: 1112 | Lượt tải: 1

  • Bài giảng ECE 250 Algorithms and Data Structures - 5.01. Binary treesBài giảng ECE 250 Algorithms and Data Structures - 5.01. Binary trees

    Summary In this talk, we introduced binary trees – Each node has two distinct and identifiable sub-trees – Either sub-tree may optionally be empty – The sub-trees are ordered relative to the other We looked at: – Properties – Applications

    pdf32 trang | Chia sẻ: vutrong32 | Ngày: 17/10/2018 | Lượt xem: 1068 | Lượt tải: 2

  • Bài giảng ECE 250 Algorithms and Data Structures - 4.03. Tree traversalsBài giảng ECE 250 Algorithms and Data Structures - 4.03. Tree traversals

    Summary This topic covered two types of traversals: – Breadth-first traversals – Depth-first traversals – Applications – Determination of how to structure a depth-first traversal

    pdf25 trang | Chia sẻ: vutrong32 | Ngày: 17/10/2018 | Lượt xem: 1107 | Lượt tải: 1

  • Bài giảng ECE 250 Algorithms and Data Structures - 4.02. Abstract TreesBài giảng ECE 250 Algorithms and Data Structures - 4.02. Abstract Trees

    Summary In this topic, we have looked at one implementation of a general tree: – store the value of each node – store all the children in a linked list – not an easy (Q(1)) way to access children – if we use an array, different problems.

    pdf21 trang | Chia sẻ: vutrong32 | Ngày: 17/10/2018 | Lượt xem: 1096 | Lượt tải: 1

  • Bài giảng ECE 250 Algorithms and Data Structures - 4.01. The Tree Data StructureBài giảng ECE 250 Algorithms and Data Structures - 4.01. The Tree Data Structure

    Summary In this topic, we have: – Introduced the terminology used for the tree data structure – Discussed various terms which may be used to describe the properties of a tree, including: • root node, leaf node • parent node, children, and siblings • ordered trees • paths, depth, and height • ancestors, descendants, and subtrees – We looke...

    pdf42 trang | Chia sẻ: vutrong32 | Ngày: 17/10/2018 | Lượt xem: 1222 | Lượt tải: 1

  • Bài giảng ECE 250 Algorithms and Data Structures - 3.05. Linked ListsBài giảng ECE 250 Algorithms and Data Structures - 3.05. Linked Lists

    Summary We have considered the implementation of linked lists in C++ – Aspects of the Node class – Accessors and mutators – The implementation of various member functions – Stepping through a linked list – Defining the copy and assignment operator – Defining move constructors and move assignment operators – Discussed efficiencies

    pdf147 trang | Chia sẻ: vutrong32 | Ngày: 17/10/2018 | Lượt xem: 1180 | Lượt tải: 3

  • Bài giảng ECE 250 Algorithms and Data Structures - 3.04. DequesBài giảng ECE 250 Algorithms and Data Structures - 3.04. Deques

    Summary In this topic, we have introduced the more general deque abstract data structure – Allows insertions and deletions from both ends of the deque – Internally may be represented by either a doubly-linked list or a twoended array More important, we looked at the STL and the design pattern of an iterator

    pdf34 trang | Chia sẻ: vutrong32 | Ngày: 17/10/2018 | Lượt xem: 1206 | Lượt tải: 1

  • Bài giảng ECE 250 Algorithms and Data Structures - 3.03. QueuesBài giảng ECE 250 Algorithms and Data Structures - 3.03. Queues

    Summary The queue is one of the most common abstract data structures Understanding how a queue works is trivial The implementation is only slightly more difficult than that of a stack Applications include: – Queuing clients in a client-server model – Breadth-first traversals of trees

    pdf49 trang | Chia sẻ: vutrong32 | Ngày: 17/10/2018 | Lượt xem: 1086 | Lượt tải: 3

  • Bài giảng ECE 250 Algorithms and Data Structures - 3.02. StacksBài giảng ECE 250 Algorithms and Data Structures - 3.02. Stacks

    Stacks The stack is the simplest of all ADTs – Understanding how a stack works is trivial The application of a stack, however, is not in the implementation, but rather: – where possible, create a design which allows the use of a stack We looked at: – parsing, function calls, and reverse Polish

    pdf104 trang | Chia sẻ: vutrong32 | Ngày: 17/10/2018 | Lượt xem: 1168 | Lượt tải: 2