0% found this document useful (0 votes)
22 views

Unit One

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Unit One

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Unit One

Introduction to Data Structure


What is Data Structure??
• Data structure is a storage that is used to store and organize data. It is a way of
arranging data on a computer so that it can be accessed and updated efficiently.
• Depending on your requirement and project, it is important to choose the right
data structure for your project. For example, if you want to store data sequentially
in the memory, then you can go for the Array data structure.
• A data structure should be seen as a logical concept that must address four
fundamental concerns.
• First, how the data will be stored, and
• Second, what operations will be performed on it.
• Third, how are the data associated
• Fourth, how can they be accessed.
• As data structure is a scheme for data organization so the functional definition of a
data structure should be independent of its implementation.
• The functional definition of a data structure is known as ADT (Abstract Data
Type) which is independent of implementation.
• The way in which the data is organized affects the performance of a program for
different tasks.
• Computer programmers decide which data structures to use based on the nature of
the data and the processes that need to be performed on that data.
• Some of the more commonly used data structures include lists, arrays, stacks,
queues, heaps, trees, and graphs.
Data Type
- Data => represents value or set of values.
- Data Type => classification that specifies what value a variable can hold and what
operation can be performed.
- Programming Languages have own implementation of various data types.
- Ex: C = int, char, float, long, and so on …
Python = String, List, Tuples and so on …
- Types

- 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.

Non-linear Data Structure:


• Non-linear data structure can be constructed as a collection of randomly distributed set of data item
joined together by using a special pointer (tag).
• In non-linear Data structure the relationship of adjacency is not maintained between the data items.
• The following list of operations applied on non-linear data structures.
1. Add elements
2. Delete elements
3. Display the elements
4. Sort the list of elements
5. Search for a data element
For example Tree, Decision tree, Graph and Forest
Abstract Data Type
• Abstract data types, abbreviated as ADT are the entities that are definitions of
data and operations but do not have implementation details. In this case, we know
the data that we are storing and the operations that can be performed on the data,
but we don't know about the implementation details. The reason for not having
implementation details is that every programming language has a different
implementation strategy for example; a C data structure is implemented using
structures while a C++ data structure is implemented using objects and classes.
• For example, a List is an abstract data type that is implemented using a dynamic
array and linked list. A queue is implemented using linked list-based queue,
array-based queue, and stack-based queue. A Map is implemented using Tree
map, hash map, or hash table.
• ADT simply defines what is does, and hides how it does?
• Before knowing about the abstract data type model, we should know about abstraction and
encapsulation.
• Abstraction: It is a technique of hiding the internal details from the user and only showing
the necessary details to the user.
• Encapsulation: It is a technique of combining the data and the member function in a single
unit is known as encapsulation.

• 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.

You might also like