Gautamass 4
Gautamass 4
Worksheet 3
1.Aim:
Problem Statement:
Elena is a software engineer tasked with processing two large datasets stored in
separate linked lists. Her objective is to identify the unique values across both lists,
compute their squares, and present the information in a concise and efficient
manner. To optimize the solution, Elena decides to use a hash set to quickly
identify unique values and avoid duplicates
Input format
The first line contains an integer n. the number of elements in the first linked list
The second line contains n integers separated by spaces, representing the elements
of the first linked list.
The third line contains an integer m, the number of elements in the second linked
list
The fourth line contains m integers separated by spaces, representing the elements
of the second linked list.
Output format
The first line should print the unique elements from theninion of both linked listis,
sorted in ascending order, and separated by spaces The second line should print the
squares of these unique elements, sorted in ascending order, and separated by
spaces write same in right way .
3.Procedure:
#include <iostream>
#include <vector>
using namespace std;
int main() {
int numVertices, numEdges;
cin >> numVertices;
cin >> numEdges;
// Input edges
for (int i = 0; i < numEdges; ++i) {
int from, to;
cin >> from >> to;
graph[from].push_back(Edge(to));
}
return 0;
}
4.Output:
5.Learning Outcome:
·write learning outcomes of this code
Certainly! Here are the learning outcomes from the code provided:
1.
2.
3.
4.
5.
6.
7.
Handling Input and Output: Practice handling standard input and output
in C++, which is essential for competitive programming and real-world
applications.
10.
11.
12.
13.