Properties of Various Adts

Properties of Various Adts

<p> Properties of various ADTs</p><p>1. LIST</p><p> a. can be accessed from front, middle, and end</p><p> b. to search for an item:</p><p> i. if not sorted: </p><p> it has to be a sequential search. O(n)</p><p> for items not in the list: you have to search until the end</p><p> ii. if sorted: </p><p> and if it is implemented as an array or vector it can be searched using binary search. O(log n)</p><p> if searched sequentially and item not in the list you can stop once you passed the place where the item should be, you do not have to search until the end.</p><p> c. adding to a sorted list requires finding appropriate location</p><p>2. STACK</p><p> a. additions and removals are done at one end … the TOP</p><p> b. you access the last (newest) item added first (LIFO)</p><p> c. you can not add in the middle of a stack</p><p>3. QUEUE</p><p> a. additions are done at the END of the queue</p><p> b. removals are done at the FRONT of the queue</p><p> c. you access the first (oldest) item added first (FIFO) d. you can not add in the middle of a queue</p><p>4. PRIORITY QUEUE (PQ)</p><p> a. it is a variation of a queue that is sorted by priority</p><p> b. additions are done in specific positions according to priority</p><p>(not controlled by user, it is controlled by the ADT)</p><p> c. removals are done at the FRONT of the PQ, just like a regular queue</p><p> d. you can access the most important item first, that is the item with the highest priority.</p><p> e. Do NOT confuse with sorted list. Here you can only remove from front!!</p><p>5. DEQUE</p><p> a. it is a combination of stack and a queue</p><p> b. you can add and remove from both ends</p><p> c. but you can not add or remove from the middle</p><p>6. BINARY SEARCH TREE (BST)</p><p> a. if traversed inorder produces sorted output</p><p> b. additions are easy, only need to find appropriate location by deciding left or right repeatedly (or recursively)</p><p> c. removals have different cases depending on whether the node to be removed is a leaf, has one child, or two children, so it is a little bit complicated.</p><p> d. search is of O(h) and h=height is at best O(log n) where n=number of nodes. This means the shorter the tree the faster the search. e. it is suitable for applications that require fast searching.</p><p>7. AVL TREE</p><p> a. a special kind of BST : </p><p> it is balanced, which means it is always shortest possible  faster search</p><p> b. additions are complicated, because need to keep tree balanced</p><p> c. removals are also complicated</p><p> d. not suitable if there are a lot of additions and removals all the time</p><p>8. B-TREE</p><p> a. another kind of balanced trees, but not a binary tree</p><p> b. used for huge amount of data</p><p>9. HEAP</p><p> a. a special kind of Binary Trees, but not a binary search tree</p><p> b. it is a complete binary tree</p><p> c. can be used to implement priority queues</p><p> d. can be used to sort data</p><p> e. additions are controlled by the ADT</p><p> f. removals always from root</p><p> g. Two kinds i. MAX heaps: </p><p> largest value in root and its subtrees are also max heaps ii. MIN heaps:</p><p> smallest value in root and its subtrees are also min heaps</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us