CTSd-In-Sem-2 Sample QP

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

IN-SEM EXAM – 2

CTSD SAMPLE QUESTION PAPER

QNo Sub Ques on Marks BTL CO Max Marks


1 A Mr.Kim is a coding whiz. Help him to find length of 2 2 CO1 12 marks
the string without using string library func on.
B Write a C program to find reminder of two 2 2
numbers using command line arguments.
C Write a C program that dynamically allocates 2 2
memory for an integer array. Allocate memory for No Choice
an array of a predefined size, ini alize the array
with default values, and ensure proper
dealloca on of the allocated memory.
D Describe the Last In, First Out (LIFO) principle of a 2 2 CO2
stack. Provide a real-world analogy to illustrate this
concept.
E Describe, in detail, the methods for accessing 2 2
structure members in C
F Explain the fundamental difference between a 2 2
stack and a queue in data structures.
2 A Compare and contrast the malloc and calloc 4 2 CO1 16 marks
func ons in C, highligh ng their differences and
discussing the specific circumstances in which you No choice
would opt for one func on over the other.
B Develop a C func on to find second highest data in 4 2
the given array
C Perform the following opera ons on an empty 4 2 CO2
stack of size 3 and draw the status of the stack a er
every opera on: push (25), push(12), push (76),
pop(), pop(), push (25), push(29) and pop()
D Define parent nodes, child nodes, and leaf nodes 4 2
in a tree data structure. Consider your own tree
structure and represent parent nodes, child
nodes, and leaf nodes.
3 A Given a square matrix, calculate the absolute 5 3 CO1 11 marks
difference between the sums of its diagonals. For
example, the square matrix arr is shown below: 1 2 Q3 or Q4
34 5 6 9 8 9 The le -to-right diagonal = 1 + 5 + 9 =
15. The right to le diagonal = 3 + 5 + 9 = 17. Their
absolute difference is | 15-17| = 2.
B Suppose that the input array contains the 6 3
integers1,2,3,4,5,6,7,8 in order. Write a binary
search func on and trace it to determine what
comparisons of keys are done in searching for the
following targets:
(i) 3(ii) 5 (iii) 1 (iv) 9 (v) 4.5
4 A Noddy was driving his car very fast, and he was 5 3
caught by the policeman Mr. Plod. As a
punishment, Mr. Plod gave Noddy a set of strings
and asked him to determine whether each string
contains all the vowels (a, e, i, o, u). If Noddy can
correctly iden fy whether all the given strings
contain all the vowels, he will be allowed to leave
without further consequences. However, since
Noddy is not proficient in string manipula on, he
seeks your assistance in solving this challenge. Can
you help Noddy by providing a solu on to check
whether each given string contains all the vowels?
B Design a code to accept the age of n students of a 6 3
class. Rearrange the data in ascending order
(smallest value to largest value). Display the age of
the youngest and eldest student in the class.
5 A You are assigned the task of crea ng a program to 5 3 CO2 11 marks
convert an integer into its binary representa on
using a stack-based approach. The process requires Q5 or Q6
dividing the integer by 2, pushing the remainders
onto a stack un l the quo ent becomes zero, and
finally popping the stack to construct the binary
representa on.
B Develop a C func on for the following opera ons 6 3
on the linked list and analyse them: a) Store
element at the beginning of the list. b) Delete the
element at the specific posi on from the list.
6 A Declare a structure me that has three fields 5 3
hours, minutes and seconds. Create two variables.
Start_ me and end_ me. Input their values from
the user. Then display me dura on between
start_ me and end_ me.
Sample Input:
Enter start Time Hours: 9 Minutes: 25 Seconds: 10
Enter end me: Hours: 9 Minutes: 50 seconds:10
Sample output:
25 minutes
B Develop C func ons to implement following 6 3
opera ons on Queue data structure of size 5
i) Insert values into a Queue
ii) Delete the elements from the Queue
iii) Draw the Queue structure a er each inser on
opera on while inser ng 10, 15, 22 and 16 and
also a er performing 3 delete opera ons

You might also like