0% found this document useful (0 votes)
1K views4 pages

UCEST105 Algorithmic Thinking With Python MODEL QP SEMESTER 1

Uploaded by

mynoteskl
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)
1K views4 pages

UCEST105 Algorithmic Thinking With Python MODEL QP SEMESTER 1

Uploaded by

mynoteskl
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

MODEL QUESTION PAPER

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY


FIRST SEMESTER B. TECH DEGREE EXAMINATION, DECEMBER 2024

Course Code: UCEST105


Course Name: Algorithmic Thinking with Python
Max. Marks: 60 Duration: 2 hours 30 minutes

PART A
Answer all questions. Each question carries 3 marks CO Marks
1 How do you use a decomposition strategy to design a menu-driven calculator 1 (3)
that supports four basic arithmetic operators - addition, subtraction,
multiplication, and division?
2 A mad scientist wishes to make a chain out of plutonium and lead pieces. 4 (3)
There is a problem, however. If the scientist places two pieces of plutonium
next to each other, BOOM! The question is, in how many ways can the
scientist safely construct a chain of length n?
3 Write a case statement that will examine the value of flag and print one of the 3 (3)
following messages, based on its value.

Flag value Message

1 Hot

2 Luke warm

3 Cold

Any other value Out of range

4 Draw a flowchart to print the numbers that are divisible by 4 but not by 3 in a 3 (3)
list of n positive numbers.
5 Identify and rectify the problem with the following recursive definition to find 4 (3)
the greatest common divisor of two positive integers.
ABC ( n , m )
if n == 2 return m
else return ABC(m , n mod m)
6 Write a recursive procedure to search for a key in a list of n integers. 4 (3)
7 Compare and contrast greedy and dynamic programming strategies. 3 (3)

Page 1 of 4
8 Give the pseudocode for brute force technique to find the mode of elements 3 (3)
in an array. Mode is the value that appears most frequently in the array.
PART B
Answer any one full question from each module. Each question carries 9 marks
Module 1
9 Walk through the six problem-solving steps to find the largest number out of 1 (9)
three numbers.
10 a) Your professor has given you an assignment on “Algorithmic thinking” to be 2 (5)
submitted by this Wednesday. How do you employ means-end analysis to
devise a strategy for completing your assignment before the deadline?
b) Name two current problems in your life that might be solved through a 1 (4)
heuristic approach. Explain why each of these problems can be solved using
heuristics.
Module 2
11 a) Mr. Shyam, a history professor, would like to know the percentage increase 3 (6)
in the population of our country per decade given the first decade and the last
decade. Other given data include the population at the beginning of each
decade. Draw a flowchart for determining the percentage increase in the
population.
b) Draw a flowchart to find the average mileage of a car in kilometers per litre 3 (3)
after six fill-ups at petrol pumps. Input data include the number of litres of
diesel, the starting odometer reading, and the odometer reading at each fillup.
12 a) A standard science experiment is to drop a ball and see how high it bounces. 3 (6)
Once the “bounciness” of the ball has been determined, the ratio gives a
bounciness index. For example, if a ball dropped from a height of 10 feet
bounces 6 feet high, the index is 0.6, and the total distance traveled by the ball
is 16 feet after one bounce. If the ball were to continue bouncing, the distance
after two bounces would be 10 ft + 6 ft + 6 ft + 3.6 ft = 25.6 ft. Note that the
distance traveled for each successive bounce is the distance to the floor plus
0.6 of that distance as the ball comes back up. Write an algorithm that lets the
user enter the initial height of the ball, bounciness index and the number of
times the ball is allowed to continue bouncing. Output should be the total
distance traveled by the ball.

Page 2 of 4
b) Light travels at 3 × 108 meters per second. A light-year is the distance a light 3 (3)
beam travels in one year. Write an algorithm that inputs a large distance value
(in meters) and displays it in light-years.
Module 3
13 a) Write a recursive function to find an array's minimum and maximum 4 (5)
elements. Your method should return a tuple (a, b), where a is the minimum
element and b is the maximum.
b) Write a program to input a matrix and determine its type: lower triangular, 4 (4)
upper triangular, or diagonal.
14 a) Write a program to read N words and display them in the increasing order of 4 (6)
their lengths. The length of each word is also to be displayed.
b) There are 500 light bulbs (numbered 1 to 500) arranged in a row. Initially, 4 (3)
they are all OFF. Starting with bulb 2, all even numbered bulbs are turned
ON. Next, starting with bulb 3, and visiting every third bulb, it is turned ON
if it is OFF, and it is turned OFF if it is ON. This procedure is repeated for
every fourth bulb, then every fifth bulb, and so on up to the 500th bulb. Devise
an algorithm to determine which bulbs glow at the end of the above exercise.
Module 4
15 a) Studies show that the capacity of an empty human stomach is 1.5 litres on 3 (6)
average. Give a greedy algorithm to output an efficient lunch menu
maximizing the total nutritional value. The available items along with their
nutritional values are tabulated below:

Available Nutritional
Recipe
quantity value

Cooked rice 2.5 cups 800 calories

Sambar 1.5 cups 140 calories

Potato curry 0.5 cup 50 calories

Page 3 of 4
Fish fry 0.5 cup 200 calories

Buttermilk 1 cup 98 calories

Payasam 2 cups 300 calories

You may assume that 1 cup is equivalent to 250ml.


b) How are recursion and dynamic programming (DP) related? Is it possible to 2 (3)
construct a DP version for all recursive solutions?
16 a) Write a Python program for a random walk simulation in a 2D grid starting 3 (4)
from the origin (0, 0). At each step, randomly move up, down, left, or right.
Print the final position after 10 steps.
b) Use divide and conquer to find the majority element in an array, where the 2 (5)
majority element appears more than n/2 times. Divide the array into two
halves, find the majority element in each half, and combine the results to
identify if there is a majority element in the entire array.
*****

Page 4 of 4

You might also like