The document is a lab manual for data structures using C programming. It contains 12 programs related to data structures and algorithms including linear search, binary search, sorting algorithms like bubble sort, selection sort, insertion sort, quick sort and merge sort. Each program contains the aim, code and output for a different data structure operation or algorithm implementation. The manual provides examples and step-by-step instructions for students to complete various exercises to learn data structures and algorithms using the C programming language.
Learn about how to define and invoke methods in Java, how to use parameters and return results. Watch the video lesson here:
https://softuni.org/code-lessons/java-foundations-certification-methods
A storage class defines the scope (visibility) and life time of variables and/or functions within a C++ Program. There are following storage classes which can be used in a C++ Program
auto
register
static
extern
Learn about how to define and invoke methods in Java, how to use parameters and return results. Watch the video lesson here:
https://softuni.org/code-lessons/java-foundations-certification-methods
A storage class defines the scope (visibility) and life time of variables and/or functions within a C++ Program. There are following storage classes which can be used in a C++ Program
auto
register
static
extern
A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions.
File Handling is used in C language for store a data permanently in computer.
Using file handling you can store your data in Hard disk.
http://www.tutorial4us.com/cprogramming/c-file-handling
Constructors, Destructors, call in parameterized Constructor, Multiple constructor in a class, Explicit/implicit call, Copy constructor, Dynamic Constructors and call in parameterized Constructor
Programs are complete in best of my knowledge with zero compilation error in IDE Bloodshed Dev-C++. These can be easily portable to any versions of Visual Studio or Qt. If you need any guidance please let me know via comments and Always Enjoy Programming.
A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions.
File Handling is used in C language for store a data permanently in computer.
Using file handling you can store your data in Hard disk.
http://www.tutorial4us.com/cprogramming/c-file-handling
Constructors, Destructors, call in parameterized Constructor, Multiple constructor in a class, Explicit/implicit call, Copy constructor, Dynamic Constructors and call in parameterized Constructor
Programs are complete in best of my knowledge with zero compilation error in IDE Bloodshed Dev-C++. These can be easily portable to any versions of Visual Studio or Qt. If you need any guidance please let me know via comments and Always Enjoy Programming.
Ex.1 Write a program to print the following pattern
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Ex.2 Write a program to find bigger of three integers.
Ex.3 Write a program to calculate GCD between two numbers.
Ex.4 Write a program to find transpose of matrix.
Ex.5 Write a program which deletes an element from an array & display all other elements.
Ex.6 Write a program to calculate XA+YB where A & B are matrix & X=2, Y=3.
Ex.7 Write a program to calculate the total amount of money in the piggy bank, given that coins of Rs.10, Rs.5, Rs.2, RS.1.
& many more.....
This document contains some programs of C using Data structures, like Stack, LinkedList, queue, Fibonacci series, addition and multiplication of two matrices,etc.
A few Programs, that are tested with compilers of respective IDEs s Bloodshed-DevC++, Visual Studio 2008, Qt 4.2. These are running successfully within console window of windows platform. So just enjoy coding. Programs in C of College days.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Data struture lab
1. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
LAB MANUAL
FOR
DATA STRUCTURE USING C LAB
1
DATA STRUCTURE USING C LAB MANUAL
2. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
PROGRAM NO.1
Aim: - To search an element in the array using Linear Search.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,item,flag=0;
clrscr();
printf("Enter the data in the array");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the element to be searched");
scanf("%d",&item);
for(i=0;i<10;i++)
{
if(item==a[i])
{
flag=1;
break;
}
}
if(flag==0)
printf("Element Not Found");
else
printf("Element Found at Position =%d",i);
getch();
}
2
DATA STRUCTURE USING C LAB MANUAL
3. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
PROGRAM NO.2
Aim: - To search an element in the 2-dimensional array using Linear Search.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],i,j,item,flag=0;
clrscr();
printf("Enter the data in the array");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Enter the element to be searched");
scanf("%d",&item);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(item==a[i][j])
{
flag=1;
printf("Element found at position =%d,%d",i,j);
}
}
}
if(flag==0)
printf("Element Not Found");
getch();
3
DATA STRUCTURE USING C LAB MANUAL
4. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
}
PROGRAM NO.3
Aim: - To merge two sorted array into one sorted array.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],b[10],c[20],i,j,k,n,m,t;
clrscr();
printf("Enter size of Array An");
scanf("%d",&n);
printf("Enter the data in Array An");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("Enter size of Array Bn");
scanf("%d",&m);
printf("Enter the data in Array Bn");
for(j=0;j<m;j++)
{
scanf("%d",&b[j]);
}
i=j=k=0;
while(i<n&&j<m)
{
if(a[i]<b[j])
c[k++]=a[i++];
else
if(a[i]>=b[j])
c[k++]=b[j++];
}
4
DATA STRUCTURE USING C LAB MANUAL
5. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
if(i<n)
{
for(t=0;t<n;t++)
c[k++]=a[i++];
}
else
{
for(t=0;t<m;t++)
c[k++]=b[j++];
}
printf("n");
for(k=0;k<(m+n);k++)
printf("n %d ",c[k]);
getch();
}
5
DATA STRUCTURE USING C LAB MANUAL
6. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
PROGRAM NO.4
Aim: - To perform the following operation in Matrix
1. Addition 2. Subtraction
3. Multiplication 4. Transpose
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],d[3][3],i,j,k;
clrscr();
printf("Enter the data in Matrix A");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Enter the data in Martix B");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
6
DATA STRUCTURE USING C LAB MANUAL
7. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf("Addition of two Matrix A and B isn");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%dt",c[i][j]);
}
printf("n");
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]-b[i][j];
}
}
printf("Subtraction of two Matrix A and B isn");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%dt",c[i][j]);
}
printf("n");
}
printf("Transpose of Matrix C isn");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
d[j][i]=c[i][j];
}
}
for(i=0;i<3;i++)
{
7
DATA STRUCTURE USING C LAB MANUAL
8. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
for(j=0;j<3;j++)
{
printf("%dt",d[i][j]);
}
printf("n");
}
printf("Multiplication of Matrix A and B isn");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=0;
for(k=0;k<3;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf("n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%dt",c[i][j]);
}
printf("n");
}
getch();
}
8
DATA STRUCTURE USING C LAB MANUAL
9. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
PROGRAM NO.5
Aim: - To perform the swapping of two numbers using call by value and call by
reference.
#include<stdio.h>
#include<conio.h>
void swapbyvalue(int,int);
void swapbyref(int*,int*);
void main()
{
int a,b;
clrscr();
printf("Enter the two numbers");
scanf("%d%d",&a,&b);
swapbyvalue(a,b);
swapbyref(&a,&b);
printf("nNumber after swapping by Referencen");
printf("na=%dnb=%d",a,b);
getch();
}
void swapbyvalue(int x, int y)
{
int temp;
temp=x;
x=y;
9
DATA STRUCTURE USING C LAB MANUAL
10. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
y=temp;
printf("nNumbers after swapping by value aren");
printf("a=%d",x);
printf("nb=%d",y);
}
void swapbyref(int *x,int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}
PROGRAM NO.6
Aim: - To perform following operation on strings using string functions
1. Addition 2. Copying 3. Reverse 4. Length of String.
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
char a[20],b[20],c[20];
int l;
clrscr();
printf("Enter the First String");
scanf("%s",&a);
printf("Enter the Second String");
scanf("%s",&b);
strcat(a,b);
printf("nConcatenation of String a and b is:%s",a);
l=strlen(a);
printf("nLength of String is %d",l);
strcpy(c,a);
printf("nthe Copied String is %s",c);
strrev(a);
10
DATA STRUCTURE USING C LAB MANUAL
11. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
printf("nreverse of String is %s",a);
getch();
}
PROGRAM NO.7 (a)
Aim: - To search an element in the array using Iterative Binary Search.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,mid,beg,i,end,item,loc=-1;
clrscr();
printf("Enter the number of elements to be enteredn");
scanf("%d",&n);
printf("Enter the elements in ascending order");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the element to be searched");
scanf("%d",&item);
beg=0;
end=n-1;
while(beg<=end)
11
DATA STRUCTURE USING C LAB MANUAL
12. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
{
mid=(beg+end)/2;
if(item==a[mid])
{
loc=mid;
break;
}
else if(a[mid]<item)
beg=mid+1;
else
end=mid-1;
}
if(loc==-1)
printf("Element Not Present");
else
printf("Element found at =%d",loc);
getch();
}
PROGRAM NO.7 (b)
Aim: - To search an element in the array using Recursive Binary Search.
#include<stdio.h>
#include<conio.h>
void binary(int [],int,int);
void main()
{
int a[20],i,n,item;
clrscr();
printf("Enter the number of items in the array");
scanf("%d",&n);
printf("enter the data in array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the element to be searched");
12
DATA STRUCTURE USING C LAB MANUAL
13. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
scanf("%d",&item);
binary(a,n,item);
getch();
}
void binary(int a[],int n,int item)
{
int beg,end,mid,loc=-1;
beg=0;
end=n-1;
while(beg<=end)
{
mid=(beg+end)/2;
if(item==a[mid])
{
loc=mid;
break;
}
else if(item>a[mid])
beg=mid+1;
else
end=mid-1;
}
if(loc==-1)
printf("Element not Found");
else
printf("Element Found at position = %d",loc);
}
13
DATA STRUCTURE USING C LAB MANUAL
14. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
PROGRAM NO.8
Aim: - To implement Bubble Sort.
#include<stdio.h>
#include<conio.h>
void bubble(int [],int);
void main()
{
int a[20],i,n;
clrscr();
printf("Enter the number of items in the array");
scanf("%d",&n);
printf("Enter the data in the array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
14
DATA STRUCTURE USING C LAB MANUAL
15. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
}
bubble(a,n);
getch();
}
void bubble(int a[],int n)
{
int i,temp,j,p;
for(i=1;i<n;i++)
{
for(p=0;p<n-i;p++)
{
if(a[p]>a[p+1])
{
temp=a[p];
a[p]=a[p+1];
a[p+1]=temp;
}
}
}
for(i=0;i<n;i++)
printf("n%d",a[i]);
}
PROGRAM NO.9
Aim: - To implement Selection Sort.
#include<stdio.h>
#include<conio.h>
void select(int [],int);
void bubble(int [],int);
int min(int [],int,int);
void main()
{
int a[20],i,n;
clrscr();
printf("Enter the number of items in the array");
15
DATA STRUCTURE USING C LAB MANUAL
16. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
scanf("%d",&n);
printf("Enter the data in the array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
bubble(a,n);
select(a,n);
getch();
}
void bubble(int a[],int n)
{
int i,temp,p;
for(i=1;i<n;i++)
{
for(p=0;p<n-i;p++)
{
if(a[p]>a[p+1])
{
temp=a[p];
a[p]=a[p+1];
a[p+1]=temp;
}
}
}
printf("nData After Bubble Sort");
for(i=0;i<n;i++)
printf("n%d",a[i]);
}
void select(int a[],int n)
{
int i,loc,temp;
loc=0;
temp=0;
for(i=0;i<n;i++)
{
loc=min(a,i,n);
temp=a[loc];
16
DATA STRUCTURE USING C LAB MANUAL
17. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
a[loc]=a[i];
a[i]=temp;
}
printf("nData After Selection Sort");
for(i=0;i<n;i++)
printf("n%d",a[i]);
}
int min(int a[],int lb,int ub)
{
int m=lb;
while(lb<ub)
{
if(a[lb]<a[m])
{
m=lb;
}
lb++;
}
return m;
}
PROGRAM NO.10
Aim: - To implement Insertion Sort.
#include<stdio.h>
#include<conio.h>
void insert(int [],int);
void main()
{
int a[20],i,n;
17
DATA STRUCTURE USING C LAB MANUAL
18. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
clrscr();
printf("Enter the number of items in the array");
scanf("%d",&n);
printf("Enter the data in the array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
insert(a,n);
getch();
}
void insert(int a[],int n)
{
int i,j,temp;
for(i=1;i<n;i++)
{
temp=a[i];
for(j=i-1;j>=0;j--)
{
if(a[j]>temp)
{
a[j+1]=a[j];
}
else
break;
}
a[j+1]=temp;
}
printf("Data After Insertion Sort");
for(i=0;i<n;i++)
printf("n%d",a[i]);
}
18
DATA STRUCTURE USING C LAB MANUAL
19. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
PROGRAM NO.11
Aim: - To implement Quick Sort.
#include<stdio.h>
#include<conio.h>
void quicksort(int[],int,int);
int partition(int [],int,int);
19
DATA STRUCTURE USING C LAB MANUAL
20. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
void main()
{
int a[20],i,n;
clrscr();
printf("Enter the size of array");
scanf("%d",&n);
printf("Enter the elements in the array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
quicksort(a,0,n-1);
for(i=0;i<n;i++)
printf("n%d",a[i]);
getch();
}
void quicksort(int a[],int lb,int ub)
{
int mid;
if(lb<ub)
{
mid=partition(a,lb,ub);
quicksort(a,lb,mid-1);
quicksort(a,mid+1,ub);
}
}
int partition(int a[],int lb,int ub)
{
int i,p,q,t;
p=lb+1;
q=ub;
i=a[lb];
while(q>=p)
20
DATA STRUCTURE USING C LAB MANUAL
21. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
{
while(a[p]<i)
p++;
while(a[q]>i)
q--;
if(q>p)
{
t=a[p];
a[p]=a[q];
a[q]=t;
}
}
t=a[lb];
a[lb]=a[q];
a[q]=t;
return q;
}
PROGRAM NO.12
Aim: - To implement Merge Sort.
21
DATA STRUCTURE USING C LAB MANUAL
22. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
#include<stdio.h>
#include<conio.h>
void mergesort(int a[],int,int);
void merge(int [],int,int,int);
void main()
{
int a[20],i,n;
clrscr();
printf("Enter the number of elements");
scanf("%d",&n);
printf("Enter the elements");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
mergesort(a,0,n-1);
printf("Data After Merge Sort");
for(i=0;i<n;i++)
printf("n%d",a[i]);
getch();
}
void mergesort(int a[],int lb,int ub)
{
int mid;
if(lb<ub)
{
mid=(lb+ub)/2;
mergesort(a,lb,mid);
mergesort(a,mid+1,ub);
merge(a,lb,mid+1,ub);
}
}
void merge(int a[],int lb,int mid,int ub)
{
int k,p1,p2,p3,b[20];
p1=lb;
p3=lb;
22
DATA STRUCTURE USING C LAB MANUAL
23. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
p2=mid;
while((p1<mid)&&(p2<=ub))
{
if(a[p1]<=a[p2])
b[p3++]=a[p1++];
else
b[p3++]=a[p2++];
}
while(p1<mid)
{
b[p3++]=a[p1++];
}
while(p2<=ub)
{
b[p3++]=a[p2++];
}
for(k=lb;k<p3;k++)
{
a[k]=b[k];
}
}
PROGRAM NO.13
Aim: - To implement Stack using array.
23
DATA STRUCTURE USING C LAB MANUAL
24. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
#include<stdio.h>
#include<conio.h>
#include<process.h>
void push();
void pop();
void display();
int top;
int a[5];
void main()
{
int choice;
char ch;
top=-1;
clrscr();
do
{
printf("nt 1. PUSH");
printf("nt 2. POP");
printf("nt 3. DISPLAY");
printf("nt 4. EXIT");
printf("nEnter your choice");
scanf("%d",&choice);
switch(choice)
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
display();
24
DATA STRUCTURE USING C LAB MANUAL
25. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
break;
case 4:
exit(0);
default:
printf("nBAD CHOICE");
}
printf("ndo you want to continue y/n");
ch=getche();
}
while(ch=='y');
}
void push()
{
int item;
if(top==4)
printf("STACK IS FULL");
else
{
printf("Enter the item to be inserted");
scanf("%d",&item);
top=top+1;
a[top]=item;
//top=tope;
}
}
void pop()
{
int item;
if(top==-1)
printf("STACK IS EMPTY");
else
{
item=a[top];
top=top-1;
printf("%d is deleted",item);
//top=tope;
}
25
DATA STRUCTURE USING C LAB MANUAL
26. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
}
void display()
{
int i;
for(i=top;i>=0;i--)
printf("n%d",a[i]);
}
26
DATA STRUCTURE USING C LAB MANUAL
27. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
PROGRAM NO.14
Aim: - To implement Queue using array.
#include<stdio.h>
#include<conio.h>
#include<process.h>
void insert();
void delet();
void display();
int front,rear;
int q[5];
void main()
{
int choice;
char ch;
front=-1;
rear=-1;
clrscr();
do
{
printf("nt 1. INSERT");
printf("nt 2. DELETE");
printf("nt 3. DISPLAY");
printf("nt 4. EXIT");
printf("nEnter your choice");
scanf("%d",&choice);
switch(choice)
{
case 1:
insert();
break;
case 2:
delet();
break;
27
DATA STRUCTURE USING C LAB MANUAL
28. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
case 3:
display();
break;
case 4:
exit(0);
default:
printf("nBAD CHOICE");
}
printf("ndo you want to continue y/n");
ch=getche();
}
while(ch=='y'||'Y');
}
void insert()
{
int item;
if(((front==1)&&(rear==5))||(front==rear+1))
{
printf("QUEUE IS FULL");
}
else
{
printf("Enter the element");
scanf("%d",&item);
if(front==-1)
{
front=1;
rear=1;
}
else if(rear==5)
{
rear=0;
}
else
{
rear=rear+1;
}
q[rear]=item;
28
DATA STRUCTURE USING C LAB MANUAL
29. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
}
}
void delet()
{
int item;
if(front==-1)
{
printf("QUEUE IS EMPTY");
}
else
{
item=q[front];
if(front==rear)
{
front=-1;
rear=-1;
}
else if(front==5)
{
front=0;
}
else
front=front+1;
printf("%d is deleted",item);
}
}
void display()
{
int i;
if(front==-1)
printf("QUEUE IS EMPTY");
else
{
for(i=front;i<=rear;i++)
{
printf("n%d",q[i]);
}}
29
DATA STRUCTURE USING C LAB MANUAL
30. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
}
PROGRAM NO.15
Aim: - To implement Linked List.
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
#include<process.h>
struct node
{
int info;
struct node *next;
};
struct node *start=NULL;
void ins();
void ins_at_beg
();
void ins_at_mid();
void ins_at_end();
void del();
void del_at_beg();
void del_at_mid();
void del_at_end();
void display();
int count();
void main()
{
int ch=0,i=0,cnt;
clrscr();
while(1)
{
printf("***********menu************");
printf("n1.insert");
printf("n2.delete");
30
DATA STRUCTURE USING C LAB MANUAL
31. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
printf("n3.display");
printf("n4.count");
printf("n5.exit");
printf ("nenter your choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1:ins();
break;
case 2:del();
break;
case 3:display();
break;
case 4:cnt=count();
printf("n the no of nodes : %dn",cnt);
break;
case 5:exit(1);
}
}
}
void ins()
{
int j=0,ch1=0;
printf("nenter your choice");
printf("n1.insert at the beggning");
printf("n2.insert at the middle");
printf("n3.insert at the end");
scanf ("%d",&ch1);
switch(ch1)
{
case 1:ins_at_beg();
break;
case 2:ins_at_mid();
break;
case 3:ins_at_end();
}
}
void ins_at_beg()
{
31
DATA STRUCTURE USING C LAB MANUAL
32. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
int info;
struct node *t=(struct node *)malloc(sizeof(struct node));
printf("nenter information to be inserted in the beggning");
scanf("%d",&info);
t->info=info;
t->next=start;
start=t;
}
void ins_at_mid()
{
int inform,x,i;
struct node *t=(struct node *)malloc(sizeof(struct node));
struct node *p=start;
printf("nenter the location after which new node to be added");
scanf("%d",&x);
for(i=1;i<x;i++)
p=p->next;
printf("nenter information of the new node");
scanf("%d",&inform);
t->info=inform;
t->next=p->next;
p->next=t;
}
void ins_at_end()
{
int inform1;
struct node *t=(struct node *)malloc(sizeof(struct node));
struct node *p=start;
printf("nenter information to be added");
scanf("%d",&inform1);
t->info=inform1;
while(p->next!=NULL)
p=p->next;
p->next=t;
t->next=NULL;
}
void del()
{
int k=0,ch2=0;
printf("nenter your choice");
printf("n1.delete at the beggning");
32
DATA STRUCTURE USING C LAB MANUAL
33. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
printf("n2.delete at the middle");
printf("n3.delete at the end");
scanf ("%d",&ch2);
switch(ch2)
{
case 1:del_at_beg();
break;
case 2:del_at_mid();
break;
case 3:del_at_end();
break;
}
}
void del_at_beg()
{
struct node *t=start;
start=start->next;
free(t);
}
void del_at_mid()
{
int n;
struct node *cur=start;
struct node *pre=start;
printf("nenter information to be deleted");
scanf("%d",&n);
while(cur->info!=n)
{
pre=cur;
cur=cur->next;
}
pre->next=cur->next;
free(cur);
}
void del_at_end()
{
struct node *cur=start;
struct node *pre=start;
while(cur->next!=NULL)
{
33
DATA STRUCTURE USING C LAB MANUAL
34. WCTM /IT/LAB MANUAL/3RD SEM/DATA STRUCTURE
pre=cur;
cur=cur->next;
}
pre->next=NULL;
free(cur);
}
void display()
{
struct node *p=start;
printf("nn***************LINK LIST*****************nn");
while(p!=NULL)
{
printf("%dn",p->info);
p=p->next;
}
}
int count()
{
int c=0;
struct node *q=start;
while(q!=NULL)
{
q=q->next;
c=c+1;
}
return c;
}
34
DATA STRUCTURE USING C LAB MANUAL