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

FDS (Introduction - To - FDS)

FDS unit 1 Notes

Uploaded by

vidyadevi6996
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

FDS (Introduction - To - FDS)

FDS unit 1 Notes

Uploaded by

vidyadevi6996
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

UNIT 1

Introduction to Algorithm and


Data structure
Introduction
• Data structure:
– A scheme for organizing data in the memory of a
computer.
– A particular way of storing and organizing data in a
computer so that it can be used efficiently.
– The logical or mathematical model of a particular
organization of data is called data structure.
– Ex. lists, arrays, stacks, queues, heaps, trees, and graphs
– Data-> Collection of numbers, Characters and Symbols
– Information-> Combination of Data
Concept of Data Type
• Data Type:
• A data type is a method of interpreting a
pattern of bits.
• A data type represents a type of the data which
you can process using your computer program.
• Ex. Integer, Float, string, Char etc.
Data Types
Abstract Data Type
• Abstract data type:
• The process of providing only the essentials and hiding
the details is known as abstraction.
• ADT is a useful tool for specifying the logical properties
of a data type
• All implementation details are hidden
• ADT only mentions what operations are to be
performed but not how these operations will be
implemented.
• It gives an implementation-independent view
• Ex. List ADT, Stack ADT,
Classification of data types
Primitive Data structure
• These are basic structures and are directly operated
upon by the machine instructions.
• Have different representations on different computers,
Integer, Floating point numbers, character-constants,
string constants, pointers, etc.
• Examples:
– Float
– Integer
– Character
– Pointer
Integer
• What is an Integer?
– An integer defined as a whole number, not a
fraction number.
– The integer number can be positive, negative or
zero number.
– such as 10, 11, 0, -7, -67 and 5148 are all integers.
– Integer number can’t have decimal places.
– Therefore, when two integer numbers are added,
subtracted or multiplied, the result always comes as
an integer.
Float
• What is Float?
– Float is a tern in a data structure which is used in
the various programming language, for defining
the variable with a fractional value.
– The numbers created using of float variable
declaration will have decimal point.
– Ex. 23.67, 1.56 , 8.96 etc.
Character
• What is Character?
– Character in the data structure represents letter
and symbol such as a, B, f, R, “.” , “-” and
whitespace.
– Therefore, it can store the basic character set.
– It can hold one letter/symbol like n, F, d, etc.
characters can also be of different types.
Non-primitive data types
• Non-primitive data types:
– language provides a way of defining our own data
type. such data types are kept under the non-
primitive data structure category.
– More sophisticated data structure.
– These are derived from the primitive data
structure.
– Arrays, lists, and files are the example.
Array
• What is Arrays?
– An array is defined as it is a collection of items
stored at contiguous memory locations.
– we can also say that arrays are the set of
homogeneous data elements stored in RAM,
therefore, it can hold only one type of data.
– Therefore, the data may be all floating numbers or
all characters or all integers numbers.
Array
Lists
• What are Lists?
– A Lists is defined as it is a collection of a variable number of
data items.
– Lists or sequence is an abstract data type, which always
represents a countable number of ordered values.
– Every list element contains at least two fields, one field is
used for storing the data and another filed is used for storing
the address of the next element.
– Lists are an example of containers. as they contain other
values.
– If the same value occurs multiple times, then each
occurrence is considered a distinct item.
List
Files
• What is Files?
– Files contain information, and this information
stored permanently in the Hard Disk and Floppy
Disk, this disk also knows as a secondary storage
device.
– A file name always contains the primary and
secondary name and dot(.) is used for separating.
for understanding in a better way see the below
Diagram
– Example: new.doc, fds.pdf
File
Stack
• What is Stacks?
– A stack is a basic data structure, it’s defined as an ordered
collection of elements represented by a real physical stack or
pile.
– Linear data structure features insertion and deletion of items
take place at one end called top of the stack.
– The implementation of the stack also know as LIFO (Last in First
Out)
– These are the three basic concepts that can be performed on
stacks.
1) push (insert the items into a stack)
2) Pop (delete an item from the stack)
Stack
Queue
• What are Queues?
– Queue defined (FIFO) First In First Out type of data
structure.
– Queues are also the part of non-primitive linear
data structure.
– we can insert an element in a queue from the
REAR end and delete an element from the FRONT
end only.
Queue
Graphs
• What are the Graphs?
– There are different types of graphs :
• Connected Graph
• Non-Connected Graph
• Directed Graph
• Non-Directed Graph
– Graphs are the non-linear and non-primitive type of
data structure.
– Graph is representing the different types of physical
design structures such as used in Chemistry, physics,
maths & Engineering Science.
Graph
Trees
• What are the trees?
– In the classification of data structure, Trees also
come in the non-primitive and non-linear category
data structure
– Using tree we can represent a hierarchical
relationship between the data elements.
Trees
Classification of Non-primitive data structure
Linear data structure
• What is Linear data structure?
– It is a type of data structure where the arrangement of the data
follows a linear trend.
– The data elements are arranged linearly such that the element is
directly linked to its previous and the next elements.
– Traversal of the data is achieved through a single run only.
• Characteristics:
⮚ Data is stored and managed in a linear sequence.
⮚ Data elements in the sequence are linked to one after the other.
⮚ Implementation of the linear structure of data in a computer’s
memory is easy.
⮚ Array, queue. Stack, linked list, etc.
Advantage and Disadvantage of Linear data
structure
Advantages:
– Data is stored in memory in linear or sequential order.
– It use the pointer.
– It is easy to implement.
– Single level is involved.
– Eg:-array, link list, stack and queue.

Disadvantages:
• Poor utilization of the computer memory
• With the increase in the size of the data structure, the time
complexity of the structure increases.
• Memory utilization is in-effective.
Examples of Linear data structure
• Array:
– The same types of objects are stored sequentially in an array.
– The main idea of an array is that multiple data of the same
type can be stored together.
– Before storing the data in an array, the size of the array has to
be defined.
– Example
• Storing the marks for all the students in a class. Suppose there are
20 students, then the size of the array has to be mentioned as 20.
Marks of all the students can then be stored in the created array
without the need for creating separate variables for marks for every
student. Simple traversal of the array can lead to the access of the
elements.
Examples of Linear data structure
• Linked list
• The linked list is that type of data structure where separate objects
are stored sequentially.
• Every object stored in the data structure will have the data and a
reference to the next object.
• The last node of the linked list has a reference to null.
• The first element of the linked list is known as the head of the list.
• Types of linked list:
– Single Linked List
– A Double Linked List
– Circular linked List
Single linked list
Singly linked list:
1. Unidirectional, that is, it can be traversed in only one
direction from head to the last node (tail).
2. Each element in a linked list is called a node.
3. A single node contains data and a pointer to the next node
which helps in maintaining the structure of the list.
Double linked list
• Doubly linked list:
• Complex type of linked list in which a node contains a pointer to the
previous as well as the next node in the sequence.
• In a doubly linked list, a node consists of three parts: node data, pointer to
the next node in sequence (next pointer) , pointer to the previous node
(previous pointer).
Circular linked list
• A circular linked list:
• Variation of a singly linked list.
• In circular linked list the last node connects to the first node, so the link
part of the last node holds the first node's address.
• The circular linked list has no starting and ending node.
• We can traverse in any direction, i.e., either backward or forward.
Doubly Circular linked list
• Doubly circular linked list:
• The doubly circular linked list has the features of both the circular linked
list and doubly linked list.
• In Doubly circular linked list the last node is attached to the first node and
thus creates a circle.
• In doubly linked list each node holds the address of the previous node
also.
• Doubly circular linked contains three parts, i.e., two address parts and one
data part so its representation is similar to the doubly linked list.
Examples of Linear data structure
• Queue:
– First In First Out (FIFO) type of data structure
– In the case of a queue, the element that was added first is removed first.
– Both the end of the data structure is used for the insertion and the removal of
data.
– The two main operations governing the structure of the queue are enqueue,
and dequeue.
• Enqueue : Inserting an element is allowed to the collection of data
• Dequeue: Removal of elements is allowed, which is the first element in
the queue in this case.
– Queues are applied when multiple users are sharing the same resources and
they have to be served on the basis of who has come first on the server.
– Example of the queue: We can imagine a person waiting for the bus and
standing at the first position as the person that came to the queue first. This
person will be the first one who will get onto a bus, i.e. exit the queue.

You might also like