Data Type vs Data Structure

Data Types

A data type specifies the type of data that a variable can store such as integer, floating, character, etc.

There are the following data types in C language.

Types

Data Types

Basic Data Type

int, char, float, double

Derived Data Type

array, pointer, structure, union

Enumeration Data Type

enum

Void Data Type

void

Basic Data Types

The basic data types are integer-based and floating-point based. C language supports both signed and unsigned literals.

The memory size of the basic data types may change according to 32 or 64-bit operating system.

Let's see the basic data types. Its size is given according to 32-bit architecture.

Data Types

Memory Size

Range

char

1 byte

−128 to 127

signed char

1 byte

−128 to 127

unsigned char

1 byte

0 to 255

short

2 byte

−32,768 to 32,767

signed short

2 byte

−32,768 to 32,767

unsigned short

2 byte

0 to 65,535

int

2 byte

−32,768 to 32,767

signed int

2 byte

−32,768 to 32,767

unsigned int

2 byte

0 to 65,535

short int

2 byte

−32,768 to 32,767

signed short int

2 byte

−32,768 to 32,767

unsigned short int

2 byte

0 to 65,535

long int

4 byte

-2,147,483,648 to 2,147,483,647

signed long int

4 byte

-2,147,483,648 to 2,147,483,647

unsigned long int

4 byte

0 to 4,294,967,295

float

4 byte

double

8 byte

long double

10 byte


Data Structure

Data Structure can be defined as the group of data elements which provides an efficient way of storing and organising data in the computer so that it can be used efficiently. Some examples of Data Structures are arrays, Linked List, Stack, Queue, etc. Data Structures are widely used in almost every aspect of Computer Science i.e. Operating System, Compiler Design, Artifical intelligence, Graphics and many more.

Data Structures are the main part of many computer science algorithms as they enable the programmers to handle the data in an efficient way. It plays a vital role in enhancing the performance of a software or a program as the main function of the software is to store and retrieve the user's data as fast as possible.

Typical base data types, such as integers or floating-point values, that are available in most computer programming languages are generally insufficient to capture the logical intent for data processing and use. Yet applications that ingest, manipulate and produce information must understand how data should be organized to simplify processing. Data structures bring together the data elements in a logical way and facilitate the effective use, persistence and sharing of data. They provide a formal model that describes the way the data elements are organized.

Data structures are the building blocks for more sophisticated applications. They are designed by composing data elements into a logical unit representing an abstract data type that has relevance to the algorithm or application. An example of an abstract data type is a "customer name" that is composed of the character strings for "first name," "middle name" and "last name."

It is not only important to use data structures, but it is also important to choose the proper data structure for each task. Choosing an ill-suited data structure could result in slow runtimes or unresponsive code. Five factors to consider when picking a data structure include the following:

  1. What kind of information will be stored?
  2. How will that information be used?
  3. Where should data persist, or be kept, after it is created?
  4. What is the best way to organize the data?
  5. What aspects of memory and storage reservation management should be considered?

In general both data type and data structure seems to be the same thing as both deals with the nature and organizing of data but among two one describes the type and nature of data while other represents the collections in which that data can be stored.

Following are the important differences between Data Type and Data Structure

Data TypeData Structures
It tells about the type of data a variable can accept.It is a collection of data types
Data Types implementation is a form of abstract implementation where different languages define it differently.Data Structures implementation is called concrete implementation as their definition is already defined by the language that what type of data they are going to store and deal with.
Data Types can only hold a particular value that is part of the dataData Structure can have different kinds and types of data within one single object
Values can directly be assigned to the data type variables since data type already represents the type of value that can be storedThe data is assigned to the data structure object using some set of algorithms and operations like push, pop, and so on.
For Data Types, there is no involvement of time complexity since only type and nature of data is concernTime complexity comes into play when working with data structures as it mainly deals with manipulation and execution of logic over stored data.
Examples: intfloatdoubleExamples: stacksqueuestree

Popular posts from this blog

DATA STRUCTURES-II

DATA STRUCTURES FOR B.TECH

DATA STRUCTURES FOR BCA