21bcs1560_harsh Patil_advanced Programming Lab 1
21bcs1560_harsh Patil_advanced Programming Lab 1
UID: 21BCS1560
INDEX
Code:
(a) #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int nseq, seq, size;
int nquery;
int lostans, a;
cin>>nseq;
cin>>nquery;
vector<vector<int>> v(nseq, vector<int>());
vector<int> q;
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
unsigned long long int n,d;
cin>>n>>d;
unsigned long long int a[n];
unsigned long long int i;
for(i=0;i<n;i++)
cin>>a[i];
for(i=d;i<n;i++)
cout<<a[i]<<" ";
for(i=0;i<d;i++)
cout<<a[i]<<" ";
return 0;
}
Output:
(a)
(b)
Learning outcomes:
1. Implementation and the concept of Dynamic Array.
Experiment 1.2
Name: harsh patil UID: 21BCS1560
Branch: CSE Semester: 5
Subject: Advance programming lab-1 Section: A
Date of Performance:17-06-25 Subject Code: 21CSP-314
}
else if(t==2){q.pop();}
else{
cout<<q.front()<<endl;
}
}
return 0;
}
Output:
(a)
(b)
Learning outcomes:
Implementation of stacks and queues
Experiment 1.3
Name: harsh patil UID: 21BCS1560
Branch: CSE Semester: 5
Subject: Advance programming lab-1 Section: A
Date of Performance:17-06-25 Subject Code: 21CSP-314
Learning outcomes:
Concept of linked list
Experiment 1.4
Name: harsh patil UID: 21BCS1560
Branch: CSE Semester: 5
Subject: Advance programming lab-1 Section: A
Date of Performance:17-06-25 Subject Code: 21CSP-314
int main() {
long long n,m,temp;
cin>>n;
vector<int> a;
for(long long i=0;i<n;i++) {
cin >> temp;
a.push_back(temp);
}
cin>>m;
vector<int> b;
for(long long i=0;i<m;i++){
cin >> temp;
b.push_back(temp);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
long long i=0,j=0;
while(i<n && j<m){
if(a[i]==b[j]) {
i++;j++;
b[j-1]=0;
}
else if(a[i]>b[j])j++;
else i++;
}
set<int> st;
for(i=0;i<m;i++) {
if(b[i]!=0) st.insert(b[i]);
}
for(set<int>::iterator it = st.begin();it!=st.end();it++){ cout<<*it<<" ";
}
cout<<endl;
return 0;
}
Output:
(a)
(b)
Learning outcomes:
implement the concept of Tree Data Structure.
Experiment 2.3
Name: harsh patil UID: 21BCS1560
Branch: CSE Semester: 5
Subject: Advance programming lab-1 Section: A
Date of Performance:17-06-25 Subject Code: 21CSP-314