0% found this document useful (0 votes)
30 views

Spring 2024 - CS304P - 2

Uploaded by

saleensidhu870
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Spring 2024 - CS304P - 2

Uploaded by

saleensidhu870
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment No.

02 Total Marks: 20
Semester: Spring 2024
Due Date: 24 June, 24
CS304P- Object Oriented Programming - Practical

Objective
To give you an idea of the practical implementation of the following concepts of Object-Oriented Programming
(OOP):
Class: Involves declaration of the class, its member functions, and objects.
Templates: Class templates and function templates.

Uploading instructions:

• Your assignment should be in .CPP format (Any other formats like scan images, PDF, zip, doc, rar and bmp
etc. will not be accepted).
• Save your assignment with your ID (e.g. bc000000000.CPP).
• No assignment will be accepted through email.

Rules for Marking:

It should be clear that your assignment will not get any credit if:

• The assignment is submitted after the due date.


• The submitted assignment does not open, or execute or the file is corrupted.
• Your assignment is copied from the internet, handouts, or any other student.
(Strict disciplinary action will be taken in this case).

Lectures Covered:

This assignment covers Labs # 10 - 11.


Assignment No. 2

Problem Statement:
Suppose you are working as a junior programmer in an organization. The organization uses different data compression
algorithms before sending a message to reduce the communication bandwidth and transmission time. You are asked
to implement a simple compression algorithm known as Run-Length Encoding (RLE). In RLE, consecutive
occurrences of the same character/number are replaced by a single occurrence of the character/number followed by
the count of its occurrences.

Example Of RLE:
Consider the string: "A A A A B B B C C D A A "
Encoding Process:
• the runs of consecutive characters:
Identify the runs of consecutive characters:
o A A A A (four 'A's)
o B B B (three 'B's)
o C C (two 'C's)
o D (one 'D')
o A A (two 'A's)
• Encode each run as the character followed by the count of repetitions:
o A A A A becomes A4
o B B B becomes B3
o C C becomes C2
o D becomes D1
o A A becomes A2
• Combine these encoded segments into a single string:
o "A4B3C2D1A2"
Final Encoded Output:
"A4B3C2D1A2"
Question Statement:
Write Dev C++ code for the above scenario. The program can compress any type of data: integer, float, characters,
and symbols.
Consider the following points while writing the code:
• Write a single template class to encode integer, character, float, and symbol data.
• The input should be of one data type only. For example, in the case of integer type input, the input string
should be all integers e.g. 2 2 2 3 3 3 3. In the case of character type input, the input string should be all
characters. a a a a b b b b.
• In the main() function, initialize four arrays; one for each data type(int, char, float, symbol).
• Encode array data and display the actual and encoded message as shown in the screenshot of the output of all
types of data.

Note: The C++ program should contain only a template class with an encode function and a main() function only.
Sample Output:

Guidelines for Solution:


Save the program using your personal VUID. Your VUID will therefore appear at the top of the screen.

Best of luck!
NOTE: Do not put any query on MDB about this assignment, if you have any query then email at [email protected].
Furthermore, if any student is found cheating by any other student or from online forums then he/she will be awarded
ZERO right away and strict disciplinary action will be taken against the student.

Deadline: Your assignment must be uploaded/submitted on or before 24 June 2024.

You might also like