0% found this document useful (0 votes)
20 views2 pages

DAA A1 Winter Semester 24-25

Uploaded by

nomercyrkgaming
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)
20 views2 pages

DAA A1 Winter Semester 24-25

Uploaded by

nomercyrkgaming
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/ 2

VIT

1cllore Institute of
CENNAI Technnlogy

Continuous Assessment Test I-


January 2025
Programnme B.Toch.(CSE) Algorithms Semester Wintcr 2024-25
Design and Analysis of p Code BCSE 204L
MJanaki mecna, D,
Coursc
Faculty Dr.L. Jeganathan, Dr
Dr. Suguna.
Slot/Class No. A1/CH202425050
Jayaram, Dr USrinivasa Rao, 1844,1830,1832,
Sree T
Dr. Lekshmi K, Dr. Raja 1824,1846,1848,1851
90 Minutes Max. Marks 50
Time
Instructions:

Answer all the FOUR questions.


assume the same and mention
" If any assumptions are required, should have both the design those assumptions in the answer script.
Your answer for all the questions component and the 'analysis component
The 'Design'component should consist: logic to devetop the pseudocode, illustration and pseudocode.
The 'Analysis' component should consist: Proot-or-Coeetness, Computation of T(n), Time-complexity.

1. Given two positive integers a and b with a 0,6 0, we usually say that a is less than or equal to b
(denoted by a <b) if the value of ais maller than or equal to the value of b. Here, we define a new
relation sk, as follows: a is said to be less than or equal to b with respect to k(denoted by a sk b) if
a+b#k. Given n distinct positive integers a1, a2, -., a, with n > 3, and apositive integer
k,anddesign a pseudocode which will output the integers a,, as, , a, such that, for any a
a1,1 <i<n-1, a Sk a1 where the relation 's*' is the new relation defined above
and a e {a, ag, a3.., an}, for all i. Your 'design' should involve all the required steps. Analyse your
algorithm with all the steps involved. You can follow any strategy for designing the algortihm. Your
pseudocode should be designed in such a way that there will be only one output for a given input. For
example, if (4,3, 1,2) and k = 5 your pseudocode should output the sequence [1,2, 4, 3.] (10 marks
|Rubrics: Logic for pseudocode: 3marks, Ilustration for pseudocode : 3marks, Pseudocode : 3marks,
Time-complexity :1 mark ]
2. Given an array A[1...n] of nintegers and two positive numbers z and y, design a pseudocode to compute
a longest contiguous subarray whose sum is maximum subject to the following constraints.
i) The sum of the subarray must not exceed I.
ii) The number of elerments in the subarray must not exceed u.
For the input (2, 1, 5,3, 4, 2], if z= 8,y = 3, your pseudocode should output [2, 1, 5]. Also, if a = 8,y =2,
then the output will be (5,3]. If such a longest contiguous subarray is not possible for the given input,
your pseudocode should output -1. Your design' should involve all the required steps. Analyse your
algorithm with all the steps involved. (10 marks)
Rubrics: Logic for pseudocode: 2 marks, llustration for pseudocode : 2 marks, Pseudocode : 3 marks,
Proof-of-Correctness: 2 marks , Time-complexity :1 mark )
3. Frequency of an integer in an array is the number of occurences of that. number in the array. Given an
array A of n integers, design two different algorithms each using two different design tech-
niques to arrange the integers of Ain such a way that the integers with higher frequency
appears first. If two integers have the same frequency, sort them in an ascending order. For the input
4.5,.6,5.6,4,33.6,13),
involve your pscudoocde should give the output (6.6.6,3,3,4,4,5,5,13). Your 'dosign' should
all the requirod
steps. Analysc your all the stcpsinvolved. |15 marks)
|Rubrics: Logic: 1 +l marks, Illustration: algorithm
2+2 marks,with Pscudocodc: 3+3marks, Timc-complcxity
:1.5 + 1.5 mark |
4. Consider the pscudo-code given in and answer the following: |15 marks
Algorithm-1
(a) Describethe functionality of the
above algorithm. (3 marks)
(b) Compute the
time-complexity of the algorithm. (2 marks]
(c) What will be the output for the inputs : [2.2.2,2,2), | 2d j: |4marks)
() ldentify an input array of size 5. which when fed to the above algorithm, returns the maximum
value. |3 marks
(e) size
Whatn? willbe the maximum and minimum value returned by Algorithm-1 for an input array of
(3 marks]

Algorithm 1RinArray
1: Procedure CIR(arr, fl, fr):
2: if f > fr then
3 Return 0
4: end if
5: dm - [tj
6: il 4- CIR(arr, fl, dm)
7: ir + CIR(arr, dm + 1, fr)
8: CI MAC(arr, fl, dm, fr)
9: Return il + ir+ CI
10: Procedure MAC(arr, fl, dm, fr):
11: temp +|
12: if- A
13: j - dm + 1
14: ir - 0
15: while (i < dm AND j < fr) do
16: if arri < arlj] then
17: temp.APPEND(arr[i)
18: i+i+1
19: else
20: temp.APPEND (arrj])
21: ir + ir+ (dm -i+ 1)
22: j+j+1
23: end if
24: end while
25: while i< dm do
26: temp.APPEND(arr(i])
27: i+i+ 1
28: end while
29: while j <fr do
30: temp.APPEND(arri])
31: j+j+1
32: end while
33: for k=f to fr do
34: arrk] - temp|k - A)
35: end for
36: Return ir

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy