DS - Lect 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Chapter: 1 Introduction to Data Structure

What is Data Structure?


Definition: It is a collection of data values and relationship among them with
required operations.
OR
A Data Structure is a way to store and organize data in a computer memory,
so that it can be used efficiently.
OR
A Data Structure is a programmatic way of storing data so that data can be
used efficiently.
OR
The way in which data is efficiently stored, processed and retrieved is called
Data Structure.
OR
The logical or mathematical organization of data in computer memory is
called Data Structure.
Why we use data structure?
• Data Organization
• Data Management
• Storage Format
• Easy Access of data
• Efficient retrieval of data
• Efficient modification of data etc.

Why we need of Data Structures?


As applications are getting complexed and amount of data is increasing day
by day, there may arise the following problems:
• Processor speed: To handle very large amount of data, high speed
processing is required, but as the data is growing day by day to the
billions of files per entity, processor may fail to deal with that much
amount of data.
• Data Search: Consider an inventory size of 106 items in a store, if our
application needs to search for a particular item, it needs to traverse
106 items every time, results in slowing down the search process.
1|Page
Chapter: 1 Introduction to Data Structure

• Multiple requests: If thousands of users are searching the data


simultaneously on a web server, then there are the chances that a very
large server can be failed during that process.
In order to solve the above problem, data structures are used. Data is
organized to form a data structure in such a way that all items are not
required to be searched and required data can be searched instantly.

What are the advantages of Data Structures?


• Efficiency: Efficiency of a program depends upon the choice of data
structures. For example: suppose, we have some data and we need to
perform the search for a particular record. In that case, if we organize
our data in an array, we will have to search sequentially element by
element. Hence, using array may not be very efficient here. There are
better data structures which can make the search process efficient like
ordered array, binary search tree or hash tables.
• Reusability: Data structures are reusable, i.e., once we have
implemented a particular data structure, we can use it at any other
place. Implementation of data structures can be compiled into libraries
which can be used by different clients.
• Abstraction: Data structure is specified by the ADT which provides a
level of abstraction. The client program uses the data structure through
interface only, without getting into the implementation details.

Discuss various types of data structure?


Following are types of data structure;
➢ Linear Data Structure
➢ Non-Linear Data Structure

Linear Data Structure: A type of data structure in which data is stored in


continuous memory locations OR data is stored in a sequence is called Linear
Data Structure.
Example: Array, Linked List, Queues, Stack, Strings etc.
Linear data structure is further divided into the following types;
• Static Data Structure
• Dynamic Data Structure

2|Page
Chapter: 1 Introduction to Data Structure

Static Data Structure: A type of Linear data structure whose size is fixed
and cannot be change during execution time is called Static data structure.
The content of the static data structure can be modified but without changing
the memory space allocated to it.
Example: Arrays

Dynamic Data Structure: A type of Linear data structure whose size is not
fixed and can be modified during the operations performed on it is called
Dynamic data structure. Dynamic data structures are designed to facilitate
change of data structures in the run time.
Example: Linked List, Stack

Non-Linear Data Structure: A type of data structure in which data is


stored in non-continuous memory locations OR data is stored randomly is
called Non-Linear Data Structure.
Example: Trees, Graphs, Files etc.

3|Page
Chapter: 1 Introduction to Data Structure

Which types of operations can be performed on a data structure?


Following operations can be performed on a data structure;
Traversing: Accessing and processing each record in a data structure is
called traversing. It is also called visiting of the record.
Searching: Finding a particular record in a data structure OR finding the
location of a record with the given key value is called searching.
Insertion: Adding a new record in a data structure is called insertion.
Deletion: Removing a particular record from a data structure is called
deletion.
Sorting: Arranging data elements of a data structure in a specified order is
called sorting. There are many algorithms that can be used to perform
sorting, for example, insertion sort, selection sort, bubble sort, etc.
Merging: Combining elements of two similar data structures to form a new
data structure of the same type, is called merging. Merging is of two types;
✓ Copying: Combining some portions of two different files into a single
file is called copying.
✓ Concatenation: Combining two different files into one file is called
concatenation.

X
AJAB NOOR
Lecturer in Computer Science, GPGC Bannu

4|Page

You might also like