Professional Documents
Culture Documents
UID: 21BCS8668
Section: 21BCS_CC_625
Group: A
INDEX
Ex. Name of Experiments Date Conduct Viva Worksheet Total Remarks Signature
No (MM: 12) (MM: 10) (Record) (MM: 30) (with date)
(MM: 8)
2. String Matching
3. Heap model
4. Hashing
5. Trees
6. Graph
8. Greedy
9. Backtracking
UID: 21BCS8668
Section: CC-625
Group: A
INDEX
Experiment - 1.1
Student Name: Lokesh Raj UID: 21BCS8668
Branch: Computer Science Engineering Section/Group: CC-625-A
Semester: 6th Date of Performance: Jan 15, 2024
Subject Name: Cloud Computing & Distributed Systems Lab
Subject Code: 21CSP-378
5. Give a name to the Virtual Machine and Select the downloaded Windows
ISO file.
DEPARTMENT OF
7. Allocate base memory and processors to the Virtual Machine and click on
the Next Button.
DEPARTMENT OF
1. Aim: To implement the concept of Arrays, Queues and Stack and Linked List.
2. Objective:
Problem: 3Sum
Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]]
such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.
Notice that the solution set must not contain duplicate triplets.
3. Algorithm:-
5. Source Code:
class Solu7on {
public:
// Shubham Gaurav 21BCS11419
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
vector<vector<int>> threeSum(vector<int>& nums) {
set<vector<int>> st;
sort(nums.begin(), nums.end());
vector<vector<int>> ans;
int n = nums.size();
while (j < k) {
int a = nums[i];
int b = nums[j];
int c = nums[k];
if ((a + b + c) == 0) {
st.insert({a, b, c});
j++;
k--;
} else if ((a + b + c) > 0) {
k--;
} else {
j++;
}
}
}
return ans;
}
};
6. Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Learning Outcomes:
1. Learnt about different data structures and manipulation on them, including
arrays, queues, stacks, and linked lists.
2. Proficiently implemented algorithms for optimized data storage and retrieval
using arrays.
3. Learnt about different time complexities associated with different approach to
solve a problem.
Experiment-1.2
Student Name: Lokesh Raj UID: 21BCS8668
Branch: BE-CSE Section/Group:622-'A'
Semester: 6th Date of Performance:23Jan
Subject Name: Advanced Programming lab-2 Subject Code:21CSP-351
Aim:
• Rotate String
• Repeated string match
• Find Index of First Occurences
Objective:
• Given two strings s and goal, return true if and only if s can become goal after some number of
shifts on s. A shift on s consists of moving the leftmost character of s to the rightmost position.
• Given two strings a and b, return the minimum number of times you should repeat string a so
that string b is a substring of it. If it is impossible for b to be a substring of a after repeating it,
return -1.
• Given two strings needle and haystack, return the index of the first occurrence of needle in
haystack, or -1 if needle is not part of haystack.
Algorithm:
Code(A):
public:
bool rotateString(string s, string goal) {
if(s.length()!=goal.length()) return false;
s=s+s;
if(s.find(goal)<s.length())
return true;
return false;
}
};
Output(A):
Code(B):
class Solution {
public:
int repeatedStringMatch(string a, string b) {
string s=a;
int count=1;
int n=b.length()/a.length();
for(int i=0;i<n+1;i++){
if(s.find(b)!=-1) return count;
s+=a;
count++;
}
return -1;
}
};
Output(B):
Code(C):
class Solution {
public:
int strStr(string haystack, string needle) {
int n = needle.length(),h = haystack.length(),i,c=0;
for(i=0;i<(h-n+1);i++){
if(needle == haystack.substr(i,n)){
c=1;
break;
}
}
if(c==1) return i;
return -1;
}
};
Output(C):