CBSE Class 12 – Computer Science Question Paper 2022

SECTION A

1.”Stack is a linear data structure which follows a particular order in which the operations are performed.”
What is the order in which the operations are performed in a Stack?
Answer:
The order in which operations are performed in a Stack is Last In, First Out (LIFO). The last element inserted is the first one to be removed.

Name the List method/function available in Python which is used to remove the last element from a list implemented stack.
Answer:
The Python List method used to remove the last element from a list is pop().

Also write an example using Python statements for removing the last element of the list.
Answer:

python
stack = [1, 2, 3, 4, 5]
stack.pop() # Removes the last element (5)
print(stack) # Output: [1, 2, 3, 4]

2.(i) Expand the following:

  • VOIP: Voice Over Internet Protocol
  • PPP: Point-to-Point Protocol

(ii) Riya wants to transfer pictures from her mobile phone to her laptop. She uses Bluetooth technology to connect two devices. Which type of network (PAN/LAN/MAN/WAN) will be formed in this case?
Answer:
The type of network formed in this case will be a PAN (Personal Area Network).

3.Differentiate between the terms Attribute and Domain in the context of Relational Data Model.
Answer:

  • Attribute: An attribute is a property or characteristic of an entity in a relation. It represents a column in a table and holds a specific type of data for each record (row). For example, in the MEMBER table, M_ID, NAME, and ACTIVITY are attributes.

  • Domain: A domain refers to the set of possible values that an attribute can have. It defines the type and the range of values that an attribute can take. For instance, the domain of the attribute M_ID might consist of numeric values, while the domain of the ACTIVITY attribute might include values such as ‘GYM’, ‘SWIMMING’, etc.

 

4.Consider the following SQL table MEMBER in a SQL Database CLUB:
Table MEMBER

M_ID NAME ACTIVITY
M1001 Amina GYM
M1002 Pratik GYM
M1003 Simon SWIMMING
M1004 Rakesh GYM
M1005 Avneet SWIMMING

Assume that the required library for establishing the connection between Python and MYSQL is already imported in the given Python code. Also assume that DB is the name of the database connection for the table MEMBER stored in the database CLUB.

Predict the output of the following code:

python
MYCUR = DB.cursor()
MYCUR.execute("USE CLUB")
MYCUR.execute("SELECT * FROM MEMBER WHERE ACTIVITY = 'GYM'")
R = MYCUR.fetchone()
for i in range(2):
R = MYCUR.fetchone()
print(R[0], R[1], sep="4")

Answer:
Let’s break down the code:

  1. MYCUR.execute("USE CLUB") tells the cursor to use the CLUB database.

  2. MYCUR.execute("SELECT * FROM MEMBER WHERE ACTIVITY = 'GYM'") will select all rows from the MEMBER table where the activity is ‘GYM’. This results in the following records:

    • M1001, Amina, GYM
    • M1002, Pratik, GYM
    • M1004, Rakesh, GYM
  3. R = MYCUR.fetchone() will fetch the first row from the result of the query. This row is M1001, Amina, GYM.

  4. The for loop will call MYCUR.fetchone() twice, which fetches the next two rows:

    • The second row is M1002, Pratik, GYM.
    • The third row is M1004, Rakesh, GYM.
  5. Finally, the print(R[0], R[1], sep="4") will print the values of R[0] and R[1] (which correspond to M_ID and NAME), separated by the number 4.

So, the output will be:

nginx
M1004Rakesh

(Note: The separator “4” in the sep parameter will be used between R[0] and R[1], which results in M1004 and Rakesh being printed together as M1004Rakesh.)

5.Write the output of SQL queries (a) to (d) based on the table VACCINATION_DATA given below:

TABLE VACCINATION_DATA

VID Name Age Dosel Dose2 City
101 Jenny 27 2021-12-25 2022-01-31 Delhi
102 Harjot 55 2021-07-14 2021-10-14 Mumbai
103 Srikanth 43 2021-04-18 2021-07-20 Delhi
104 Gazala 75 2021-07-31 NULL Kolkata
105 Shiksha 32 2022-01-01 NULL Mumbai

(a) SELECT Name, Age FROM VACCINATION_DATA WHERE Dose2 IS NOT NULL AND Age > 40;
Answer:
This query selects the Name and Age of individuals where Dose2 is not NULL and their Age is greater than 40.
Output:

Name Age
Harjot 55
Srikanth 43

(b) SELECT City, COUNT(*) FROM VACCINATION_DATA GROUP BY City;
Answer:
This query counts the number of people from each city.
Output:

City COUNT(*)
Delhi 2
Mumbai 2
Kolkata 1

(c) SELECT DISTINCT City FROM VACCINATION_DATA;
Answer:
This query selects the distinct cities in the VACCINATION_DATA table.
Output:

City
Delhi
Mumbai
Kolkata

(d) SELECT MAX(Dosel), MIN(Dose2) FROM VACCINATION_DATA;
Answer:
This query selects the maximum Dosel date and the minimum Dose2 date from the table.
Output:

MAX(Dosel) MIN(Dose2)
2022-01-01 2021-10-14

6.Write the output of SQL queries (a) and (b) based on the following two tables DOCTOR and PATIENT belonging to the same database:

Table DOCTOR

DNO DNAME FEES
D1 AMITABH 1500
D2 ANIKET 1000
D3 NIKHIL 1500
D4 ANJANA 1500

Table PATIENT

PNO PNAME ADMDATE DNO
P1 NOOR 2021-12-25 D1
P2 ANNIE 2021-11-20 D2
P3 PRAKASH 2020-12-10 NULL
P4 HARMEET 2019-12-20 D1

(a) SELECT DNAME, PNAME FROM DOCTOR NATURAL JOIN PATIENT;
Answer:
This query performs a NATURAL JOIN between the DOCTOR and PATIENT tables based on the DNO column.
Output:

DNAME PNAME
AMITABH NOOR
ANIKET ANNIE
AMITABH HARMEET

(b) SELECT PNAME, ADMDATE, FEES FROM PATIENT P, DOCTOR D WHERE D.DNO = P.DNO AND FEES > 1000;
Answer:
This query joins the PATIENT and DOCTOR tables and filters the results based on FEES > 1000.
Output:

PNAME ADMDATE FEES
NOOR 2021-12-25 1500
HARMEET 2019-12-20 1500

(a)

Identify and write the name of the most appropriate column from the given table PLAYER that can be used as a Primary key.

Answer:
The most appropriate column to use as a primary key is typically a column that contains unique values for each record. Without the actual table PLAYER data, the column that would serve as the primary key should be something like PLAYER_ID, ID, or similar, assuming it uniquely identifies each player. If there is a column that uniquely identifies each player, it should be used as the primary key.


(b)

Define the term Degree in relational data model. What is the Degree of the given table PLAYER?

Answer:

  • Degree: In the context of a relational data model, the degree of a table refers to the number of attributes (or columns) in that table. It is the number of columns in a relation.

  • Degree of the table PLAYER: The degree of the PLAYER table would be the number of columns it contains. If you can provide the column names, the degree would be the count of those columns.

SECTION B

8. Write the definition of a user-defined function PushNV (N) which accepts a list of strings in the parameter N and pushes all strings which have no vowels present in it, into a list named NoVowel.

Write a program in Python to input 5 words and push them one by one into a list named All.
The program should then use the function PushNV() to create a stack of words in the list NoVowel so that it stores only those words which do not have any vowel present in it, from the list All.
Thereafter, pop each word from the list NoVowel and display the popped word. When the stack is empty, display the message “EmptyStack”.
For example:
If the Words accepted and pushed into the list All are
['DRY', 'LIKE', 'RHYTHM', 'WORK', 'GYM']

Then the stack NoVowel should store
["DRY', 'RHYTHM', 'GYM']
And the output should be displayed as
GYM RHYTHM DRY EmptyStack


Answer for Problem 8:

python
# Function to push words with no vowels into a list
def PushNV(N):
NoVowel = [] # List to store words without vowels
vowels = "aeiouAEIOU"

for word in N:
# Check if the word contains any vowels
if not any(vowel in word for vowel in vowels):
NoVowel.append(word) # Push the word into NoVowel stack
return NoVowel

# Input 5 words into the list All
All = []
for i in range(5):
word = input(f"Enter word {i+1}: ")
All.append(word)

# Create the NoVowel stack using PushNV
NoVowel = PushNV(All)

# Pop from NoVowel stack and display the popped word
while NoVowel:
print(NoVowel.pop(), end=" ")

# Display the message when stack is empty
if not NoVowel:
print("EmptyStack")

Explanation:

  1. The function PushNV takes a list N of words.
  2. It checks each word to see if it contains any vowels.
  3. If a word does not contain vowels, it is added to the list NoVowel.
  4. In the main part of the program, the words are input, stored in the list All, and the function PushNV is called to filter words without vowels.
  5. The words in NoVowel are popped one by one and displayed. When the stack is empty, the message "EmptyStack" is shown.

OR

Write the definition of a user-defined function Push3_5(N) which accepts a list of integers in the parameter N and pushes all those integers which are divisible by 3 or divisible by 5 from the list into a list named Only3_5.

Write a program in Python to input 5 integers into a list named NUM.
The program should then use the function Push3_5() to create the stack of the list Only3_5. Thereafter, pop each integer from the list Only3_5 and display the popped value. When the list is empty, display the message “StackEmpty”.
For example:
If the integers input into the list NUM are:
[10, 6, 14, 18, 30]

Then the stack Only3_5 should store
[10, 6, 18, 30]
And the output should be displayed as
30 18 6 10 StackEmpty


Answer for the OR problem:

python
# Function to push numbers divisible by 3 or 5 into a list
def Push3_5(N):
Only3_5 = [] # List to store numbers divisible by 3 or 5
for number in N:
# Check if the number is divisible by 3 or 5
if number % 3 == 0 or number % 5 == 0:
Only3_5.append(number) # Push the number into Only3_5 stack
return Only3_5

# Input 5 integers into the list NUM
NUM = []
for i in range(5):
num = int(input(f"Enter integer {i+1}: "))
NUM.append(num)

# Create the Only3_5 stack using Push3_5
Only3_5 = Push3_5(NUM)

# Pop from Only3_5 stack and display the popped number
while Only3_5:
print(Only3_5.pop(), end=" ")

# Display the message when stack is empty
if not Only3_5:
print("StackEmpty")

Explanation:

  1. The function Push3_5 takes a list N of integers.
  2. It checks if each number is divisible by either 3 or 5.
  3. If the number is divisible by 3 or 5, it is added to the Only3_5 list.
  4. In the main program, the integers are input, stored in the list NUM, and the function Push3_5 is called to filter the numbers.
  5. The numbers in Only3_5 are popped one by one and displayed. When the stack is empty, the message "StackEmpty" is shown.

Example Inputs and Outputs:

Example 1:

Input (for words with no vowels):

arduino
Enter word 1: DRY
Enter word 2: LIKE
Enter word 3: RHYTHM
Enter word 4: WORK
Enter word 5: GYM

Output:

nginx
GYM RHYTHM DRY EmptyStack

Example 2:

Input (for numbers divisible by 3 or 5):

bash
Enter integer 1: 10
Enter integer 2: 6
Enter integer 3: 14
Enter integer 4: 18
Enter integer 5: 30

Output:

30 18 6 10 StackEmpty

9.(i) A SQL table ITEMS contains the following columns: INO, INAME, QUANTITY, PRICE, DISCOUNT. Write the SQL command to remove the column DISCOUNT from the table.

Answer:

sql
ALTER TABLE ITEMS
DROP COLUMN DISCOUNT;

This SQL command will remove the DISCOUNT column from the ITEMS table.


(ii) Categorize the following SQL commands into DDL and DML:

Commands:

  • CREATE
  • UPDATE
  • INSERT
  • DROP

Answer:

  • DDL (Data Definition Language):
    These commands are used to define or modify the structure of the database.

    • CREATE (used to create tables, databases, etc.)
    • DROP (used to delete tables, databases, etc.)
  • DML (Data Manipulation Language):
    These commands are used to manipulate data in the database.

    • UPDATE (used to modify existing data)
    • INSERT (used to insert new data into tables)

10. Rohan is learning to work upon Relational Database Management System (RDBMS) application. Help him to perform following tasks:

(a) To open the database named “LIBRARY”.

Answer:

sql
USE LIBRARY;

This SQL command will switch the context to the LIBRARY database, making it the current database for operations.


(b) To display the names of all the tables stored in the opened database.

Answer:

sql
SHOW TABLES;

This SQL command lists all the tables in the currently selected database (LIBRARY).


(c) To display the structure of the table “BOOKS” existing in the already opened database “LIBRARY”.

Answer:

sql
DESCRIBE BOOKS;

This SQL command displays the structure of the BOOKS table, including column names, data types, and constraints.

SECTION C

11. Write SQL queries for (a) to (d) based on the tables PASSENGER and FLIGHT given below:

Table: PASSENGER

PNO NAME GENDER FNO
1001 Suresh MALE F101
1002 Anita FEMALE F104
1003 Barjas MALE F102
1004 Nita FEMALE F103

Table: FLIGHT

NO START END F_DATE FARE
F101 MUMBAI CHENNAI 2021-12-25 4500
F102 MUMBAI BENGALURU 2021-11-20 4000
F103 DELHI CHENNAI 2021-12-10 5500
F104 KOLKATA MUMBAI 2021-12-20 4500
F105 DELHI BENGALURU 2021-01-15 5000

(a) Write a query to change the fare to 6000 of the flight whose FNO is F104.

Answer:

sql
UPDATE FLIGHT
SET FARE = 6000
WHERE NO = 'F104';

This query updates the fare of the flight with FNO = F104 to 6000.


(b) Write a query to display the total number of MALE and FEMALE PASSENGERS.

Answer:

sql
SELECT GENDER, COUNT(*) AS Total_Passengers
FROM PASSENGER
GROUP BY GENDER;

This query counts the total number of male and female passengers by grouping the data based on the GENDER column.


(c) Write a query to display the NAME, corresponding FARE, and F_DATE of all PASSENGERS who have a flight to START from DELHI.

Answer:

sql
SELECT P.NAME, F.FARE, F.F_DATE
FROM PASSENGER P
JOIN FLIGHT F ON P.FNO = F.NO
WHERE F.START = 'DELHI';

This query joins the PASSENGER and FLIGHT tables on the flight number (FNO), and then filters passengers whose flight starts from DELHI.


(d) Write a query to delete the records of flights which end at Mumbai.

Answer:

sql
DELETE FROM FLIGHT
WHERE END = 'MUMBAI';

This query deletes all flight records where the END column has the value 'MUMBAI'.


12.

(i) Differentiate between Bus Topology and Tree Topology. Also, write one advantage of each of them.

Answer:

  • Bus Topology:
    • In bus topology, all devices are connected to a single central cable (bus), and data travels along this bus.
    • Advantage: Easy to implement and extend as new devices can be added without disrupting the network.
  • Tree Topology:
    • Tree topology combines characteristics of bus and star topologies, where groups of star-configured networks are connected to a central bus.
    • Advantage: Scalability, as it allows for the addition of more nodes without much complexity.

(ii) What is a web browser? Write the names of any two commonly used web browsers.

Answer:

  • Web Browser:
    A web browser is a software application used to access and view websites on the internet. It interprets and displays HTML pages and other content like text, images, and videos.

  • Commonly used web browsers:

    1. Google Chrome
    2. Mozilla Firefox

13. Galaxy Provider Ltd. is planning to connect its office in Texas, USA with
its branch at Mumbai. The Mumbai branch has 3 Offices in three blocks located at some distance from each other for different operations ADMIN, SALES and ACCOUNTS.
As a network consultant, you have to suggest the best network related solutions for the issues/problems raised in (a) to (d), keeping in mind the distances between various locations and other given parameters.
Layout of the Offices in the Mumbai branch:

Shortest distances between various locations:
Sales Block
ADMIN Block to SALES Block
300 m
SALES Block to ACCOUNTS Block
175m
ADMIN Block to ACCOUNTS Block
350 m
MUMBAI Branch to TEXAS Head Office
14000 km

Number of Computers installed at various locations are as follows:
ADMIN Block
ACCOUNTS Block
SALES Block
TEXAS Head Office
255
75
30
88
90
(a) It is observed that there is a huge data loss during the process of data transfer from one block to another. Suggest the most appropriate networking device out of the following, which needs to be placed along the path of the wire connecting one block office with another to refresh the signal and forward it ahead.
(1) MODEM
(iii) REPEATER
(ii) ETHERNET CARD
(iv) HUB
(b) Which hardware networking device out of the following, will you suggest to connect all the computers within each block?
(1) SWITCH
(iii) REPEATER
(ii) MODEM
(iv) ROUTER
(c) Which service/protocol out of the following will be most helpful to conduct live interactions of employees from Mumbai Branch and their counterparts in Texas?
(1) FTP
(iii) SMTP
(ii) PPP
(iv) Volp
(d) Draw the cable layout (block to block) to efficiently connect the three
offices of the Mumbai branch.

Answers:

(a) Question: It is observed that there is a huge data loss during the process of data transfer from one block to another. Suggest the most appropriate networking device out of the following, which needs to be placed along the path of the wire connecting one block office with another to refresh the signal and forward it ahead.  

 

Options: (i) MODEM (ii) ETHERNET CARD (iii) REPEATER (iv) HUB

Answer: (iii) REPEATER

(b) Question: Which hardware networking device out of the following, will you suggest to connect all the computers within each block?

Options: (i) SWITCH (ii) MODEM (iii) REPEATER (iv) ROUTER

Answer: (i) SWITCH

(c) Question: Which service/protocol out of the following will be most helpful to conduct live interactions of employees from Mumbai Branch and their counterparts in Texas?  

 

Options: (i) FTP (ii) PPP (iii) SMTP (iv) VoIP

Answer: (iv) VoIP

(d) Question: Draw the cable layout (block to block) to efficiently connect the three offices of the Mumbai branch.

(This requires a visual answer, which I cannot directly provide. The answer is a Star Topology.)

Description of Star Topology for (d): A central switch is placed in a convenient location. Cables (ideally fiber optic) run from each of the three blocks (Admin, Accounts, and Sales) to this central switch. Each block’s network connects to a port on the switch.