Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Loading...
User Settings
close menu
Welcome to Scribd!
Upload
Read for free
FAQ and support
Language (EN)
Sign in
0 ratings
0% found this document useful (0 votes)
3 views
DS Part 2
Uploaded by
mahammadsuhail12345
AI-enhanced
Copyright:
© All Rights Reserved
Available Formats
Download
as PDF, TXT or read online from Scribd
Download
Save
Save DS PART 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
DS Part 2
Uploaded by
mahammadsuhail12345
0 ratings
0% found this document useful (0 votes)
3 views
2 pages
AI-enhanced title
Document Information
click to expand document information
Original Title
DS PART 2
Copyright
© © All Rights Reserved
Available Formats
PDF, TXT or read online from Scribd
Share this document
Share or Embed Document
Sharing Options
Share on Facebook, opens a new window
Facebook
Share on Twitter, opens a new window
Twitter
Share on LinkedIn, opens a new window
LinkedIn
Share with Email, opens mail client
Email
Copy link
Copy link
Did you find this document useful?
0%
0% found this document useful, Mark this document as useful
0%
0% found this document not useful, Mark this document as not useful
Is this content inappropriate?
Report
Copyright:
© All Rights Reserved
Available Formats
Download
as PDF, TXT or read online from Scribd
Download now
Download as pdf or txt
Save
Save DS PART 2 For Later
0 ratings
0% found this document useful (0 votes)
3 views
2 pages
DS Part 2
Uploaded by
mahammadsuhail12345
AI-enhanced title
Copyright:
© All Rights Reserved
Available Formats
Download
as PDF, TXT or read online from Scribd
Save
Save DS PART 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download as pdf or txt
Jump to Page
You are on page 1
of 2
Search inside document
Queue using Quick sort stack using linked
Merge sort array technique list
1]#include<stdio.h> 2]#include<stdio.h> printf("elements in queue i=first; int choice=0;
void merge_sort(int i,int #define max 6 are\n"); j=last; clrscr();
j,int a[],int aux[]){
int queue[max]; while(i<=rear){ while(i<j){ while(choice!=4){
int mid,leftp,rightp,k;
if(j<=i){ int front=-1; printf("%d\n",queue[i]); while(a[i]<=a[ptr]&&i<last) printf("\n\n choose one from the
return;} int rear=-1; i=(i+1)%max;}}} i++; below option...\n");
mid=(i+j)/2; void enqueue(int element) int main(){ while(a[j]>a[ptr]) printf("\n1.Push\n2.Pop\n3.Sho
merge_sort(i,mid,a,aux); { int ch,x; j--; w\
merge_sort(mid+1,j,a,aux if(front==-1&rear==-1){ clrscr(); if(i<j){ n4.Exit");
);
front=0; while(1){ temp=a[i]; printf("\n Enter your choice:");
leftp=i;
rightp=mid+1; rear=0; printf("\n1.insert"); a[i]=a[j]; scanf("%d",&choice);
for(k=i;k<=j;k++){ queue[rear]=element;} printf("\n2.delete"); a[j]=temp;}} switch(choice){
if(leftp==mid+1){ else printf("\n3.display"); temp=a[ptr]; case 1:push();
aux[k]=a[rightp]; if((rear+1)%max==front){ printf("\n4.exit"); a[ptr]=a[j]; break;
rightp++;} printf("queue is full\n");} printf("\nenter your a[j]=temp; case 2:pop();
else if(rightp==j+1){
else{ choice:"); quicksort(a,first,j-1); break;
aux[k]=a[leftp];
leftp++;} rear=(rear+1)%max; scanf("%d",&ch); quicksort(a,j+1,last);}} case 3:display();
else if(a[leftp]<a[rightp]){ queue[rear]=element;}} switch(ch){ void main(){ break;
aux[k]=a[leftp]; void dequeue(){ case 1:printf("enter int i,n,a[25]; case 4:break;
leftp++;} if((front==-1)&&(rear==- elements to be inserted:"); clrscr(); default:printf("Please enter a
else{ 1)){ scanf("%d",&x); printf("Enter the size of the valid choice");}}}
aux[k]=a[rightp];
printf("queue is enqueue(x); array:"); void push(){
rightp++;}}
for(k=i;k<=j;k++){ empty\n"); break; scanf("%d",&n); int val;
a[k]=aux[k];}} } case 2:dequeue(); printf("Enter %d struct node*ptr=(struct
int main(){ else if(front==rear){ break; elements:",n); node*)malloc(sizeof(struct
int printf("element %d is case 3:display(); for(i=0;i<n;i++) node));
a[100],aux[100],n,i,d,swa dequeued\n",queue[front]) break; scanf("%d",&a[i]); if(ptr==NULL){
p;
; case 4:exit(0);}}} quicksort(a,0,n-1); printf("Unable to push the
clrscr();
printf("Enter number of front=-1;rear=-1;} printf("Order of Sorted elemen
elements in the array:\n"); else{ elements:"); t");}
scanf("%d",&n); front=(front+1)%max; for(i=0;i<n;i++) else{
printf("Enter %d printf("element %d is printf("%d\n",a[i]); printf("Enter the value:");
integers:\n",n);
3]#include<stdio.h>
dequeued\n",queue[front- #include<conio.h> getch();} scanf("%d",&val);
for(i=0;i<n;i++)
1]);}} void quicksort(int a[25],int if(head==NULL){
scanf("%d",&a[i]); 4]#include<stdio.h>
merge_sort(0,n-1,a,aux); void display(){ first,int last){ #include<stdlib.h> ptr->val=val;
printf("Printing the sorted int i=front; int i,j,ptr,temp; void push(); ptr->next=NULL;
array:\n"); if(front==-1&&rear==- if(first<last){ void pop(); head=ptr;}
for(i=0;i<n;i++) 1){ void display(); else{
printf("%d\n",a[i]);
ptr=first; struct node{
printf("queue is ptr->val=val;
getch(); int val;
empty\n");} ptr->next=head;
return 0;} struct node*next;};
else{ struct node*head; head=ptr;}
void main(){ printf("Item pushed");}}
Queue using void pop(){
Postfix expression
linked list
int item; 5]#include<stdio.h> else{ 6]#include<stdio.h> switch(c) {
struct node*ptr; #include<stdlib.h> printf("\nenter a value:\n") ; #include<conio.h> case'+':ans=b+a;
if(head==NULL){ struct node{ scanf("%d",&item); #include<string.h> break;
printf("Underflow");} int data; ptr->data=item; #define MAX 50 case'-':ans=b-a;
else{ struct node*next;}; if(front==NULL){ int stack[MAX]; break;
item=head->val; struct node*front; front=ptr; char post[MAX]; case'*':ans=b*a;
ptr=head; struct node*rear; rear=ptr; int top=-1; break;
head=head->next; void insert(); front->next=NULL; void pushstack(int temp); case'/':ans=b/a;
free(ptr); void del(); rear->next=NULL;} void evaluate(char c); break;
printf("Item %d void display(); else{ void main(){ case'^':ans=b^a;
popped",item) void main(){ rear->next=ptr; int i,l; break;
;}} int ch; rear=ptr; clrscr(); default:ans=0;
void display(){ clrscr(); rear->next=NULL;}}} printf("Insert a postfix }
int i; while(1){ void del(){ notation top++;
struct node*ptr; printf("\n1.insert an struct node*ptr; n:"); stack[top]=ans; }
ptr=head; element\n2.delete an if(front==NULL){ gets(post);
if(ptr==NULL){ element\n3.display the printf("\nUNDERFLOW\n" l=strlen(post);
printf("Stack is queue\n4.exit\n"); ); for(i=0;i<l;i++){
empty\n");} printf("\nenter your return;} if(post[i]>='0'&&post[i]<='9')
else{ choice:"); else{ {
printf("Printing Stack scanf("%d",&ch); ptr=front; pushstack(i);}
elements switch(ch){ printf("\n%d is if(post[i]=='+'||post[i]=='-
\n"); case1:insert(); deleted\n",ptr->data); '||post[i]=='*'||post[i]=='/'||post
while(ptr!=NULL){ break; front=front->next; [i
printf("%d\n",ptr- case2:del(); free(ptr);}} ]=='^'){
>val); break; void display(){ evaluate(post[i]);}}
ptr=ptr->next;}}} case3:display(); struct node*ptr; printf("\n\nResult::%d",stack[t
break; ptr=front; o
case4:exit(0); if(front==NULL){ p]);
break; printf("\nempty queue\n");} getch();}
default:printf("\nenter a else{ void pushstack(int temp){
valid choice:");}}} while(ptr!=NULL){ top++;
void insert(){ printf("\n%d\n",ptr->data); stack[top]=(int)(post[temp]-
struct node*ptr; ptr=ptr->next;}}} 48);}
int item; void evaluate(char c){
ptr=(struct int a,b,ans;
node*)malloc(sizeof(struc a=stack[top];
t node)); stack[top]='\0';
if(ptr==NULL){ top--;
printf("\nOVERFLOW\n" b=stack[top];
); stack[top]='\0';
return;} top--;
Queue using Quick sort stack using linked
Merge sort array technique list
7]#include <stdio.h> 8]#include<stdio.h>
#include <stdlib.h> typedef struct tnode{
struct node{ int data; #include <stdlib.h>
int data; struct tnode *right, *left;
struct node*next;}; } TNODE;
struct node*head; TNODE *CreateBST(TNODE *, int);
void beginsert(); void Inorder(TNODE *);
void random_delete(); void Preorder(TNODE *);
void display(); void Postorder(TNODE *);
void main(){ void main(){
int ch; TNODE *root = NULL;
while(1){ int choice=0, elem, n, i;
printf("\n\n******Main Menu*******\n"); clrscr();
printf("\n.Insert in beginning\n2.Delete a given while(choice<=2){
node\n3.Display\n4.Exit\n"); printf("\n\n Binary Search Tree Operations \n");
printf("\nEnter your choice:"); printf("\n 1.Creation of BST");
scanf("\n%d",&ch); printf("\n 2.Inorder, Preorder and Postorder Traversal");
switch(ch){ printf("\n 3.Exit");
case 1: printf("\n Enter Your choice: ");
beginsert(); scanf("%d", &choice);
break; switch (choice){
case 2: case 1:root = NULL;
random_delete(); printf("\n\nTotal number of nodes in BST :");
break; scanf("%d", &n);
case 3: for (i=1;i<=n;i++) {
display(); printf("\nEnter the element %d:", i);
break; scanf("%d", &elem);
case 4: root = CreateBST(root, elem);}
exit(0); printf("\nBST with %d nodes created\n", n);
default: break;
printf("Please enter valid choice..");}}} case 2: printf("\n Inorder Traversal:");
void beginsert(){ Inorder(root);
struct node*ptr; printf("\n Preorder Traversal: ");
int item; Queue using Preorder(root);
ptr=(struct node*)malloc(sizeof(struct node*)); printf("\n Postorder Traversal:"); Postfix expression
if(ptr==NULL){
linked list
(sizeof(structnode*)); Postorder(root);
printf("nOVERFLOW");} break;}}
else{ getch();}
printf("\nEnter value\n"); TNODE *CreateBST(TNODE *root, int elem){
scanf("%d",&item); if (root == NULL){
ptr->data=item; root = (TNODE *) malloc(sizeof(TNODE));
ptr->next=head; root->left = root->right = NULL;
head=ptr; root->data = elem;
printf("\n%d inserted",item);}} return root;}
void random_delete(){ else if (elem < root->data)
struct node*temp; root->left = CreateBST(root->left, elem);
struct node*del; else
int loc,i; root->right = CreateBST(root->right, elem);
printf("\nEnter the position to delete the node:\n"); return (root);}
scanf("%d",&loc); void Inorder(TNODE *root){
temp=head; if (root != NULL){
if(loc==0){ Inorder(root->left);
printf("\nElement deleted is %d\n",temp->data); printf(" %d ", root->data);
head=head->next; Inorder(root->right);}}
temp->next==NULL; void Preorder(TNODE *root){
free(temp);} if (root!= NULL){
else { printf(" %d ", root->data);
for(i=0;i<loc-1;i++){ Preorder(root->left);
temp=temp->next;} Preorder(root->right);}}
del=temp->next; void Postorder(TNODE *root){
temp->next=temp->next->next; if (root != NULL){
printf("\nElement deleted is:%d\n",del->data); Postorder(root->left);
del->next=NULL; Postorder(root->right);
free(del);}} printf(" %d ", root->data);}}
void display(){
struct node*ptr;
ptr=head;
if(ptr==NULL){
printf("No element found!\n");}
else{
printf("Elements are:\n");
while(ptr!=NULL){
printf("%d",ptr->data);
ptr=ptr->next;}}}
You might also like
DS Part 1
Document
1 page
DS Part 1
mahammadsuhail12345
No ratings yet
Dsa Lab
Document
19 pages
Dsa Lab
Shaliq
No ratings yet
DS Programs
Document
15 pages
DS Programs
Sahana M.k
No ratings yet
XVCXBV XVXXXXXXXV
Document
22 pages
XVCXBV XVXXXXXXXV
Samrat Prince
No ratings yet
Program:-4: Write A Program To Implement A Queue
Document
4 pages
Program:-4: Write A Program To Implement A Queue
jindal112211
No ratings yet
Programs For 3rd Sem B.tech Data Structures Lab
Document
47 pages
Programs For 3rd Sem B.tech Data Structures Lab
Rishabh
No ratings yet
CTSD Home Assignment-6: NAME: S Adarsh ID-NO: 2100010062
Document
19 pages
CTSD Home Assignment-6: NAME: S Adarsh ID-NO: 2100010062
praveen tummalacharla
No ratings yet
Dsu
Document
13 pages
Dsu
popbro44
No ratings yet
Circular Queue
Document
4 pages
Circular Queue
Sujal Rajvansh
No ratings yet
Circular Queue
Document
4 pages
Circular Queue
Sujal Rajvansh
No ratings yet
Long Assignment
Document
15 pages
Long Assignment
abubakernawaz
No ratings yet
DSA C Programs
Document
30 pages
DSA C Programs
[CO - 174] Shubham Mourya
No ratings yet
Programms
Document
8 pages
Programms
Swathi Pothurajula
No ratings yet
Data Structure Lab Manual
Document
27 pages
Data Structure Lab Manual
Shweta Yadav
No ratings yet
DSU Programs
Document
36 pages
DSU Programs
snigdhakandikatla8
No ratings yet
ds programs
Document
24 pages
ds programs
Adi ff
No ratings yet
Insertq Deleteq Display: Void Int Int Void Int Void Int
Document
3 pages
Insertq Deleteq Display: Void Int Int Void Int Void Int
K.M Chaithrashree
No ratings yet
Ques
Document
78 pages
Ques
jaiaggarwal1912
No ratings yet
Programs
Document
14 pages
Programs
Lord Breacher
No ratings yet
Dsa File of Kushagra
Document
53 pages
Dsa File of Kushagra
Kushagra Verma
No ratings yet
Program On Circular Queue
Document
3 pages
Program On Circular Queue
akurathikotaiah
No ratings yet
PRasitkumar Bairagi
Document
13 pages
PRasitkumar Bairagi
prasitbairagi730
No ratings yet
Data Structure Programs DR - Sudharsan
Document
33 pages
Data Structure Programs DR - Sudharsan
ksaryan08
No ratings yet
DS 15marks 2016
Document
34 pages
DS 15marks 2016
RUSHIKESH UJJAINKAR
No ratings yet
Stack Queue Using Array
Document
5 pages
Stack Queue Using Array
stdesai1005
No ratings yet
Lab No 07 - Dequenc
Document
2 pages
Lab No 07 - Dequenc
2023msee7
No ratings yet
Data Structure
Document
21 pages
Data Structure
itsnedhere
No ratings yet
Lab Cycle
Document
82 pages
Lab Cycle
Pavan Malladi
No ratings yet
Lab No 08
Document
2 pages
Lab No 08
2023msee7
No ratings yet
All Program K Scheme
Document
22 pages
All Program K Scheme
x11077011x
No ratings yet
?DS Programs?
Document
40 pages
?DS Programs?
ABHIRAM M
No ratings yet
Insert Del Display Main: MAX 3 1 1 MAX
Document
3 pages
Insert Del Display Main: MAX 3 1 1 MAX
Kanabi Raj
No ratings yet
Practical Assignment
Document
42 pages
Practical Assignment
Ajit
No ratings yet
DS LAB - Manual
Document
58 pages
DS LAB - Manual
Murthy Babu
No ratings yet
Data Structure File
Document
46 pages
Data Structure File
59mansikangs4
No ratings yet
DS - 15 Marks Slip - 2
Document
35 pages
DS - 15 Marks Slip - 2
aryaganeshmhaske
No ratings yet
Implementation of Queue Using Array
Document
42 pages
Implementation of Queue Using Array
rsgk
100% (1)
DS Lab
Document
46 pages
DS Lab
KamalStark
No ratings yet
Queue Using Arrays
Document
2 pages
Queue Using Arrays
eloziiopfoze
No ratings yet
Ex No 2 Implementation of Queue Using Array
Document
5 pages
Ex No 2 Implementation of Queue Using Array
NIVAASHINI MATHAPPAN
No ratings yet
LCI2023004 Vedamsh Lab6 DS
Document
6 pages
LCI2023004 Vedamsh Lab6 DS
vedamsh25
No ratings yet
DS 5 to 15
Document
29 pages
DS 5 to 15
mannidedha3570
No ratings yet
Dslab
Document
13 pages
Dslab
Gayathri Munji
No ratings yet
DSA Lab Internal III Programs
Document
12 pages
DSA Lab Internal III Programs
pokemonepisodes27
No ratings yet
Data Structure Lab Manual
Document
24 pages
Data Structure Lab Manual
shibu n
No ratings yet
QUEUEUSARRAY
Document
4 pages
QUEUEUSARRAY
arjunrarjun99
No ratings yet
Shortened_DSA_Programs_Full
Document
15 pages
Shortened_DSA_Programs_Full
ssss7750913
No ratings yet
Qeue
Document
18 pages
Qeue
Puneet Bhandari
No ratings yet
Circular
Document
5 pages
Circular
Ashwin Harikumar
No ratings yet
Experiment No 2: AIM: Program To Implement Binary Search
Document
21 pages
Experiment No 2: AIM: Program To Implement Binary Search
Ayushtheflirt
No ratings yet
C
Document
41 pages
C
Sahil Soni
No ratings yet
CTSD Home Assignment-564
Document
28 pages
CTSD Home Assignment-564
YELLETI Deepak
No ratings yet
Data Structure
Document
21 pages
Data Structure
Prateek singh
No ratings yet
Data ST
Document
109 pages
Data ST
aaa
No ratings yet
CDS Assignment 6
Document
9 pages
CDS Assignment 6
Soumen Pathak
No ratings yet
DSA_smol
Document
21 pages
DSA_smol
hehehaha
No ratings yet
Data structure
Document
12 pages
Data structure
fathimahiba8963
No ratings yet
Lab Exam Pactice
Document
29 pages
Lab Exam Pactice
sarkarsolanki045
No ratings yet
Computer Engineering Laboratory Solution Primer
From Everand
Computer Engineering Laboratory Solution Primer
Karan Bhandari
No ratings yet
150+ C Pattern Programs
From Everand
150+ C Pattern Programs
Hernando Abella
No ratings yet
Seneca's Morals of A Happy Life
Document
262 pages
Seneca's Morals of A Happy Life
steventshibangu4
No ratings yet
Linear Algebra II (Lecture Notes) - Peter Philip
Document
213 pages
Linear Algebra II (Lecture Notes) - Peter Philip
vic1234059
No ratings yet
Gramatika Engleski Jezik 1 20232024
Document
51 pages
Gramatika Engleski Jezik 1 20232024
xp80yz90
No ratings yet
Curriculum Materials
Document
4 pages
Curriculum Materials
Sherelyn Labrado Lucas
No ratings yet
SAP WM Interview Questions - 30.10.2019
Document
19 pages
SAP WM Interview Questions - 30.10.2019
Vishnuvardhan Reddy
No ratings yet
ESL Hotel Reading
Document
4 pages
ESL Hotel Reading
juan2006morenollanos
No ratings yet
LB7 Unit Test 3A
Document
2 pages
LB7 Unit Test 3A
fafohet322
No ratings yet
Lopez Juan Carlos M07 S3 AI5 WORD
Document
3 pages
Lopez Juan Carlos M07 S3 AI5 WORD
juan.c. lopez.b.
No ratings yet
Scott Schema MySQL
Document
2 pages
Scott Schema MySQL
manharakshat
No ratings yet
TOEFL Listening: "Lecture On Sylvia Plath."
Document
2 pages
TOEFL Listening: "Lecture On Sylvia Plath."
Nora Koller
0% (1)
How To Install and Configure Squid Proxy On Debian 9
Document
3 pages
How To Install and Configure Squid Proxy On Debian 9
Hamdi Maulana
No ratings yet
Berghahn Books
Document
6 pages
Berghahn Books
Asim Roy
No ratings yet
Ch#5 The Two-Sided Laplace Transform
Document
19 pages
Ch#5 The Two-Sided Laplace Transform
Mubarak Ahmad
No ratings yet
Grade 1 Phonics - S Workbook
Document
13 pages
Grade 1 Phonics - S Workbook
dina Elbassel
No ratings yet
Laravelsaas
Document
120 pages
Laravelsaas
Luz DeMars
100% (1)
Winols Manual PDF
Document
125 pages
Winols Manual PDF
xivo5
100% (2)
Participle Phrases As Reduced A Relatives
Document
4 pages
Participle Phrases As Reduced A Relatives
Anne Ku
No ratings yet
Jayatirtha's "Padyamaala"
Document
4 pages
Jayatirtha's "Padyamaala"
NiranjanacharKalale
No ratings yet
Python Notes For 9 Final
Document
18 pages
Python Notes For 9 Final
Mahima Kalucha
No ratings yet
28 Travis Week11 Tutorial Q2
Document
3 pages
28 Travis Week11 Tutorial Q2
Travis Teoh
No ratings yet
r22 B.tech Ece Jntuh Syllabus
Document
138 pages
r22 B.tech Ece Jntuh Syllabus
Anonymous VG6Zat1o
No ratings yet
Tong Hop On Ly Thuyet Thi Tot Nghiep 12
Document
122 pages
Tong Hop On Ly Thuyet Thi Tot Nghiep 12
min1nguyet123
No ratings yet
Academic Vocabulary Words For 1st Graders
Document
9 pages
Academic Vocabulary Words For 1st Graders
Zaher Attawneh
No ratings yet
Maths Olympiad Questions For Class 5
Document
17 pages
Maths Olympiad Questions For Class 5
anushapl2010
No ratings yet
Web Design For Beginners - Project Brief
Document
19 pages
Web Design For Beginners - Project Brief
Mouhamed Nazirou Diankha
No ratings yet
13 Natures of Language
Document
14 pages
13 Natures of Language
Gerald Lasheras DM
0% (1)
CSS-FW.L.U01 (Boostrap 4)
Document
71 pages
CSS-FW.L.U01 (Boostrap 4)
beu24122000
No ratings yet
Japanese Vocabulary for English Speakers English-Japanese - 5000 Words - Tss John - オンラインでPDFをめくる - FlipHTML5
Document
253 pages
Japanese Vocabulary for English Speakers English-Japanese - 5000 Words - Tss John - オンラインでPDFをめくる - FlipHTML5
locire9174
No ratings yet
Is PPP Dead?: Jeremy Harmer
Document
17 pages
Is PPP Dead?: Jeremy Harmer
Sofia Isern
No ratings yet
Help Desk Management System Abstract
Document
2 pages
Help Desk Management System Abstract
shannu
No ratings yet