Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 65

Knowledge Management

and
Data Structure
Knowledge management and data
structure
• Data preprocessing is the first step of the
knowledge management process.
• Data in the data warehouse was preprocessed
and then fed to the knowledge management
tool.
• The historical data being preprocessed was
stored in a file.
• A Data structure refers to a scheme for
organizing related pieces of information.
Data Structure
• Data structure is a mathematical way for
storage of data in the computer memory.
• It is the way of storing and accessing the data
from the computer memory.
• So that large number of data is processed in
small interval of time.
Basic types of Data structure
• The basic types of data structures include:
• Files
• Lists
• Array
• Records
• Trees
• Tables
• Each of these basic structures has many
variations and allows different operations to be
performed on the data.
Types of Data Structure
There are two types of data structure
– Linear data structure
– Non linear data structure

Linear data structure


• When the data is to be stored in the memory in
linear form is called linear data structure.
• Array,
• List
–Stack, Queue, Circular Queue, Dequeue,
Link List.
Types of Data Structure
Non Linear Data Structure
• When the data is to be stored in the computer
memory in dispersed order is called non-linear
data structure.
• For example,
• Trees,
• Files,
• Graphs.
Classification of linear data structure
It can be classified into two types.
– Physical Data Structure
– Logical Data Structure

Physical Data Structure


When the data is to be stored in the computer
memory in proper order is called physical data
structure.
Classification of linear data structure
Logical Data Structure

• The two-dimensional array is called logical


data structure because we are not sure, that
in which format data in stored in the memory,
then we represent the data in the memory at
row major order or column major order, so
due to this reason it is called logical data
structure.
Operation Perform on Data Structure
• When data is proceeding then different type of
operation perform.
• Following are most important operation,
which play major role in data structure.
• Searching
• Sorting
• Insertion
• Deletion
• Merging
• Copying
• Traversing
Operation Perform on Data Structure
Traversing
Accessing of records is called traversing. It is
also known as visiting of records.
Searching: -
Finding the location of record with given value
is called Searching.
Sorting
The arrangement of data in ascending or
descending order is called sorting.
Operation Perform on Data Structure
Insertion
Adding new record to structure is called inserting.

Deletions
Removing a record or set of records form data structure is
called deleting process.

Merging
When two or more than two records are combined, this
process is called merging.

Copying
The creation of duplicate data item is called copying process.
Linear data structure

• Array,
• List
– Stack,
– Queue,
– Circular Queue
– Dequeue
– Link List etc.
Array
• Array is the collection of finite homogeneous type of
data, which are stored in successive memory locations.
• The memory locations are identifies by a name which is
called the array name.
• The data items of the array are called the elements of
array and each data item is stored in separate memory
location.
• Each memory location within the array is identifies by
its position value, which is called the index of the array.
Array
Types of array
There are two types of array.
• One dimensional array
• Two Dimensional array

One Dimensional Array (Linear Array)


• One-dimensional array represent the data in the
form of vector, list or linear form. It is used to
store similar type of data consisting of only one
row or column.
One Dimensional Array (Linear Array)
Two dimensional array
• Two-dimensional array represent the data in the
form of table or matrix.

• In two-dimensional array the storage of


elements can be take place by two techniques.

– Row Major Order


– Column Major Order
Row Major Order

• To understand the concept of row major


order, consider the following matrix of 2 X 3.
12 9 16
5 11 22
• Now the storage of above matrix in row major
order is
Column Major Order

• To understand the concept of column major


order, consider the following matrix of 2 X 3.
12 9 16
5 11 22
• Now the storage of above matrix in column
major order is
Linear data structure

• Array,
• List
– Stack,
– Queue,
– Circular Queue
– Dequeue
– Link List etc.
List
The arrangement of elements in some sequence is called
list. There are two types of list.
• Ordered List
• Unordered List 

Ordered List
– The proper sequence of elements is called ordered list.
– For example The days of week, the month of year, seasons of
year.

Unordered List
– In this type of list the storage of element is not take place in
proper order.
– For example Stack, Queue, Dequeue, Circular Queue, Link List
Linear data structure

• Array,
• List
– Stack,
– Queue,
– Circular Queue
– Dequeue
– Link List etc.
Stack
• Stack is that type of list in which insertion and
deletion of elements can take place from one
end. The end of stack is called Top pointer.

• Stack work on two principal.

– LIFO (Last In First Out)


– FILO (First In Last Out)
FIFO
LIFO
Operation on Stack
Different operation can be performed with stack.

Create Stack The creation of stack structure

Push Operation The insertion of element in the stack.

Pop Operation The Deletion of element from the stack

Full Stack If stack is full, False value is returned i.e Boolean
value

Empty Stack If stack is empty, True value is returned i.e


Boolean value
 
Two Major Operation of the Stack
Over Flow

• When the stack is full and new element is inserted/ Push


then overflow condition occur.

Under Flow

• When the stack is empty, and a deletion process is


performed the under flow condition occur.

Example
– Pile of Trays in Cafeteria
– Pile of books in Library
Linear data structure

• Array,
• List
– Stack,
– Queue,
– Circular Queue
– Dequeue
– Link List etc.
Queue
• Queue is that type of list in which insertion can take
place from one end called (Rear) and deletion can
take place from another end called (Front).
• Queue works on the principle of first in first out
(FIFO)
• List come First Serve and Last in last out (LILO).

Daily Life Example


• The number of cars at police check
• People purchase tickets from cinema make a queue.
• People deposits their bills in bank make a queue.
Operations on Queue
Different operations can be performed at queue as
 
Create Queue
By using this operation the structure of the queue is
generated.
 
Enqueue
The insertion of element in the queue is called enqueue.
 
Dequeue
The deletion of element from the queue is called dequeue.
Operations on Queue
Empty Queue
It returns Boolean value true, if queue is empty.

Full Queue
It returns Boolean value false, if queue is full.
 
Destroy Queue
This operation deletes all the elements of the
queue and also deletes the structure of queue
from the computer memory.
Major Operation on Queue
Overflow Condition
When no more elements can be inserted in
the queue then this condition is called
overflow condition.

Underflow Condition
When queue is empty and no more elements
can be deleted from the queue then this
condition is called underflow condition.
Linear data structure

• Array,
• List
– Stack,
– Queue,
– Circular Queue
– Dequeue
– Link List etc.
Circular Queue
• Circular queue provide flexible way for the
insertion of element in a circular way.
• In queue we are nor sure that when the rear
pointer goes to an end i.e Rear = N , overflow
condition occur, may be the same element from
the front are deleted, it is the major drawback of
queue.
• This drawback can be overcome with the help of
circular queue.
• In circular queue the insertion can be take place
by using this sequence 1,2,3, …… N
Circular Queue
Check for Underflow
When the front and rear pointer become equal that is
Front  Rear  0
Underflow condition may arise.

Check for Overflow


When Front = 1 and Rear = N then overflow condition
may arise. OR
When Front  Rear + 1 then overflow condition may
arise.
Linear data structure

• Array,
• List
– Stack,
– Queue,
– Circular Queue
– Dequeue
– Link List.
Dequeue
• It is a linear data structure. This queue is
called double ended queue.
• In this type of queue insertion and deletion of
elements can be take place from both ends.
• In this queue, insertion and deletion of
elements from Rear and Front can take place
on the principal of Right and Left pointer.
Two types of Dequeue
Input restricted queue
In this type of queue, insertion can take place
only from one end and deletion can take place
from both ends.

Output restricted queue


In this type of queue, insertion can take place
from both ends and deletion can take place
from one end.
Linear data structure

• Array,
• List
– Stack,
– Queue,
– Circular Queue
– Dequeue
– Link List.
Link list
A linked list is a data structure which can change during
execution.

–Successive elements are connected by pointers.


–Last element points to NULL.
–It can grow or shrink in size during execution of a
program.
–It can be made just as long as required.
–It does not waste memory space.
Types of list
– Linear single link list
– Circular link list
– Double linked list
Linear single link list
• It can be made just as long as sequence
• It does not waste memory space
Circular link list
• The pointer from the last element in the list
points back to the fist element.
Double linked list
• Pointers exist between adjacent nodes in both
directions.
• The list can be traversed either forward or
backward.
• Usually two pointers are maintained to keep
track of the list, head and tail.
Non Linear Data Structure

• Trees
• Files
• Graphs
Trees
• Trees are used to impose a hierarchical
structure on a collection of data items.
• For example, we need to impose a hierarchical
structure on a collection of data items while
preparing organizational charts and
genealogies to represent the syntactic
structure of a source program in compilers.
• So the study of trees as one of the data
structures is important.
Definition of a Tree
• A tree is a set of one or more nodes T such
that:
• There is a specially designated node called a
root
• The remaining nodes are partitioned into n
disjointed set of nodes T1, T2,…,Tn, each of
which is a tree.
Trees
• This is a tree because it is a set
of nodes {A,B,C,D,E,F,G,H,I},
with node A as a root node
• And the remaining nodes
partitioned into three disjointed
sets {B,G,H,I}, { C,E,F} and {D},
respectively.
• Each of these sets is a tree
because each satisfies the
aforementioned definition
properly.
Trees
• Even though this is a set of
nodes {A,B,C,D,E,F,G,H,I},
with node A as a root
node, this is not a tree
because the fact that node
E is shared makes it
impossible to partition
nodes B through I into
disjointed sets.
Trees
Degree of a Node of a Tree
The degree of a node of a tree is the number of sub trees having this
node as a root. A 1 B,C,D 0

Degree of a Tree
The degree of a tree is defined as the maximum of degree of the nodes
of the tree, that is, degree of tree = max (degree(node i)
for I = 1 to n)
Degree of a Tree 1

Level of the tree


The depth of the tree to be the maximum value of the level of the
node of the tree.
Level of the tree 3
Binary Trees
• A special class of trees: max degree for each node is
2
• Definition: A binary tree is a finite set of nodes that is
either empty or consists of a root and two disjoint
binary trees called the left sub tree and the right sub
tree.
Binary Trees
Non Linear Data Structure

• Trees
• Files
• Graphs
File
• Collection of logical related records is called file.
• It is a set of records that is stored on secondary
storage devices like magnetic tap, tape drives,
floppy disc, hard disc, flash etc, when created.
•  There are three types of files.
• Sequential File
• Index sequential file
• Random/ Relative file
Types of File
Sequential File
• In sequential file, the records are stored in sequential order, in
which they are inserted.
• This type of file is can be stored on magnetic tape, magnetic
disc and hard disc.

Indexed Sequential File


• In this file separate key is defined. The key uniquely identifies
the record.
• By using proper indexing the duplication of record is not
possible.
• In index sequential file, the records can be accessed in
sequential order also.
• Index sequential file cannot be processed by magnetic tape. It
can be processed by magnetic disc.
Types of Files
• Random/ Relative File
– In random file, the data can be stored randomly
and the record can be accessed randomly also.

– It is fast file processing as compared to other file


organization.

– Random file can be processed by magnetic disc.


Non Linear Data Structure

• Trees
• Files
• Graphs
Graphs
• A set of items connected by edges. Each item is called a
vertex or node. Formally, a graph is a set of vertices and
a binary relation between vertices, adjacency.

• A graph G can be defined as a pair (V,E),


• where V is a set of vertices, and E is a set of edges
between the two vertices.

• If the graph is undirected, the adjacency relation


defined by the edges is symmetric.

• If the graph does not allow self-loops, adjacency is


irreflexive.
Types of Graphs
Directed graph
• A graph edges are ordered
pairs of vertices. That is,
each edge can be followed
from one vertex to another
vertex.
• Also known as digraph,
oriented graph.

Undirected graph
• A graph whose edges are
unordered pairs of vertices.
That is, each edge connects
two vertices.
Types of Graphs
Dense graph
• A graph in which the
number of edges is close
to the possible number of
edges.

Sparse graph
• A graph in which the
number of edges is much
less than the possible
number of edges.
Types of Graphs
Labeled Graph
• A graph which has labels
associated with each edge or
each vertex.

Weighted graph
• A graph having a weight, or
number, associated with
each edge. Some algorithms
require all weights to be
nonnegative, integral,
positive, etc.
Graphs
• Graphs are so general that many other data
structures, such as trees, are just special kinds
of graphs.

• A graph is like a road map. Cities are vertices.


Roads from city to city are edges.
Array and list
•Array is collection of • List is collection of
homogeneous elements. heterogeneous elements.

•For Array memory • For List memory allocated is


allocated is static and dynamic and Random.
continuous.

•User need not have to • User has to keep in Track of


keep in track of next next location where memory
memory allocation. is allocated.

•Array size should be • list size can be determined


specified. at run time also.
Stack and Queue
•A stack is generally First In, • Queue is First In First Out.
Last Out.
• Queue insertion at the rear
•Item can be added or
and deletion from the front.
removed only at one end in
stack.
• Queue are 'enqueue' and
•The basic operation of stack 'dequeue'.
are 'push' and 'pop’
Trees and Graph
• A tree is a connected graph • A tree is a specialized case of
with no circuits and no self a graph.
loops.
• A circuit is alternating
• As a tree does not contain sequence of edges and
any loops and is still vertices where in edges are
connected, it is also called a not repeated, vertices may
minimally connected graph i.e. be and starting and ending
there is just one path between vertices are the same this
any 2 vertices. forms a loop.

You might also like