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

COL 100 Assignment 5

The document provides instructions for Assignment 5 in an Introduction to Computer Science course. It details the assignment requirements including weight, submission platform, deadline, and support channels. It also provides additional resources for concepts covered in the assignment. The document then describes two problems - one involving encrypting and decrypting nuclear codes using bitwise XOR recursion, and another involving managing employee records using C structures. It provides sample inputs and outputs for the employee records problem.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

COL 100 Assignment 5

The document provides instructions for Assignment 5 in an Introduction to Computer Science course. It details the assignment requirements including weight, submission platform, deadline, and support channels. It also provides additional resources for concepts covered in the assignment. The document then describes two problems - one involving encrypting and decrypting nuclear codes using bitwise XOR recursion, and another involving managing employee records using C structures. It provides sample inputs and outputs for the employee records problem.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

COL100

Introduction to Computer Science


Assignment 5
1 Instructions
Dear Students, Assignment 5 has been released on Gradescope. Below, you’ll find im-
portant details regarding the assignment, submission guidelines, and support channels
for any queries.

1.1 Assignment Details:


Weightage: 8% of the overall grade
Submission Platform: Gradescope (https://www.gradescope.com/courses/561465)
Deadline: 21st October 2023, 11:55pm

1.2 Support and Queries:


1. All queries about this assignment should be posted only in the relevant
Piazza board. No other queries shall be entertained. Please read through the
previously posted queries before posting.

2. Before using any function from any existing library or using any algo-
rithm not covered in the class, get a confirmation from the instructors
by posting on Piazza.

Additional Resources:
For a refresher on the concepts related to the assignment, you can refer to the course
lecture notes, slides, and relevant sections from the textbook. Assignment Grading:
Your assignments will be graded on correctness, efficiency of your code, proper usage of
comments, and adherence to the submission guidelines. We wish you the best of luck
with the assignment.
2 BitCrypt
With the ongoing disputes between countries, safeguarding the nuclear codes have become
a major challenge. You are appointed by the Defense Ministry of India to devise a robust
encryption-decryption technique to secure the nuclear codes of India. With your love for
bitwise XOR and recursion, you decide to deploy a recursive encryption algorithm.
Following is the truth table for XOR:

Input A Input B Output


0 0 0
0 1 1
1 0 1
1 1 0

Assume that the number is 7 (Binary: 111) and the key is 5 (Binary: 101) A bitwise
XOR would yield the output as 010. Hence, 2 (Binary: 010) would be the encrypted
message.
Encrypted message: 010 and the key: 101

Algorithm 1: XOR Encryption


Function Encrypt(n, key)
If n = 0 or key = 0
Return 0
End If
extract the least significant bit of the number (bit_n) and the
key (bit_key)
Return Encrypt(floor(n / 2), floor(key / 2)) * 2 + (bit_n XOR bit_key)
End Function

Note: To ensure that recursion is used to solve the problem, we will output certain
intermediate state values for testing and check for stack depth. Learn more about stack
depth here: https://www.youtube.com/watch?v=BNeOE1qMyRA

3 Handling Employees Data


In this problem you have to write a program to manage employee records using C struc-
tures. Each employee has the following attributes:

1. Employee ID (integer)

Page 2
2. First Name (string)

3. Last Name (string)

4. Salary (integer)

5. Joining Date (string) (dd/mm/yyyy format)

You need to implement the following tasks by creating function for each task:

1. Task 1 : Add each new Employee.

2. Task 2 : Delete an Employee record by Employee ID.

3. Task 3 : Display the details of a particular employee by Employee ID.

4. Task 4 : Display the details of all employees.

5. Task 5 : Update the salary of an employee by Employee ID.

6. Task 6 : Display the statistical detail of employees salary which are currently work-
ing in company. Statistical Detail include Minimum,Maximum and Mean(Average)
value of Salary for currently working Employees upto two decimal place.

7. Task 7 : Find the number of employees working in company for a given particular
date.

You should use an array of structures to store the employee records.

3.1 Input Format of each Task :


1. Task 1 : 1 23 John Doe 1200 12/03/2012

Here 1 is represent Task 1, ”23” represent Employee ID, ”John” represent First
Name, ”Doe” represent Last Name, ”1200” represent salary, ”12/03/2012” repre-
sent Joining Date.

2. Task 2 : 2 23.

Here 2 represent Task 2, ”23” represent Employee ID which to be deleted from


Company record list.

Page 3
3. Task 3 : 3 23

Here 3 represent Task 3, ”23” represent Employee ID whose detailed to display.

4. Task 4 : 4

Here 4 represent Task 4 , in this you have to display details of all Employees
currently working at company.
5. Task 5 : 5 23 1500

Here 5 represent Task 5, ”23” represent Employee ID whose salary to be up-


dated(not increment) to 1500. Now employee with ID ”23” new salary is now
1500.
6. Task 6 : 6

Here 6 represent Task 6, in this you have to display the Minimum, Maximum
and Mean value of Salary of currently working Employees.
7. Task 7 : 7 06/04/2012

Here 7 represent Task 7, You have to print a number which represent number
of employees currently working at company on 06/04/2012.

3.2 Constraints on Input:


Joining Date: Format of date will be dd/mm/yyyy.

Salary : It will belong to range [100,100000].

Number of employees : It will not exceed 100.

3.3 Sample Input


9
1 23 John Doe 1200 12/03/2012
1 16 Anu Arora 1500 09/03/2012
1 8 Dheeraj Kumar 1800 12/03/2014
3 16
2 16
4
5 8 1700

Page 4
6
7 10/04/2013

3.4 Sample Output


16 Anu Arora 1500 09/03/2012
8 Dheeraj Kumar 1800 12/03/2014
23 John Doe 1200 12/03/2012
1200 1700 1450
1

3.5 Explanation
First line in Sample Input is 9 which represent number of tasks to perform.

Next line in Sample Input is 1 23 John Doe 1200 12/03/2012 which represent Task
1 i.e., Adding employee John Doe with ID 23, Salary 1200 and Joining Data 12/03/2012.

Next line in Sample Input is 1 16 Anu Arora 1500 09/03/2012 which represent
Task 1 i.e., Adding employee Anu Arora with ID 16, Salary 1500 and Joining Data
09/03/2012.

Next line in Sample Input is 1 8 Dheeraj Kumar 1800 12/03/2014 which repre-
sent Task 1 i.e., Adding employee Dheeraj Kumar with ID 8, Salary 1800 and Joining
Data 12/03/2014.

Next line in Sample Input is 3 16 which represent Task 3 i.e., Displaying details of
employee with ID 16. Hence in First line of Sample Output ,detail of employee with id
16 (i.e., Anu Arora) is printed/displayed.

Next line in Sample Input is 2 16 which represent Task 2 i.e., Removing details of
employee with ID 16(i.e., Anu Arora).

Next line in Sample Input is 4 which represent Task 4 i.e., Displaying details of all
employees currently working on company. As for now ”Anu Arora” is removed from list
of employees so the remaining employee ”Dheeraj Kumar” and ”John Doe” details will
be display (as can be seen in Sample Output line 2 and 3). Output/Print details of
each employee according to their employee ID in ascending order.

Page 5
Next line in Sample Input is 5 8 1700 which represent Task 5 i.e., Salary of employee
”Dheeraj Kumar” (with Id 8) is changed from 1800 to 1700.

Next line in Sample Input is 6 which represent Task 6 i.e., To display the statistical
data of employees salaries who are currently working in the company. Hence as we have
two employees left in company ”Dheeraj Kumar” and ”John Doe” with salary 1700 and
1200 respectively. Hence Minimum, Maximum and Mean value will be 1200 , 1700 and
1450 respectively.

Next line in Sample Input is 7 10/04/2013 which represent Task 7 i.e., To count
the number of employees which are working on 10/04/2013.

As from our employees list we can see that only ”John Doe” had start working from
12/03/2012 and ”Dheeraj Kumar” join later (i.e., from 12/03/2014). Hence ”John
Doe” is the only employee who is working on 10/04/2013”. Hence count=1.

Note : Each task will be performed on current list of employees during that particular
task time.

Page 6

You might also like