Skip to main content

Computer Programming : Classification or Type of Data structures, C Programming

Data structures can be classified, keeping in view the way the elements are connected to each other, the way when they are stored in memory or the way further division of a data structure.

Linear and Non-Linear

This type of classification is on the basis of element's connection and placement. When the elements of a data structures are placed in order, means if the second element is placed after the first one, third one after the second one and so on, are called Linear Data Structures otherwise Non-Linear Data Structures. Examples of Non-linear Data Structures: Trees, Graphs etc.

Classification of Data Structure in Computer programming

ARRAY is an ordered collection of similar data elements. So, it is called as Linear Data Structure. The element are arranged in Linear order i.e. one after the other at consecutive memory locations.Similarly LINKED LIST is also a Linear Data Structure Where the elements of List are stored in Linear Order but at different memory locations, the Linear order is maintained by one of the fields of Linked List, called Link field(pointer to next node element).

On the other hand, TREE is a non-linear data structure in which the elements are stored in hierarchical order instead of linear order. In hierarchical order top most node is called root node and it may be connected to zero, one or more than one nodes. So from one element elements of the data structure are placed such that they are adjacent (connected) to more than one element, then the resulting data structure, Which is non-linear one, is called as GRAPH. Graph is a general non-linear data structure and Tree is a restricted Graph.

STACK and QUEUE are specialized data structures where insertion and deletion are restricted. STACK and QUEUE can be implemented either using one-dimensional array or linked list.

Linear data structure are also called as contiguous data structures and non-linear data structures are called as non-contiguous data structure.

Static and Dynamic

This type of classification is on the basis of Memory Allocation. The data structure modeled must be present in memory to use it i.e. memory should be allocated to the data structure to store the data in it. If the memory is allocated to the data structures at the time of compilation of programs where the data structures are used, then such type of data structures are called as static data structures. Compilation of program is translation of source program into an object program. The linear data structure ARRAY is static data structure for which memory is allocated at the time of  compilation.

On the other hand if the memory is allocated at the time of execution of program (While running) for the data structures used in the program are called Dynamic data structures. The linear data structure LINKED LIST is a dynamic data structure for which memory is allocated at the time of execution, means the memory for data structure is allocated as per the user wish at the time of executing the program.

Primitive and Non-Primitive

This type of classification is on the basis of further division. If the data structure is not further divisible to another data structure, then it is called as Primitive data structure and if it is further divisible then it is called as Non-Primitive data structure.

For example the standard data types of C like char, int, float are fall under the category of Primitive data structures where as user defined or derived data types like array, structure are further divisible so they are called Non-Primitive data structure. 

Comments

Popular posts from this blog

difference between structure and union in C Language

In c language article we will see the difference between union and structure. Both are the user define datatype in c language. See the table which is mentioned below: ASP.NET Video Tutorial Series Structure Union1.The keywordstruct is used to define a structure 1. The keyword union is used to define a union. 2. When a variable is associated with a structure, the compiler allocates the memory for each member. The size of structure is greater than or equal to the sum ofsizes of its members. The smaller members may end with unused slack bytes. 2. When a variable is associated with a union, thecompiler allocates thememory by considering the size of the largest memory. So, size of union is equal to the size of largest member. 3. Each member within a structure is assigned unique storage area of location. 3. Memory allocated is shared by individual members of union. 4. The address of each member will be in ascending order This indicates that memory for each member will start at different offset v…

Difference between Linear search and Binary Search in c language

SQL Video Channel : Download all SQL Video



Binary Search Linear Search Works only on sorted items. such as  1,2,3,4,5,6  etc
Works on sorted as well as unsorted items. 12,4,5,3,2,1 etc Very efficient if the items are sorted Very efficient if the items are less and present in the beginning of the list. such as Suppose your list items are : 12,3,4,5,1 and you want to search 12 number then you get beginning in the list. Works well with arrays and not on linked lists. Works with arrays and linked lists.
Number of comparisons are less More number of comparisons are required if the items are present in the later part of the array or its elements are more.

Memory representation of Linked List Data Structures in C Language

Memory representation of Linked List

             In memory the linked list is stored in scattered cells (locations).The memory for each node is allocated dynamically means as and when required. So the Linked List can increase as per the user wish and the size is not fixed, it can vary.

               Suppose first node of linked list is allocated with an address 1008. Its graphical representation looks like the figure shown below:


      Suppose next node is allocated at an address 506, so the list becomes,



  Suppose next node is allocated with an address with an address 10,s the list become,


The other way to represent the linked list is as shown below:




 In the above representation the data stored in the linked list is “INDIA”, the information part of each node contains one character. The external pointer root points to first node’s address 1005. The link part of the node containing information I contains 1007, the address of next node. The last node …