Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Lecture 01 Intro to DSA
1. I N T R O D U C T I O N T O D ATA
S T R U C T U R E S
N U R J A H A N N I PA
L E C T U R E R , D E P T O F I C T, B D U
2. LECTURE OUTLINES
• Basic Terminology
• Definition of data structure
• Types of data structures
• Data Structure Operations
• Algorithm
3. BASIC TERMINOLOGY
Data “Raw” facts, such as a telephone number, a birth date, a
customer name, and phone number. Data have little
meaning unless they have been organized in some
logical manner
Information Processed data. Information is used to reveal the
meaning of data.
Accurate, relevant, and timely information is the key to
good decision making.
Group Item Data items which have subordinate data items are
called Group item, for example, name of a student can
have first name and the last name.
4. Field Field is a smaller entity of the table which contains specific
information about every record in the table. In the example,
No, time, Temperature, difference, Measurement accuracy is
the field of that table.
Record A row of a table is also called record. It contains the specific
information of each individual entry in the table. It is a
horizontal entity in the table. For example, the fields 1,13.33,
29.30, 29.7, 0.40, 98.65 are the part of a record.
File A collection of related records. For example, a file might
contain data about the students currently enrolled at BDU.
Prepared By: Nurjahan Nipa 4
5. WHAT IS DATA STRUCTURE
• Data can be organized in many different ways; the logical or mathematical model of a
particular organization of data is called a data structure.
• Data structure is a method of organizing a large amount of data more efficiently so
that any operation on that data becomes easy.
• A data structure is a particular way of storing and organizing data either in computer’s
memory or on the disk storage so that it can be used efficiently.
• Data Structures are widely used in almost every aspect of Computer Science i.e. DBMS,
Operating System, Compiler Design, Artificial intelligence, Graphics and many more.
6. CHOICE OF PARTICULAR DATA MODEL
First, it must be rich enough in structure to mirror the actual relationships of the data
in real world.
On the other hand, the structure should be simple enough that one can effectively
process the data when necessary.
7. TYPES OF DATA STRUCTURE
1. Primitive Data structure: The primitive data structures are fundamental data types
that are supported by a programming language. The primitive data structure are also
called simple data structures. For example, integer, float, character, and Boolean are all
primitive data types.
2. Non-Primitive Data structure: Non-primitive data types are not defined by the
programming language, but are instead created by the programmer. The non-primitive
data types are used to store the group of values. Examples of the non-primitive data
types are Array, linked list, stacks, queue, tree, graphs etc.
9. LINEAR AND NON LINEAR STRUCTURES
• Linear Data Structure: If the elements of a data structure are stored in a linear or
sequential order, then it is a linear data structure. Examples- Arrays, Linked Links,
Stacks, Queues.
• Non-Linear Data Structure: If the elements of a data structure are not stored in
sequential order, then it is a non-linear data structure. Examples- Trees and graphs.
12. ARRAY
An array is a collection of items stored at contiguous memory locations. The idea is to
store multiple items of the same type together.
13. Arrays are of fixed size.
Data elements are stored in contiguous memory locations which may not be always
available.
Insertion and deletion of elements can be problematic because of shifting of elements
from
their positions.
Uses in Real life applications:
• 2D Arrays, generally called Matrices are mainly used in Image processing
• RGB image is a n*n*3 array
14. LINKED LISTS
Like arrays, Linked List is a linear data structure. Unlike arrays, linked list elements are not
stored at a contiguous location; the elements are linked using pointers.
• Music player- Songs in music player are linked to previous and next song.
• Previous and next page in web browser.
• Image viewer- Previous and next images are linked.
15. STACK
A stack is a linear data structure in which insertion and
deletion of elements are done at only ne end, which is known
as the top of the stack. Stack follows LIFO semantics i.e. the
last element which is added to the stack is the first element
which is deleted from the stack.
Push: This term is used to insert an element into a stack.
Pull: This term is used to delete an element into a stack.
Uses:
Need to store undo/redo operation in a word process.
Recursion
16. QUEUE
• A Queue is a linear list of elements in
which deletions can take place only at one
end, called the front, and insertions can
take place only at the other end, called the
rear.
• It is also called first-in-first-out (FIFO)
system.
Uses:
To implement printer spooler.
17. TREE
• A tree is a non-linear data structure
which consists of a collection of nodes
arranged in a hierarchical order.
Examples of Real Life:
• Family tree
• Table of contents of a book
• Computer file system
18. GRAPH
• A graph is a non-linear data structure which is a
collection of vertices (also called nodes) and edges
that connect these vertices.
Real life uses of graph:
Google Map
Facebook
World Wide Web
Course Pre-requisite
Circuit
Computer Networks
19. OPERATIONS PERFORMED ON DATA
STRUCTURE
Operations Description
Insertion Adding a new record to the structure.
Deletion Removing an item from the structure.
Traversing Accessing and processing each data item of the data structure exactly once
Searching Find the location of the key value within the data structure.
Sorting Arranging all the data items in a data structure either in ascending or in
descending order or in lexicographical order (for Strings).
Merging Combining the data items of two different sorted lists into a single sorted list.
20. WHAT IS ALGORITHM
• An algorithm is a set of well-defined instructions in sequence to solve a problem. Algorithms
are generally created independent of underlying languages, i.e. an algorithm can be
implemented in more than one programming language.
Each algorithm should have five characteristics:
• Input: The algorithm must take zero or more input.
• Output: The algorithm may produce one or more outputs.
• Definiteness: Each step of algorithm must be defined unambiguously.
• Effectiveness: A human should be able to calculate the exact values involved in the
procedure of the algorithm using paper & pencil. It must be possible to perform each step
of the algorithm correctly and a finite amount of time. It is not enough that each step is
definite, but it must also be feasible.
• Termination: An algorithm may terminate after a finite number of steps
21. AN ALGORITHM FOR MAKING A CUP
OF TEA.
• Put the teabag in a cup.
• Fill the kettle with water.
• Boil the water in the kettle.
• Pour some of the boiled water into the cup.
• Add milk to the cup.
• Add sugar to the cup.
• Stir the tea.
• Drink the tea.
23. TIME & SPACE COMPLEXITY
The performance of an algorithm is measured on the basis of following properties :
• Time Complexity- Time complexity of an algorithm quantifies the amount of time
taken by an algorithm to run as a function of the length of the input.
• Space Complexity-Space complexity of an algorithm quantifies the amount of space or
memory taken by an algorithm to run as a function of the length of the input.