DREAM VALLEY COLLEGE FOR GIRLS CENTRE FOR EDUCATIONAL EXECELLENCE ADD:-Near Railway spring factory,...

86
DREAM VALLEY COLLEGE FOR GIRLS CENTRE FOR EDUCATIONAL EXECELLENCE ADD:-Near Railway spring factory, Sitholi , Gwalior (MP) AFFILATED TO:-JIWAJI UNIVERSITY (strictly according to jiwaji university)

Transcript of DREAM VALLEY COLLEGE FOR GIRLS CENTRE FOR EDUCATIONAL EXECELLENCE ADD:-Near Railway spring factory,...

DREAM VALLEY COLLEGE

FOR GIRLS

CENTRE FOR EDUCATIONAL EXECELLENCE

ADD:-Near Railway spring factory, Sitholi , Gwalior (MP)

AFFILATED TO:-JIWAJI UNIVERSITY

(strictly according to jiwaji university)

PPT PRESENTATION On

DATA STRUCTURE

BCA 2nd semester

PPT PRESENTATION On

DATA STRUCTURE

BCA 2nd semester

ARRAY

STACK

LINKEDLIST

QUEUES

TREES

GRAPHS

ARRAY

STACK

LINKEDLIST

QUEUES

TREES

GRAPHS

--

• Array is vital part of Array is vital part of programming. It allows programming. It allows user to stored multiple user to stored multiple value in single variable. value in single variable. Array stored in contiguous Array stored in contiguous form in memory.form in memory.

ABCFED

OR OR

INSERTION OF ELEMENT IN THE ARRAYINSERTION OF ELEMENT IN THE ARRAY

•Traversal:- processing each element in the array.

•Search:- finding a location of an element in the given value.

•Insertion:- adding new element in array.

•deletion:- removing an element in array.

•Sorting:- arranging element in array.

•Merging:- combining two array in single array.

•Reversing:- reversing the element of array.

AA BB CC DD EE FF

DELETION OF ELEMENT IN THE ARRAYDELETION OF ELEMENT IN THE ARRAY

Delete (F) from the array.Delete (F) from the array.

Delete (E) from the array.Delete (E) from the array.

Delete (D) from the array.Delete (D) from the array.

Delete (C) from the array.Delete (C) from the array.

Delete (B) from the array.Delete (B) from the array.

Delete (A) from the array.Delete (A) from the array.

Binary tree->binary tree Binary tree->binary tree is defined as finite set of is defined as finite set of node in which number of node in which number of

the children the children of a node of a node should not exceed more should not exceed more than two .it means the than two .it means the

degree of binary tree not degree of binary tree not then greater then twothen greater then two..

BINARY TREE

A

B C

D EF

G

TYPES OF TYPES OF BINARY TREEBINARY TREE

In every non terminal In every non terminal node in a binary tree node in a binary tree

consists of non empty left consists of non empty left subtree and right subtree and right

subtree ,then such a tree subtree ,then such a tree is called strictly binary is called strictly binary

treetree..

STRICTLY BINARY TREE

A

B

D E

C

FG

Complete binary treeComplete binary tree

The level of all nodes of complete The level of all nodes of complete binary tree is equalbinary tree is equal..

A

B C

DE F

G

0

1

2

20 7 26 8 186 28 20

20 is a root node of this tree

> 7

7 is compared with 20

7

> 26

26 is compared with 20

26

> 8

> 8

8

> 6

> 6

6

< 18

< 18

18

> 28

> 28

28

To traverse a non empty binary tree in in-order following three operations are performed

Traverse the left sub –tree in in-order

Visit the root node

Traverse the right sub-tree in in-order

A

B C

D EF G

TRVERSE STARTS FROM THE ROOT NODE

Since D is the leaf node ,it gets printed ,which is the left child of D.

D

Now B gets printed as it is the parent of the node D

B

Since E is the leaf node ,it gets printed ,which is right child of B

E

Now A gets printed as it is the parent of the node B

A

Since F is the leaf node ,it gets printed ,which is the left child of c

F

Now C gets printed as it is the parent of the node F

C

Since G is leaf node ,it gets printed ,which the right child of C

G

In order traversal

Post -order traversalPrinting the data in post-order traversal

To traverse a non empty binary tree in in-order following three operations are performed Traverse the left sub –tree in in-orderVisit the root nodeTraverse the right sub-tree in in-order

A

B C

DE F G

Now A gets printed as it is the parent of the node B

Now C gets printed as it is the parent of the node FSince D is the leaf node ,it gets printed ,which is the left child of D.TRVERSE STARTS FROM THE ROOT NODENow B gets printed as it is the parent of the node D

D E B

Now F gets printed as it is the left child of C

F G C A

Since E is the leaf node ,it gets printed ,which is right child of BNow G gets printed ,as it is the right child of C

a non empty binary tree in pre-order following three operations are performed To traverse Visit the root nodeTraverse the left sub –tree in pre-orderTraverse the right sub-tree in pre-order

Pre-order traversal

A

B C

D EF G

Printing the data in pre-order traversal

Traversal starts from the root nodeThe data at the root node i.e. A gets printed

A

Since D is the leaf node ,it gets printed ,which is the left child of B.

D

Now B gets printed as it is the parent of the node D

B

Since E is the leaf node ,it gets printed ,

which is right child of B

E

Now C gets printed as it is the parent of

the node F

C

Since F is the leaf node ,it gets printed ,which is the left child of c

F

Since G is leaf node ,it gets printed ,

which the right child of C

G

Representation of a binary trees in Representation of a binary trees in memorymemory

->there are two ways by which we can ->there are two ways by which we can represent a binary treerepresent a binary tree

BINARY TREE CAN BE REPRESENTED BY LINKS

WHERE EACH NODE CONTAINS THE ADDRESS OF

THE LEFT CHILD AND THE RIGHT CHILD

LINKED LIST REPRESENTATION

LEFTDATARIGHT

ABCDEHFG

AR

ABCDEF

LC

123456

RC

268497

ARRAY

PPT PRESENTATION ONSTACKDATA STRUCTURE

BCA 2nd semesterDept. of computer science

Presented by:- Guided by:-

RICHA MITTAL HARISH SIR RANI KUSHWAH

• Introduction .

• Working of stack

• Push operation performed on stack

• Pop operation performed on stack

• Infix to prefix

• Infix to postfix

• Prefix to postfix

• Postfix to infix

A Stack is a linear collection of data in which new item may be inserted and deleted at one end. It

sometimes called LIFO and push down list .

A stack is usually represented by computer by block of memory cells. Thus, stack data structure implemented (LIFO) property. The situation of LIFO may be compared as the plates of cafeteria

where every new plate will added at the top.

INTRODUCTION TO STACK

Working of stackStacks associated with two basic operation i.e

PUSH and POP.

Push function means addition of element to the stack.

Pop function means remove an element from the top op the stack.

2341253612 Push Operation on stack

( PUSH ) INSERT 41 TO STACK

( PUSH ) INSERT 23 TO STACK

( PUSH ) INSERT 25 TO STACK

( PUSH ) INSERT 36 TO STACK

( PUSH ) INSERT 12 TO STACK

23

41

25

36

12

POP OPERATION ON STACK

( POP ) DELETE 12 FROM THE STACK

( POP ) DELETE 36 FROM THE STACK( POP ) DELETE 25 FROM THE STACK( POP ) DELETE 23 FROM THE STACK( POP ) DELETE 41 FROM THE STACK

EXPRESSION :- A + B * C

C * B + Ascan

CONVERSION OF INFIX TO PREFIX NOTATION

Character (C) scannedOperator(*) scanned

Push (*) into the stack

Character (B) scannedPriority of(*)is higher than (+),so(*) operator is poped from the stack

Character(A) Scanned

Pop(+) from the stack

CONVERSION OF INFIX TO POSTFIX NOTATION

EXPRESSION :- A + B * C

A + B * CSCAN

Character(A) scannedOperator(+)

scannedCharacter (B)

scanned

Operator (*) scanned

Character (c) Scanned

Priority of (*) is high, pop(*) from

the stack

pop (+) from the stack

CONVERSION OF PREFIX TO POSTFIX NOTATION

EXPRESSION :- + A * B C

CB*A+scan

OPERATOR (+)SCANNED

CHARACTER (A) SCANNED

OPERATOR (*)SCANNED

CHARACTER(B) SCANNEDCHARACTER (C)SCANNED

Priority of (*) is higher than (+) ,pop

(*) from the stack

Pop (+) from the stack

CONVERSION OF POSTFIX TO INFIX NOTATION

EXPRESSION :- A B + C *SCAN A B + C *

Operator(*) scanned, push to the stack

Character (C) scanned

Operator(+) scanned

Priority of (*) is higher than (+),so (*) is pop from the stack

Push (+) to the stack

Scanned character (B)

Pop (+) from the stack

Character (A) scanned

• CONCEPT

• OPERATIONS ON QUEUE

CONCEPT

LINEAR DATA STRUCTURE

PRINCIPLE :- First in First out

DEFINATION :- Ordered collection of items in a linear way.

QUEUE AS A SINGLE LINE

QUEUE ON GAME STATION

OPERATIONS OF QUEUE

• INSERT at Front or Rear end

• DELETE at Front or Rear end

FIRST OPERATIONS OF Q

• INSERT OPERATION:- first of all, we assume three elements A,B,C….. And added at Front and Rear end.

B CA

• Now, we inserting a new element in this function this is called a insert function at Front and Rear end.

A B CD

SECOND OPERATION OF Q

• DELETE OPERATION:- In this function, we deleting a new element which was added in insert function at Front end. Now, see in figure –

D A B C

GRAPHSIE…..

IN COMPUTER SCIENCE,GRAPH IS USE TO CREATE

NETWORKING! BE IT ANY WALK OF LIFE THAT’S THE KEY WORD TODAY BETTER YOUR NETWORK,FARTHER YOU WOULD REACH AND FUTHER YOU REPLACE YOUR TENTACLES BETTER WOULD YOU NETWORK, AND THE CRUX OF BUILDING AND MANAGING A NETWORK IS HIDDEN IN A SUBJECT AS INNOCUOUS AS DATA STRUCTURE IN A TOPIC CALLED GRAPHS

GRAPHS• THIS CONCEPT INTRODUCE

IMPORTANT MATHAMATICAL STRUCTURE CALLED GRAPHS

• APPLICATION IN SUBJECT AS DIVERSE AS SOCIOLOGY,CHEMISTRY GEOGRAPHY AND ELECTRICALLY ENGINEERING

NOW A DAYS MANY APPLICATION RELATED WITH COMPUTATION RELATED WITH COMPUTATION CAN BE MANAGED EFFICIENTLY WITH GRAPH DATA STRUCTURE

Vertices in the graph might represent computer instollation, edges represent connection between computers.where we want to allow message from any computer to get any other possibility with routing through intermidiate computer with minimum cost of connection

vertices in a graph are cities and edges are root between cities we want to service a connected set of cities with minimum cost

TYPES OF GRAPHS

• DIRECTED GRAPH

• UNDIRECTED GRAPHIN THIS TYPE OF GRAPH PATH IS SPECIFIED THAT TYPE OF GRAPH IS CALLED DIRECTED GRAPH

IN THIS TYPE OF GRAPH PATH IS NOT SPECIFIED IN THIS TYPE OF GRAPH THIS TYPE OF GRAPH IS CALLED UNDIRECTED GRAPH

CONNECTEDPATH

THERE ARE SEVERAL UNDIRECTED GRAPH.TWO VERTICES IN AN UNDIRECTED GRAPH IS CALLED ADJACENT IF THERE IS AN EDGE OFROM FRIST TO THE SECOND ADJACENT

CONNECTED

DISCONNECTED

PATHCYCLE

TREE

THANK YOU

Link list as data

structure

LINK LISTDefinition:

In computer science linked list is a data structure that consist of a sequence of data record such that in each record there is a

field that contains a reference of next record in a sequence

• Link list are special list of some data element link to one another. each element in link list called a node. Each node in a link list must contain at least two fields. An information field and next address field. The information field contain the actual element on the list which may be a integer, character, string or a large records.

A linked list consists of several nodes.

Each node consists of a data part and a link part.

Node

Data Link

Use of Linked List

Linked list as a data structure was used to solve many computer problem with a language called IPL. The major use of linked list to develop

1- Artificial intelligence

2- Chess Program

3- General Problem Solver

Advantage of link list

• Link list are dynamic data structure.• Efficient memory utilization that is memory is not

pre allocated memory allocated . When ever it is required and is de allocated when it is no longer required.

• Insertion and deletion are easier and efficient• Many complex application can easily handle with

link list.

Disadvantage of link list

• 1.many complex required because each node contain more fields.

• 2.access to a particular node is little bit cumber some and time consuming.

Building a linked listDataLink

70 NULL

100

80 NULL

200

90 NULL

300

300200

10 20 30

100 200 300

NULL

This is linked list of 3 nodes

Allocate memory for a new node

700

Set 99 value in data part of new node

99

Set link part of a new node ,with the address of first node

Adding a new node at the beginning

DELETION OF A NODE IN A LINK LIST

45 56 80 75

200 300 400 500

Initially link contain four nodes.Set links to the node.

Delete third node from the list

null

Set value to the nodes

FREE THE MEMORY OCCUPIED BY THIRD NODE

Types of link list

• Basically four types of link list :

• 1 singly link list.

• 2 doubly link list.

• 3 circular link list.

• 4 doubly and circular link list.

Singly link list

• A singly link list is one in which all nodes are linked together in same sequential manner . It is also called linear link list . It has the beginning and the end. The main with this list is that we cant access the previous node from the current node. This problem can be over come with link list . In this list each node divided in to two parts that is INFO AND NEXT.

SINGLY LINK LIST

STARTSTART AA .. .. XX

INFO PARTINFO PART ADDRESS PARTADDRESS PART

BB CC

Doubly link list

• A doubly link list is one in which all nodes are linked together by multiple link which is used in accessing next node and previous node from the curve node in the list .Each node in a doubly link list field to the left node and the right node .This help to traversed the list in the forward direction and the backward direction .So doubly link list provide bi directional traversing .each node in a doubly list is divided in three parts.

• INFO: To contain the information .• NEXT: To contain the pointer to the next node.• BACK :To contain the pointer to the previous node.

DOUBLY LINK LIST

BACKBACK INFOINFO NEXT NEXT

STARTSTART .. AA .. .. BB .. .. CC XX

Circular link list

• A circular link list is one which having no of beginning and no of end . A singly link list in which the link field of the last node contain the address of the first node of the list .That is the last field of the last node does not contain the null pointer rather it point back to the beginning of the link list.

CIRCULAR LINK LIST

STARTSTART AA BB CC.. .. ..

DOUBLY CIRCULAR LINK LIST

• A doubly circular link list is one which has both the successor pointer and procedure pointer in circular manner .A dell is a variation of doubly link list

DOUBLY CIRCULAR LINK LIST

STARTSTART .. AA .. .. .. .. CC ..BB