 53

# CSE1002 Problem Solving and Object Oriented Programming

CSE1002 Problem Solving and Object Oriented Programming Question Bank

VITspot App v2.0 Now with Question Papers supporting 2.5k+ courses.

CSE1002 Bonus Practice Sheet Winter 2018

Codes will be updated daily. Keep Checking 🙂 Please Comment out the code names (with IDs) which are not listed here.

You can also Use VITspot Search in Homepage 🙂

Vector of Characters

Chess, Carrom and Scrabble Players

Sort Data in File

Names that Do Begin with Vowel – Descending Order

Count Words in Tweets

Customer discount

Recursive reverse

Generic Double Ended Queue

Automatic vending machine

Code Detection Problem

Computing Area of Different Shapes

Row Maximum of a Matrix

Find a Route

Arrange Items for Solar Vehicle

3-D points- multiply and increment

College Application

List of even Points

Special Pay Increase Problem

Black Coin in Board game

Verification of ‘L’ shaped arrangement of coins on game board

Cost of Pizza

Class Average Problem

How to Serve a Coffee?

Symmetric Matrix

Polygon in a Two Dimensional Space

Jobs with and without Priority

Tender scrutiny using reference variable

Second Smallest Number

Count the Number of Items

String operations

Happy Coding NISHANT AGGARWAL - March 24, 2018

CSE1002 Verification of circular prime number
CSE1002-Tender scrutiny using reference variable
CSE1002 Cyclic Right Shift of Elements
CSE1002 Boarding Pass
CSE1002 Black Coin in Board game
CSE1002 Check if a Matrix is Sparse or Not
CSE1002 Count Words in Tweets
CSE1002 Find a Route
CSE1002 List of even Points
CSE1002 Names that Do Begin with Vowel

we want solution of these bonus practice problems

36
2 VITspot Team - March 27, 2018

3
1 Tanya - April 2, 2018

identify machines in same local network (id 1053)

3
3 Drake - March 25, 2018

We really need solutions for two vector operation questions

1.Vector operations (Id-1327)
Design a class vector to perform the operations like retrieving value for i-th component from a vector, add two vectors and subtract a vector from another if they are of same dimension. A vector of n-dimension is represented by an n-tuple (a sequence of n numbers). Addition of two vectors of same dimension, is got by adding the corresponding components of the two vectors. Similarly, subtraction of the two vectors, v1-v2, is got by the subtracting the respective components of v2 from the corresponding components of v1. Overload subscript ([]) operator for retrieving the i-th element from a vector, ‘+’ and ‘-‘ for addition and subtraction, <> for I/O operations. If the vectors are of different dimension, throw an exception stating “Vectors of different dimension cannot be added”.

Input format:
Dimension of first vector, ‘n1’
First element of first vector
Second element of first vector

n1-th element of first vector
Dimension of second vector, ‘n2’
First element of second vector
Second element of second vector

n2-th element of first vector
value of i
value of j

Output Format
i-th element of vector1
j-th element of vector2
sum of vectors
vector1-vector2

2.Vector Operations (Id-2650)
Vectors are used in everyday life to locate individuals and objects. They are also used to describe objects acting under the influence of an external force. A vector, is a quantity with a direction and magnitude. A vector with magnitude alone, is an n-tuple (list of n numbers) Given two vectors v1, v2, develop an algorithm and the subsequent C++ program to determine the sum and dot product of the two vectors. Sum of v1 and v2, written as v1+v2, is got by adding the respective elements: first element of v1+v2 is got by adding the first element of v1 with the first element of v2; second element of v1+v2 is got by adding the second element of v1 and the second element of v2 and so on. The dot product v1*v2 is a scalar ( a number), which is the sum of the product of the respective elements of v1 and v2. In other words, dot product of two vectors is got by adding : the product of the first element of v1 with the first element of v2, product of the second element of v1 with the second element of v2 and so on

if the input vectors v1 and v2 are:

v1= 3, 4, -5, 6, 7, 8

v2 = 4, 6, 8, 10, 1, 4

Then sum of the two vectors is 7, 10, 3, 16, 8, 12 and their dot product is : 3*4+4*6+(-5)*8+6*10+7*1+8*4

12+24+(-40)+ 60+7+32=95

Input Format

First line contains the number elements in vector v1 n

Next line contains the number elements in vector v2, m

Next ‘n’ lines contains the elements of the vector v1

Next ‘m’ lines contains the elements of the vector v2

Output Format

First ‘n’ lines contain the sum of the vectors

Next line contains the dot product of the vectors

14 VITspot Team - March 26, 2018

3
9 eddie - March 30, 2018

dude but i couldn’t find it.. can you send the link plzz??

2
2 Drake - March 31, 2018

Me too Sagarika - April 5, 2018

It’s not passing!
Do help out. Drake - March 26, 2018

We also need code detection problem

Code Detection Problem (Id-1529)

For security reasons, messages are transmitted as a secret code over a transmission channel. It is usually sent as a sequence of bits, that is, 0s and 1s. Due to noise in the transmission channel, the transmitted message may become corrupted. That is, the message received at the destination may not be the same as the message transmitted. There are several techniques to check the validity of the transmitted message at the destination. One such technique is to transmit the same message twice. At the destination, both copies of the message are compared. Given a file “data.txt” with the messages that is transmitted, write a C++ program to check whether the message received at the destination is error-free. For simplicity, assume that the secret code representing the message is a sequence of digits(0 to 9) and the maximum length of the message is 250 digits. Each original message is followed by a copy message and first number in both the messages indcates the length of the message. Each character in the message is separated by a space. For example, 7 9 2 7 8 3 5 6 7 9 2 7 8 3 5 6 means that the original message is of length 7 and it is 9 2 7 8 3 5 6 and copy message is also of length 7 and it is 9 2 7 8 3 5 6. If orginal and copy message is same then print Message transmitted is ok. Print Message transmitted is not OK when th length of the original or copy message is greater than 250 or when the original message is not same as copy message.

Input Format:
Name of the file
Input file contains a number of secret codes immediately followed their copy

Output Format:
Print either Message transmitted is ok or Message transmitted is not ok

6
2 VITspot Team - March 26, 2018

2
2 Drake - March 31, 2018

But it’s not there

1
1 Drake - March 31, 2018

Yeah I found it thanks Sourav - March 26, 2018

CSE1002 Identify machines in same local network
CSE1002 Recursive Fibonacci
CSE1002 Customer discount
CSE1002 Count the Number of Items
CSE1002 Count Words in Tweets
CSE1002 List of even Points
CSE1002 3-D points- multiply and increment
please solve these ….i am unable to solve them.. Drake - March 26, 2018

Guys, the hyperlink to the bonus practice problem “How to serve coffee” https://vitspot.com/code/class-average-problem/ directs us the the class average problem instead.

1
1 VITspot Team - March 26, 2018

Posted Updated! 🙂
Thanks <3 srk123 - March 26, 2018

There are many codes that arent there over here. Please make it sure that you upload all the codes.
CSE1002 Verification of circular prime number
CSE1002 Recursive reverse
CSE1002 Vector operations
CSE1002 Customer discount
CSE1002 Insert into a Generic Box
CSE1002 Generic Double Ended Queue
CSE1002 Count Words in Tweets
CSE1002 Names that Do Begin with Vowel- descending order.

8
1 Drake - March 26, 2018

Thanks a lot for putting up all these code. They are extremely helpful! VITspot Team - March 26, 2018

ThankQ 🙂 Customer discount problem is not there harry mahesh - March 26, 2018

AUTOMATIC VENDING MACHINE and GENERIC DOUBLE ENDED QUEUE are not there try to get the code NISHANT AGGARWAL - March 26, 2018

Plz update its solution

A circular prime number is a prime number ‘p’ with a property that all the numbers got by cyclically permuting the digits of ‘p’, are also a prime number.

A number is said to be a prime if it has no factors other than the number 1 and itself. 19937 is a circular prime number, as all the numbers obtained by cyclically permuting the number 19937 : 99371, 93719,37199,71993,19937 are all prime.

Develop an algorithm and write a C program to check if the given number is a circular prime or not.

Input Format

A number

Output Format

Print Circular prime or Not circular prime NISHANT AGGARWAL - March 26, 2018

update its solution also

Given a set of elements stored in an array and a number ‘m’, design an Algorithm and write the subsequent C program to perform cyclic right shift of the array by ‘m’ places. For example, if the elements are 12, 13, 16, 7, 10 and m =2 then the resultant set will be 7, 10, 12, 13, 16.

Input Format

Number of elements in the set: ‘n’

element-1

element-2

element-n

value of ‘m’

Output Format

Elements in the set after right shift by ‘m’ places Md Sameer - March 26, 2018 Tarunya - March 27, 2018

Please upload code for problem -‘ Insert into a Generic Box ‘ dharma teja u - March 27, 2018

cse 1002
batch 4
bonus practice problems
cyclic right shift of elements id-1243
sort a given set of points id-1534
generic right shift id-1538
vector operations id-2650
these four questions are not there please update these

5
1 Selena Moirangthem - March 27, 2018

Id 1053 identify machines in same local network
Id 1323 boarding pass
Id 1490 check if a matrix is sparse or not Sudharani - March 27, 2018

Id 1248 salary of employees
Id 1327 vector operations
Id 1538 generate right shift
Id 2650 vector operations Ayush Dhiman - March 27, 2018

and Arrange Items for Solar Vehicle yoyoyo - March 27, 2018

Sort Data in File (Id-1532) is not there drumit modi - March 27, 2018

RECURSIVE FIBONACCI ID-1249
Given the value of ‘n’, write a recursive routine in C to print the first ‘n’ elements of the Fibonacci series. Fibonacci series is obtained by the sum of the preceding two terms in the series. The first two terms are 0 and 1.

Eg.,

for n=7,

the Fibonacci terms are 0,1,1,2,3,5,8

Input Format

Value of ‘n’

Output Format

Fibonacci series of ‘n’ terms, each term separated by a space

VECTORS OF CHARACTERS ID-1498

Design a class charVector that has a character vector as datamember. Provide member functions in the class to createVector, duplicateVector, duplicateRevVector and print. Functions shall be defined as follows:

initializeVector – read a string and create a vector of characters

duplicateVector – Add the content of the vector once at the end. For example if the content of charVector is “bat” then after the function is called the content must “batbat”

CHECK IF MATRIX IS SPARSE OR NOT ID-1490

duplicateRevVector – Add the content of the vector in reverse at the end. For example if the content of charVector is “bat” then after the function is called the content must “battab”

print – Print content of vector, use iterators for traversal

Use the vector class defined in STL for the implementation. Use [] operator in functions duplicateVector, duplicateRevVector and use iterator in print and initializeVector functions.

Input Format

String to be stored in vector1

String to be stored in vector2

Output Format

Print duplicateVector of vector1

Print duplicateRevVector of vector2

SORT A GIVEN SET OF POINTS ID-1534

Design a OOP model to represent a point in a two dimensional space and overload the operators >>,< and ==. Given ‘n’ points, design an algorithm and write a C++ code to sort them in descending order. While sorting, a point is said to be greater than the other based on their x-coordinate value. If value of x-coordinate is same for both the points then make a decision based on their value of y-coordinate.

Input Format

Number of points ‘n’

value of X- coordinate of point1

value of Y- coordinate of point1

….

value of X- coordinate of point-n

value of Y- coordinate of point-n

Output Format

Print ‘n’ points in sorted order

value of X- coordinate and Y- coordinate of point1 separated by tab

value of X- coordinate and Y- coordinate of point2 separated by tab

….

value of X- coordinate and Y- coordinate of point-n separated by tab

CHECK IF GIVEN MATRIX IS SPARSE OR NOT ID-1490

There are numerous applications of matrices, both in mathematics and other sciences. Some of them merely take advantage of the compact representation of a set of numbers in a matrix. Few to mention the application of matrices are game theory, economics, graph theory, quantum theory, probabilty theory and statistics. Each type of application use different type of data. Design a generic class matrix with functions to check if a matrix is sparse and add two matrices. A matrix is said to be sparse, if the number of zero’s in the matrix is larger than the number of non-zero elements. Define a user defined exception mismatchDimension and throw it when the dimension of matrix1 is not equal to dimension of matrix 2. Print “Dimension of matrices do not match” when the exception is caught.

Input Format:

Number of rows in matrix1

Number of columns in matrix1

Element1 in matrix1

Element2 in matrix1

Elementn in matrix1

Number of rows in matrix2

Number of columns in matrix2

Element1 in matrix2

Element2 in matrix2

Elementn in matrix2

Output Format:

Print elements of resultant matrix or Dimension of matrices do not match if exception is caught

Element1 in resultant matrix

Element2 in resultant matrix

Elementn in resultant matrix

Matrix is sparse or Matrix is not sparse drumitmodi - March 27, 2018

779 Pawan - March 27, 2018

the Generic Double Ended Queue problem’s code showing following error
/tmp/tmp7yWcpy/Hello.cpp:90:46: error: no ‘bool deque::pushB(T)’ member function declared in class ‘deque’
template bool deque::pushB(T data) {
^
/tmp/tmp7yWcpy/Hello.cpp:93:46: error: no ‘bool deque::pushF(T)’ member function declared in class ‘deque’
template bool deque::pushF(T data) {
^
/tmp/tmp7yWcpy/Hello.cpp:107:36: error: no ‘T deque::popF()’ member function declared in class ‘deque’
template T deque::popF() {
^
/tmp/tmp7yWcpy/Hello.cpp:110:36: error: no ‘T deque::popB()’ member function declared in class ‘deque’
template T deque::popB() {
^ Pawan - March 27, 2018

Kindly update these problems
(i)CSE1002 Salary of Employees (Id-1248)
A company stores the following details of employees such as name, employee id, basic pay, % of DA and HRA. Given details of ‘n’ employees of an organization, Write an algorithm and a C code to

i. get the details of each employee.

ii. print their employee id

iii. Total salary.

Total salary = Basic Pay + % of DA * basic pay + HRA.

Input Format

value of ‘n’

Employee name of employee1

Employee id of employee1

Basic pay of employee1

Percentage of DA of employee1

HRA of employee1

Employee name of employee – n

Employee id of employee – n

Basic pay of employee – n

Percentage of DA of employee – n

HRA of employee – n

Output Format

Employee id of employee1

Total salary of employee1

Employee id of employee2

Total salary of employee2

Employee id of employee – n

Total salary of employee – n

(ii)CSE1002 Recursive Fibonacci (Id-1249)

Given the value of ‘n’, write a recursive routine in C to print the first ‘n’ elements of the Fibonacci series. Fibonacci series is obtained by the sum of the preceding two terms in the series. The first two terms are 0 and 1.

Eg.,

for n=7,

the Fibonacci terms are 0,1,1,2,3,5,8

Input Format

Value of ‘n’

Output Format

Fibonacci series of ‘n’ terms, each term separated by a space

(iii)CSE1002 Vector operations (Id-1327)

Design a class vector to perform the operations like retrieving value for i-th component from a vector, add two vectors and subtract a vector from another if they are of same dimension. A vector of n-dimension is represented by an n-tuple (a sequence of n numbers). Addition of two vectors of same dimension, is got by adding the corresponding components of the two vectors. Similarly, subtraction of the two vectors, v1-v2, is got by the subtracting the respective components of v2 from the corresponding components of v1. Overload subscript ([]) operator for retrieving the i-th element from a vector, ‘+’ and ‘-‘ for addition and subtraction, <> for I/O operations. If the vectors are of different dimension, throw an exception stating “Vectors of different dimension cannot be added”.

Input format:
Dimension of first vector, ‘n1’
First element of first vector
Second element of first vector

n1-th element of first vector
Dimension of second vector, ‘n2’
First element of second vector
Second element of second vector

n2-th element of first vector
value of i
value of j

Output Format
i-th element of vector1
j-th element of vector2
sum of vectors
vector1-vector2

Code:
#include
using namespace std;
class vector
{
int num;
int ele;
public:
friend istream& operator>>(istream&,vector&);
friend ostream& operator<>v1;
cin>>v2;
cin>>i;
cin>>j;
cout<<v1[i]<<endl;
cout<<v2[j]<<endl;
v3 = v1+v2;
cout<<v3;
v3 = v1 – v2;
cout<<v3;
} gowtham - March 27, 2018

verification of circular prime numbers(Id-1051)
vector operations(Id-2650) Vansh Kathuria - March 29, 2018

CSE1002 Salary of Employees harshita - March 30, 2018

Please get the codes for leader of elements and sort the given set of points VITspot Team - March 30, 2018

Updated 🙂
Check out at & anil - March 30, 2018

Given a set of ‘n’ elements in an order, identify all the leaders and print them. An element is said to be a leader if all the elements to its right are smaller than it. For example, if the elements are 12, 13, 16, 7, 10 then there is only one leader element 16. If there are no leaders in the given set of elements then print ‘No leaders’.

Input Format

Number of elements in the given set: ‘n’

element-1

element-2

element-n

Output Format VITspot Team - March 30, 2018

Updated 🙂
Check out at Leaders of Elements (Id-1244) Mayank Mishra - April 1, 2018

CSE 1002 Check if a matrix is sparse or not (ID-1490) Abhinav - April 2, 2018

pls post solutions for
CSE1002 Cyclic Right Shift of Elements (Id-1243)
CSE1002 Sort a Given Set of Points

error in
CSE1002 Names that Do Begin with Vowel- descending order RAHUL KUMAR - April 3, 2018

Insert into a Generic Box (Id-1492)

The given doesn’t working properly please fix it. raghav - April 4, 2018

CSE1002 Identify machines in same local network
CSE1002 Cyclic Right shift of elements
CSE1002 Insert into a Generic Box Daksh - April 5, 2018

I think the solutions for these are left. If you would kindly help:

CSE1002 Identify machines in same local network
CSE1002 Recursive Fibonacci
CSE1002 Vector operations
CSE1002 Generic Right Shift
CSE1002 3-D points- multiply and increment vivek - April 7, 2018

CSE1002 Leaders of Elements (Id-1244) Author:

Given a set of ‘n’ elements in an order, identify all the leaders and print them. An element is said to be a leader if all the elements to its right are smaller than it. For example, if the elements are 12, 13, 16, 7, 10 then there is only one leader element 16. If there are no leaders in the given set of elements then print ‘No leaders’.

Input Format

Number of elements in the given set: ‘n’

element-1

element-2

element-n

Output Format Rishabh Kansal - April 9, 2018

*** CSE1002 Check if a Matrix is Sparse or Not (Id-1490) *** Solution Please. Tonight is the last date Spiderman - April 21, 2018

Can you post an article on how to calculate the marks for CSE1002.

1
1 VINITH REDDY - November 7, 2018

hi ,we need questions for course code CSE1001 can u upload them FIKSHUN - April 2, 2019

CSE 1002 Generic right shift
Check if a matrix is sparse or not DEBJIT - April 7, 2019

INSERT INTO A GENERIC BOX
CHECK IF A MATRIX IS SPARSE OR NOT DEBJIT - April 7, 2019

INSERT INTO A GENERIC BOX

CHECK IF A MATRIX IS SPARSE OR NOT Gobind - April 9, 2019

Check if a Matrix is Sparse or Not
There are numerous applications of matrices, both in mathematics and other sciences. Some of them merely take advantage of the compact representation of a set of numbers in a matrix. Few to mention the application of matrices are game theory, economics, graph theory, quantum theory, probabilty theory and statistics. Each type of application use different type of data. Design a generic class matrix with functions to check if a matrix is sparse and add two matrices. A matrix is said to be sparse, if the number of zero’s in the matrix is larger than the number of non-zero elements. Define a user defined exception mismatchDimension and throw it when the dimension of matrix1 is not equal to dimension of matrix 2. Print “Dimension of matrices do not match” when the exception is caught.

Input Format:

Number of rows in matrix1

Number of columns in matrix1

Element1 in matrix1

Element2 in matrix1

Elementn in matrix1

Number of rows in matrix2

Number of columns in matrix2

Element1 in matrix2

Element2 in matrix2

Elementn in matrix2

Output Format:

Print elements of resultant matrix or Dimension of matrices do not match if exception is caught

Element1 in resultant matrix

Element2 in resultant matrix

Elementn in resultant matrix

Matrix is sparse or Matrix is not sparse Gobind - April 9, 2019

Today is the Last day
Please provide solution for this question:

Check if a Matrix is Sparse or Not
There are numerous applications of matrices, both in mathematics and other sciences. Some of them merely take advantage of the compact representation of a set of numbers in a matrix. Few to mention the application of matrices are game theory, economics, graph theory, quantum theory, probabilty theory and statistics. Each type of application use different type of data. Design a generic class matrix with functions to check if a matrix is sparse and add two matrices. A matrix is said to be sparse, if the number of zero’s in the matrix is larger than the number of non-zero elements. Define a user defined exception mismatchDimension and throw it when the dimension of matrix1 is not equal to dimension of matrix 2. Print “Dimension of matrices do not match” when the exception is caught.

Input Format:

Number of rows in matrix1

Number of columns in matrix1

Element1 in matrix1

Element2 in matrix1

Elementn in matrix1

Number of rows in matrix2

Number of columns in matrix2

Element1 in matrix2

Element2 in matrix2

Elementn in matrix2

Output Format:

Print elements of resultant matrix or Dimension of matrices do not match if exception is caught

Element1 in resultant matrix

Element2 in resultant matrix

Elementn in resultant matrix

Matrix is sparse or Matrix is not sparse