Data Structures On C/C++

First let us begin what data structures is ‘It is an organized collection of data in the memory of the computer so that it can be easily retrieved, updated, deleted easily’ it often comes to use when we develop enterprise software they have to maintain huge databases of employees and customers etc.

Data structures are of many types like linked lists, trees, graphs etc. When it comes to programming we see the requirement and depending upon that we select the right kind of data structure which is cost effective and efficient.

Let’s begin with link lists. We have various kinds of linked lists I have summarized them here.

1) Single Linked list-> Each node pointing to the next.

 

 

 

          Click Here for a C++ source code on single link list with insertion, deletion,            modification.

2)        Double Linked list-> Each node pointing to previous and the next node.

          Click Here for a C++ source code on double link list with insertion, deletion,            modification.

3)        Circular Linked list-> The last node or tail pointing to the head node.

          Click Here for a C++ source code on circular link list with insertion, deletion,            modification.

Now we come to trees. Trees have less access time but are very complicated to implement. Trees are of following types.

1) Binary Search tree-> Each node points to two nodes and have a left and right child. The left child is lesser than the key value at parent node and right child has a value greater than the key in the parent node

 

 

 

 

 

 

 

 

 

 

 

As you can see this has this is an ideal BST but this is not the general case sometimes trees have more left nodes than right nodes the situation will be different and it will be nothing better than a linked list. So AVL ( Adelson Velski Landis) these 3 computer scientists designed an algorithm for a balanced BST known as AVL tree. The term balanced means that the no of left nodes minus no of right nodes will be less than or equal to mod 1.

(no of left nodes)-(no of right nodes)<=[ 1 ] means it can take only 3 values –1,0,+1.

Click here to find a C/C++ program on BST.

HEAD

TAIL

          76

         64

        84

55

70

78

92