DSU Project

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

A

PROJECT REPORT

ON

“Types of sorting”
SUBMITTED BY
Pawar Abhinav Sujit [134]
Paithankar pratik kishor [129]
Sadawarte Gaurav Shrishankar
[144]

Under the guidance of

Miss. V.A Parjane

DEPARTMENT OF COMPUTER TECHNOLOGY


Sanjivani Rural Education Society’s

SANJIVANI K. B. P. POLYTECHNIC
KOPARGAON – 423601, DIST-AHMADNAGAR
2022-2023

1
Sanjivani Rural Education Society’s

SANJIVANI K. B. P. POLYTECHNIC
DEPARTMENT OF COMPUTER TECHNOLOGY

CERTIFICATE
This is to certify that the Project report entitled

“Types of sorting”
Submitted By

Pawar Abhinav Sujit [134]


Paithankar pratik kishor [129]
Sadawarte Gaurav Shrishankar [144]

Under our supervision and guidance for partial fulfillment of the requirement for

Diploma in Computer` Technology affiliated to

Maharashtra State Board of Technical Education,

Mumbai For academic year

2022-2023

Mrs. V.A.Parjane Mr. G. N. Jorvekar


(Project Guide) (H.O.D)

2
ACKNOWLEDGEMENT
First and the foremost we, express my deep sense of gratitude, sincere thanks and deep
sense of appreciation to Project Guide Mr. V. A. Parjane , Department of Computer
Technology, Sanjivani K.B.P. Polytechnic, Kopargaon. Your availability at any time
throughout the year, valuable guidance, opinion, view, comments, critics, encouragement,
and support tremendously boosted this project work.

Lots of thanks to Mr. G. N. Jorvekar, Head Of Department Computer Technology


Department, for providing us the best support we ever had. We like to express my sincere
gratitude to Mr. A.R. Mirikar, Principal, Sanjivani K. B. P. Polytechnic, Kopargaon for
providing a great platform to complete the project within the scheduled time.

We are also thankful to all the faculty members, Computer Technology Department,
Sanjivani K. B. P. Polytechnic, Kopargaon for giving comments for improvement of work,
encouragement and help during completion of the Project.

Last but not the least, we should say thanks from our bottom of heart to my Family &
Friends for their never ending love, help, and support in so many ways through all this time.
Thank you so much.

Mst. Pawar Abhinav S.


Mst. Sadawarte GauravS.
Mst. Paithankar Pratik
K.
Diploma in Computer Technology.
Sanjivani K. B. P. Polytechnic,
Kopargaon.

3
INDEX
CHAP CONTENTS PAGE
T ER NO.
1. Introduction. 5
7. Source Code 16
8. Output 17
9. Reference 18

4
1. INTRODUCTION.

Traversing a tree involves iterating over all nodes in some manner. Because from a
given node there is more than one possible next node (it is not a linear data structure),
then, assuming sequential computation (not parallel), some nodes must be deferred—
stored in some way for later visiting. This is often done via a stack (LIFO)
or queue (FIFO). As a tree is a self-referential (recursively defined) data structure,
traversal can be defined by recursion or, more subtly, corecursion, in a natural and
clear fashion; in these cases the deferred nodes are stored implicitly in the call stack.
Depth-first search is easily implemented via a stack, including recursively (via the call
stack), while breadth-first search is easily implemented via a queue, including
corecursively.

Pre-order, NLR

1. Visit the current node (in the figure: position red).


2. Recursively traverse the current node's left subtree.
3. Recursively traverse the current node's right subtree.
The pre-order traversal is a topologically sorted one, because a parent node is processed before any of its child
nodes is done.
Post-order, LRN

1. Recursively traverse the current node's left subtree.


2. Recursively traverse the current node's right subtree.
3. Visit the current node (in the figure: position blue).
Post-order traversal can be useful to get postfix expression of a binary expression tree.
In-order, LNR

1. Recursively traverse the current node's left subtree.


2. Visit the current node (in the figure: position green).
3. Recursively traverse the current node's right subtree.
In a binary search tree ordered such that in each node the key is greater than all keys in its left subtree and less than
all keys in its right subtree, in-order traversal retrieves the keys in ascending sorted order.[7]

5
Source code
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
struct BTnode
{
int data;
struct BTnode* leftNode;
struct BTnode* rightNode;
};

void inorder(struct BTnode* rootNode)


{
if (rootNode == NULL) return;
inorder(rootNode->leftNode);
printf("%d ->", rootNode-
>data); inorder(rootNode-
>rightNode);
}

void preorder(struct BTnode* rootNode)


{
if (rootNode == NULL) return;
printf("%d ->", rootNode-
>data); preorder(rootNode-
>leftNode); preorder(rootNode-
>rightNode);
}

void postorder(struct BTnode* rootNode)


{
if (rootNode == NULL) return;
postorder(rootNode->leftNode);
postorder(rootNode-
>rightNode); printf("%d ->",
rootNode->data);
}

struct BTnode* createNode(value)


{
struct BTnode* newNode = malloc(sizeof(struct
BTnode)); newNode->data = value;
newNode->leftNode = NULL;
newNode->rightNode =
NULL; return newNode;
}

struct BTnode* insertLeftNode(struct BTnode* rootNode, int value)


{
rootNode->leftNode = createNode(value);
return rootNode->leftNode;
}

struct BTnode* insertRightNode(struct BTnode* rootNode, int value)


6
{
rootNode->rightNode = createNode(value);

7
return rootNode->rightNode;
}

int main()
{
struct BTnode* rootNode = createNode(7);
clrscr();
insertLeftNode(rootNode, 4);
insertRightNode(rootNode, 8);
insertLeftNode(rootNode->leftNode, 1);
insertRightNode(rootNode->rightNode, 5);
insertLeftNode(rootNode->leftNode, 6);
insertRightNode(rootNode->rightNode, 3);
printf("Inorder \n");
inorder(rootNode);
printf("\nPreorder \n");
preorder(rootNode);
printf("\nPostorder \n");
postorder(rootNode);
getch();
return 0;
}

8
OutPut

9
References

https:\\www.google.com https:\\
www.m.youtube.com https:\\
www.developerinsider.co

1
0

You might also like