Unit One
Unit One
- Primitive => basic building blocks, stores single value (ex: int, float, boolean,
char etc)
- Composite => made by composing primitive or other composite types (ex:
struct, array, string etc)
- Abstract => defined by the behaviour exhibited. (ex: set, stack, queue, graph,
tree etc)
In C programming language, the data types are classified as:
Primitive Data Type: set of basic data types from which all other data types are
constructed. Specifically it often refers to the limited set of data representations in
use by a particular processor, which all compiled programs must use.
Derived Data Type: can be defined as the type of data types that are derived from
fundamental data types. They are derived from the primitive data types by inclusion
of some elements of the basic or primary data types. They are used in order to
represent single/multiple values.
User Defined Data Type: a set of constructs that allow users to define their data
types. These user-defined data types are constructed using a combination of
primitive data types and derived data types.
Classification of Data Structure
The classification of Data Structure is as follow:
Simple Data Structure
• Simple data structure can be constructed with the help of primitive data structure.
• A primitive data structure used to represent the standard data types of any one of the
computer languages.
• Variables, arrays, pointers, structures, unions, etc. are examples of primitive data
structures.
Compound Data structure:
• Compound data structure can be constructed with the help of any one of the primitive
data structure and it is having a specific functionality.
• It can be designed by user. It can be classified as
• Linear data structure
• Non-linear data structure
Linear Data Structure:
• Linear data structures can be constructed as a continuous arrangement of data elements
in the memory.
• It can be constructed by using array data type.
• In the linear Data Structures the relationship of adjacency is maintained between the
data elements.
• The following list of operations applied on linear data structures
1. Add an element
2. Delete an element
3. Traverse
4. Sort the list of elements
5. Search for a data element
For example Stack, Queue, Tables, List, and Linked Lists.
• The above figure shows the ADT model. There are two types of models in the ADT model,
i.e., the public function and the private function. In this model, first encapsulation is
performed, i.e., all the data is wrapped in a single unit, i.e., ADT. Then, the abstraction is
performed means showing the operations that can be performed on the data structure and
what are the data structures that we are using in a program.
Array as ADT
• 1 D array declaration in C
data_type array_name[size]={element1,element2,..............,element n};
• 2 D array declaration in C
data_type array_name[row_size][column_size];
• Common operations on array:
○ Creating of an array
○ Inserting new element at required position
○ Deletion of any element
○ Modification of any element
○ Traversing of an array
○ Merging of arrays
• How is array an ADT?
Let A be an array of type T and has n elements then it satisfied the following
operations:
• CREATE(A): Create an array A
• INSERT(A,X): Insert an element X into an array A in any location
• DELETE(A,X): Delete an element X from an array A
• MODIFY(A,X,Y): modify element X by Y of an array A
• TRAVELS(A): Access all elements of an array A
• MERGE(A,B): Merging elements of A and B into a third array C
Importance of Data Structure
• In computer science, the Importance of data structure is everywhere. Data structure
provides basic stuff to resolve problems. Its importance can be understood by the following:
1. A software has two parts front end and back end. The front end provides an interface and
the back end is called a database which contains records of customers. There can be
million or trillion of customers. If we have to find out the record of a particular or a
number of customers, it is done by a searching method which is an operation on the data
structure.
2. If any software is to be run, at first it is fed into computer memory. In computer memory
jobs are entered into queues. And the queue is also a concept of data structure.
3. As we know when jobs and processes are entered then queues are formed. These queues
can have too many jobs or processes. In queues, jobs are processed in the same order as
they entered. If any job is created it is placed at the end of a queue. Suppose we have to
add or delete any job in any order then the concept of the queue will be failed and the
concept of link list will be used.
4. If any data is to be stored in a hierarchical fashion then the concept of tree is used.
5. If data is to be arranged alphabetically or numerically then it is done by sorting method
which is an operation on the data structure.