0% found this document useful (0 votes)
31 views29 pages

Dsu Project

Uploaded by

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

Dsu Project

Uploaded by

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

G.V.

ACHARYA
POLYTECHNIC, SHELU

Acharya Technical Education Campus, Raigad, Shelu, Maharashtra 410201

RREPORT ON
SORTING
SUBJECT
DATA STRUCTURES USING 'C'
SUBJECT CODE
22317
PROJECT GUIDE
DIKSHIKA BHUNDERE
ACADEMIC YEAR:2023-24

1
MAHARASHTRA STATE BOARD OF
TECHNICAL EDUCATION

This is to certify that Mr./Mrs NAKSHATRA PAWAR


Of semester – III of diploma in COMPUTER ENGINEERING of institute,
G.V.ACHARAYA POLYTECHNIC, SHELU has completed the Micro project
satisfactorily in subject - DATA STRUCTURES USING 'C' ON SORTING for the
academic year 2023-24 as prescribed in the curriculum.

Place: SHELU
Date:

ENROLLMENT NO.:2211440058

SUBJECT TEACHER HEAD OF THE DEPARTMENT PRINCIPAL


(Mrs. DIKSHIKA BHUNDERE) (Mrs. Madhura Mahindrikar)

2
MAHARASHTRA STATE BOARD OF
TECHNICAL EDUCATION

This is to certify that Mr./Mrs HARSHADA HINWAR


Of semester – III of diploma in COMPUTER ENGINEERING of institute,
G.V.ACHARAYA POLYTECHNIC, SHELU has completed the Micro project
satisfactorily in subject - DATA STRUCTURES USING 'C' ON SORTING for the
academic year 2023-24 as prescribed in the curriculum.

Place: SHELU
Date:
ENROLLMENT NO.:2211440045

SUBJECT TEACHER HEAD OF THE DEPARTMENT PRINCIPAL


(Mrs. DIKSHIKA BHUNDERE) (Mrs. Madhura Mahindrikar)

3
MAHARASHTRA STATE BOARD OF
TECHNICAL EDUCATION

This is to certify that Mr./Mrs SAKSHI NAYAKAWDI


Of semester – III of diploma in COMPUTER ENGINEERING of institute,
G.V.ACHARAYA POLYTECHNIC, SHELU has completed the Micro project
satisfactorily in subject - DATA STRUCTURES USING 'C' ON SORTING for the
academic year 2023-24 as prescribed in the curriculum.

Place: SHELU
Date:

ENROLLMENT NO.:2211440059

SUBJECT TEACHER HEAD OF THE DEPARTMENT PRINCIPAL


(Mrs. DIKSHIKA BHUNDERE) (Mrs. Madhura Mahindrikar)

4
MAHARASHTRA STATE BOARD OF
TECHNICAL EDUCATION

This is to certify that Mr./Mrs PRANAYA LAD


Of semester – III of diploma in COMPUTER ENGINEERING of institute,
G.V.ACHARAYA POLYTECHNIC, SHELU has completed the Micro project
satisfactorily in subject - DATA STRUCTURES USING 'C' ON SORTING for the
academic year 2023-24 as prescribed in the curriculum.

Place: SHELU
Date:

ENROLLMENT NO.:2211440032

SUBJECT TEACHER HEAD OF THE DEPARTMENT PRINCIPAL


(Mrs. DIKSHIKA BHUNDERE) (Mrs. Madhura Mahindrikar)

GROUP MEMBERS
ROLL NO. STUDENT NAME ENROLLMENT BRANCH

5
NO.
13 HARSHADA 2211440045 CO
HINWAR
25 SAKSHI 2211440059 CO
NAYAKAWDI
02 PRANAYA LAD 2211440032 CO
24 NAKSHATRA 2211440058 CO
PAWAR

ACKNOWLEDGEMENT

This project work titled “ SORTING “ is a part of curriculum as prescribed by


MSBTE.

6
We really thankful to our principal……………and the HOD MADHURA
MAHINDRIKAR, Computer Department, G. V. Acharya Polytechnic. Shelu for his
invaluable guidance and assistance, without which the accomplishment of the task
would have never been possible.

We are also thankful to our Guide Mrs. Dikshika Bhundere for this opportunity to
explore into the real world and realize the interrelation without which a project
can never progress.
We are also thankful to parents, friend and all staff of Computer Department, for
providing us relevant information and necessary classifications, and great support.

INDEX
SR NO. TOPIC NAME PAGE NO.

1 ACTION PLAN 9

2 RESOURCE REQUIRED 10

7
3 INTRODUCTION 11

4 TYPES OF SORTING 12-14

5 DIFFERENT SORTING ALGORITHMS 15-17

6 PROGRAMS 19-22

7 CONCLUSION 23

8 REFERENCES 24

ACTION PLAN
Sr. Details of Activity Plan Starting Plan Name of
No Finish Responsible
Date
Date Member
1. Searching the topic 20th Nov 20th Nov PRANAYA
for Micro - project LAD

2. Collect information 22nd Nov 22nd Nov HARSHADA


from the internet and HINWAR
textbook
3. Collect information 23rd Nov 23rd Nov SAKSHI

8
from the Data NAYAKAWDI
Structure Using C
22317 reference
books
4. Arrange all 25th Nov 27th Nov NAKSHATRA
information in MS PAWAR
word
5. Prepare a report on it 29th Nov 2nd Dec NAKSHATRA
Using MS word PAWAR
6. Print micro project 9th Dec 9th Dec SAKSHI
NAYAKAWDI

RESOURCE REQUIRED
Sr. Name of resources Material Specifications Quantity
No
1. Computer System Windows 7, 2 1
GB RAM
2. Internet Wifi 1
3. Textbook Data Structure 1
Using C
Language

9
INTRODUCTION

• Sorting is the process of ordering or arranging a given collection of


elements in dome particular order. We can sort a collection of
numbers in ascending (increasing) or descending (decreasing)
order.

• Sorting refers to rearrangement of a given array or list of elements


according to a comparison operator on the elements. The
comparison operator.

• Sorting and matching things helps develop visual perceptual skills,


thinking and memory skills. These important brain skills help with
attention and problem-solving.

• Sorting algorithms take lists of items as input data, perform


specific operations on those lists and deliver ordered arrays as
output.

10
TYPES OF SORTING

1. Selection sort.
Selection Sort is a simple comparison-based sorting algorithm. It
repeatedly selects the minimum (or maximum) element from the
unsorted portion and swaps it with the first elements.

Example
Input: [64,25,12,11]
Find the minimum element(11) and swap it with the first element:
[11, 25, 12, 22, 64].
Repeat the process until the entire array is sorted.

2. Bubble Sort.
Bubble Sort is a simple comparison-based sorting algorithm. It
repeatedly steps through the lists, compares adjacent elements,
and swaps them if they are in the wrong order.

Example

Input: [64, 34, 25, 12, 22, 11, 90]

Compare adjacent elements and swap if necessary .


After the first pass: [34, 25, 12, 22, 11, 64, 90].
Continue this process for subsequent passes until the array is sorted.

11
3. Insertion Sort.
Insertion sort is a simple comparison-based sorting algorithm that
builds the final sorted array one item at a time.
It takes an element from the unsorted part and inserts it into it’s
correct position in the sorted part.

Example

Input: [64, 34, 25, 12, 22, 11, 90].


Start with the first element and insert it in the correct position:
[34, 64, 25, 12, 22, 11, 90].
Continue this process for subsequent elements until the array is sorted.
These sorting algorithms have different time complexities and are suitable
for different scenarios, depending on the size and characteristics of the data
to be sorted.

4. Radix Sort.
Radix sort is a non-comparative integer sorting algorithm.
It sorts by processing individual digits or radix position of the
numbers.

Example

Input: [170, 45, 75, 90, 802, 24, 2, 66].


Starts by sorting by the least significant digit (units place): [802, 2, 24,45, 66,
170, 75, 90].
Continue this process until the most significant digit: [2, 24, 45, 66, 75,
90,170,802].

12
5. Quick Sort.
Quick sort is a divide-and-conquer sorting algorithm.
It selects a ‘pivot’ element and partitions the array into two sub-
arrays: elements less than the pivot and elements greater than the
pivot.
Recursively sort the sub-arrays.

Example

Input: [5, 2, 9, 3, 6].


Choose 5 as the pivot.
After the first partition : [2,3]
(elements less than 5) and [9,6]
(elements greater than5).
Recursively sort the sub-arrays, and you get the sorted array:[2, 3, 5, 6, 9].

13
DIFFERENT TYPES OF ALGORITHM

1. Selection sort algorithm

Step 1: Set min=0.


Step 2: Search minimum element in the list.
Step 3: Swap with value at location min.
Step 4: Increase min to point to next element.
Step 5: Repeat until list is sorted.

2. Bubble sort algorithm

Step 1: Read the number of element say ‘n’


Step 2: Sorted the element in array set p1 and pass=p-1
Step 3: Set i=0.
Step 4: Compare two adjacent element a[i] with a[i++].
Step 5: If a[i] is < a[i++] then interchange both element.
Step 6: Increment value of i
Step 7: Repeat step no.4 and 5 for is n-1.
Step 8: Increment p that is p= p+1.
Step 9: If p<= passes then go to step 3.
Step 10: Print the sorted array.
Step 10: Stop.

3. Insertion sort algorithm

14
Step 1: Insert (A, pos, value)
Step 2: i=pos-1
Step 3: while (i>0 and A[i]> value) do
Step 4: A[i+1]=A[i]
Step 5: i= i-1
Step 6: A[i+1]= value
Step 7: End

4. Radix sort algorithm


Step 1: Find the largest number in the array as LARGE.
Step 2: [INITIALIZE] Set NOP – Number of digits in LARGE.
Step 3: Set pass-0
Step 4: Repeat step 5 while pass<= NOP-1.
Step 5: set i=0 and initialize the bucket.
Step 6: Repeat step 7 to 9 while i<n-1.
Step 7: Set digit= digit at pass th place in A[i]
Step 8: Add A[i] to bucket numbered digit.
Step 9: Increment bucket count for bucket number digit
( End of loop)
Step 10: Collects the numbers in the bucket ( End of the loop)
Step 11: End

5. Quick sort algorithm

15
Step 1:
Step 2:
Step 3:
Step 4:
Step 5:

SORTING PROGRAM

16
• Graphs can be represented through matrix (array) in computer
system's memory. This is sequential in nature. This type of
representation is called sequential representation of graphs.

• A graph can be comfortably represented using an adjacency matrix


implemented through a two- dimensional array. This
representation of graphs is also called as static representation.
(static graph).

• Graphs can be represented using matrices. Adjacency matrix is n x


n matrix A. Each element of "A' is either zero or one.

ASSUMPTIONS

G Graph

17
V Set of Vertices

(i,j) Edge connecting Vi and Vj

A[i][j] Adjacency matrix element

i,j Vertices

• If G is Directed Graph:
A[i][j]={1 if (i,j) exists

0 otherwise

• If G is Undirected Graph:
A[i][j]={1 if (i,j) or (j,i) exists

0 otherwise

PROGRAMS

 Program to represent graph as adjacency matrix.

18
#include<stdio.h> #define

MAX 10

void degree(int adj[][MAX],int x,int n)

int I,incount=0, outcount =0; for(i=0;i<n;i++)

if(adj[x][i] ==1)

outcount++; if(adj[i][x]

==1) incount++;

printf(“The indegree of the node %d is %d\n”,x,incount++); printf(“The

outdegree of the node %d is %d\n”,x,outdegree++);

int main()

int adj[MAX][MAX],n,I,j; setbuf(stdout, NULL);

printf(“Enter the total number of nodes in graph”);

scanf(“%d”,&n);

19
for(i=0;i<n;i++) for(j=0;j<n;j+

+)

printf(“Enter Edge from %d to %d,(1: Edge 0: no edge) \n”,i,j);

scanf(“%d”,&adj[i][j]);

for(i=0;i<n;i++)

degree(adj,I,n);

return 0;

Output:

20
 Program for direct graph.
#include <stdio.h>

#include <stdlib.h>

21
// Define the maximum number of vertices in the graph

#define N 6

// Data structure to store a graph object struct

Graph

// An array of pointers to Node to represent an adjacency list

struct Node* head[N];

};

// Data structure to store adjacency list nodes of the graph struct

Node

int dest;

struct Node* next;

};

// Data structure to store a graph edge struct

Edge {

22
int src, dest;

};

// Function to create an adjacency list from specified edges struct

Graph* createGraph(struct Edge edges[], int n)

// allocate storage for the graph data structure struct Graph*

graph = (struct Graph*)malloc(sizeof(struct Graph));

// initialize head pointer for all vertices

for (int i = 0; i < N; i++) {

graph->head[i] = NULL;

// add edges to the directed graph one by one

for (int i = 0; i < n; i++)

// get the source and destination vertex

23
int src = edges[i].src;

int dest = edges[i].dest;

// allocate a new node of adjacency list from src to dest

struct Node* newNode = (struct Node*)malloc(sizeof(struct


Node)); newNode->dest = dest;

// point new node to the current head newNode-

>next = graph->head[src];

// point head pointer to the new node graph-

>head[src] = newNode;

return graph;

// Function to print adjacency list representation of a graph

void printGraph(struct Graph* graph)

24
{

for (int i = 0; i < N; i++)

// print current vertex and all its neighbors

struct Node* ptr = graph->head[i]; while

(ptr != NULL)

printf("(%d —> %d)\t", i, ptr->dest);

ptr = ptr->next;

printf("\n");

// Directed graph implementation in C int

main(void)

// input array containing edges of the graph (as per the above
diagram)

25
// (x, y) pair in the array represents an edge from x to y

struct Edge edges[] =

{0, 1}, {1, 2}, {2, 0}, {2, 1}, {3, 2}, {4, 5}, {5, 4}

};

// calculate the total number of edges

int n = sizeof(edges)/sizeof(edges[0]);

// construct a graph from the given edges

struct Graph *graph = createGraph(edges, n);

// Function to print adjacency list representation of a graph

printGraph(graph);

return 0;

Output:

26
(0 —> 1)

(1 —> 2)

(2 —> 1) (2 —> 0)

(3 —> 2)

(4 —> 5)

(5 —> 4)

CONCLUSION

Graphs are a beneficial concept in data structures. It has practical


implementations in almost every field. Therefore, it is essential to
understand the basics of graph theory to understand the graph
structure’s algorithms.

27
28
REFERENCES

• www.google.com

• www.javapoint.com

• www.geeksforgeekom

29

You might also like