Assignment Data Structuer

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

AVL(Adelson-Velskii and Landis)

List of Pros of AVL Trees


1. Faster Search Operations
The most prevalent benefit of AVL trees is the fact that they offer faster search operations than their
counterparts such as red-black trees. This means that users are able to complete their tasks much
quicker than if they were to rely on other search operations. Typically this is imperative for coding to
ensure that projects are completed in a timely manner. It is also essential for when users need to
complete searches faster and in a more reliable nature.

2. Balancing Capabilities
One of the main concerns that computer science professionals have is to ensure that their trees are
balanced and with AVL trees, there is a higher likelihood of them being balanced. An unbalanced
tree means that it will take longer for operations to be performed, resulting in time intensive lookup
applications. The longer it takes for a tree to be balanced, the longer the search will take. Typically
referred to as a self balancing binary search tree, the three major operations you can complete with
an AVL tree include search, insert, and delete.

List of Cons of AVL Trees


1. Slow Inserts and Deletes
The largest disadvantage to using an AVL tree is the fact that in the event that it is slightly
unbalanced it can severely impact the amount of time that it takes to perform inserts and deletes.
Computer science professionals find that since AVL trees don’t allow anything outside of -1 to 1, it
can drastically slow these 2 functions down.

2. Fast Updating Systems


In the event that you’re working on a system that has the tendency to update quickly then it is
advisable to avoid AVL trees. This is because they work much better with systems that are rarely
updated, giving the system time to acquire all of the information that it needs to perform at its best. If
you are working with controlled data, an AVL tree is your best option.
BST (Binary Search Tree)

Advantages of BST :

Compared to linear search (checking each element in the array starting from the
first), binary search is much faster. Linear search takes, on average N/2
comparisons (where N is the number of elements in the array), and worst case N
comparisons. Binary search takes an average and worst-
case log2(N)log2(N) comparisons. So for a million elements, linear search
would take an average of 500,000 comparisons, whereas binary search would
take 20.
 It’s a fairly simple algorithm, though people get it wrong all the time.
 It’s well known and often implemented for you as a library routine.
Disadvantages of BST :

 It’s more complicated than linear search, and is overkill for very small
numbers of elements.
 It works only on lists that are sorted and kept sorted. That is not always
feasable, especially if elements are constantly being added to the list.
 It works only on element types for which there exists a less-than
relationship. Some types simply cannot be sorted (though this is rare).
 There is a great lost of efficiency if the list does not support random-access.
You need, for example, to immediately jump to the middle of the list. If your
list is a plain array, that’s great. If it’s a linked-list, not so much. Depending on
the cost of your comparison operation, the cost of traversing a non-random-
access list could dwarf the cost of the comparisons.
 There are even faster search methods available, such as hash lookups.
However a hash lookup requires the elements to be organized in a much more
complicated data structure (a hash table, not a list).

ADVANTAGE OF B+ TREE :

B+ Trees are much easier and higher performing to do a full scan, since the terminal
nodes form a linked list. But to do a full scan in B tree, a complete inorder traversal is to
be made.
DISADVANTAGE OF B+ TREE :

Any search will end at leaf node only. Time complexity for every search results in O(h).
H-height of the B+ tree. Waste of Memory. In comparing to B+ trees, B trees are
efficient.
B-Tree advantage

 B-Trees take advantage of this by maintaining a balanced binary tree structure


through the use of two files:
o index file: contains all the keys and the tree's topology is represented
by the organization of data in this file.
o data file: a file that contains all the objects and information stored by
the “tree”. Objects contained here are referenced by block pointer
references stored in the index file.

B- Tree disadvantages
 B-trees are powerful not just because they allow any file item to be
immediately located using any attribute as a key, but because they work even
when the file is very dynamic, with items constantly being inserted, changed, or
deleted.
 But imagine a parts file where new items are infrequently added or changed
(say, once every few months) and rarely deleted. It may be tempting to use a B-
tree to allow instant lookup of a part number for a given description, but a B-
tree is probably overkill in this situation, since the data file being indexed rarely
changes.
 Whenever a data file is relatively static and unchanging, it may be better to use
an indexing method simpler than B-trees, such as a minimum file of pointers
that is completely rebuilt any time the target data file is changed.

Red Black Tree

Advantages

 Red-black trees are self-balancing so these operations are guaranteed to be


O(log(n)); a simple binary search tree, on the other hand, could potentially
become unbalanced, degrading to O(n) performance for Insert, Delete, and
Get.
 Particularly useful when inserts and/or deletes are relatively frequent.
 Relatively low constants in a wide variety of scenarios.
 All the advantages of binary search trees.
Disadvantages

 Relatively complicated to implement because of all the operation edge cases;


typically you'd want to use a standard library implementation (e.g. TreeSet in
Java, STL set in C++, etc) rather than implementing one yourself from scratch.
 If you plan to only build the tree once and then only perform read operations
thereafter, AVL trees offer better performance. (In practice, this performance
gain is usually negligible, so most popular standard libraries only provide a
red-black tree implementation and no AVL tree implementation.)
 Because B-trees can have a variable number of children, they are typically
preferred over red-black trees for indexing and storing a large amount of
information on disk, since they can be kept relatively shallow to limit disk
operations.
 Locking red-black trees perform like crap with concurrent access compared
to locking skip lists, which (1) are blazingly fast even with concurrent access;
(2) are often simpler to implement; and (3) offer essentially all the advantages
of locking red-black trees.

AA TREES
Advantage of AA Trees
• AA trees simplify the algorithms – It eliminates half the restructuring cases – It simplifies
deletion by removing an annoying case
• if an internal node has only one child, that child must be a red right child
• We can always replace a node with the smallest child in the right subtree [it will either be a
leaf or have a red child]
HEAP
Advantage-
 
1-Help to find greatest and minimum number
2-Heap data structure efficiently use graph algorithm such as Dijkstra.
Disadvantage-
1-It takes so much time to compare and then execute.

Disadvantages-

Disadvantage of using Heap is storing data on Heap is slower than it would


take when using the stack . However, the main advantage of using the heap is
its flexibility. That's because memory in this structure can be allocated and
removed in any particular order . Slowness in the heap can be compensated if
an algorithm is well designed and implemented .

You might also like