12th Computer Science - EM - Sample
12th Computer Science - EM - Sample
in
n
l.i
da
ka
vi
al
.k
w
w
w
245/-
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
Published by
PREFACE
“Loyola Computer Science “ is in your hands.
Students with average IQ always struggle to cope up studies. They always seek
for the best, sources to learn and score high marks.
The pattern of the question being asked in the exams has changed dramatically
n
and the difficulty level has also increased considerably. To succeed in board exams
l.i
and to actualize your dream, you are required to prepare strategically and study in
a focused manner.
da
This book gives important tips which covers the entire chapter.
Loyola serves the above cited purpose in perfect manner.
ka
➢ Specially designed for coaching students of different levels.
(Slow learners, average and Topper students)
vi
➢ Lot of additional questions are given for toppers
al
➢ The “EC Computer Science” is prepared with due care on the lines of the Govt.
Examination Valuation, the easy method of studying, the lesson and the perfect
.k
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
5. bkšy¡f‰F« khzt / khzÉfS¡F nkY« vËik¥gL¤â¡
l.i
bfhL¤jš.
(jÄœ k‰W« M§»y tÊ¡ fšÉÆš
da
10M« tF¥ò - jÄœ, M§»y«, m¿Éaš, r_fm¿Éaš)
11M« tF¥ò - jÄœ k‰W« M§»y«
ka
12M« tF¥ò - jÄœ k‰W« M§»y«
áw¥òfŸ :
vi
1. muR¤ nj®Éš nf£f¥gL« ò¤jf Édh¡fis¤ jÉu TLjš Édh¡fŸ
ekJ gâ¥òfËš ïl« bg‰WŸsd.
al
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
9. Fine Arts (Art, Painting, Dance, Drama or Acting, Biology. A stipend of Rs.65000/- per annum will be given
Music, and Sculpture) to each candidate and Rs.20,000/- per year as summer
l.i
10. Arts & Science Courses internship. Successful candidates after completing the
11. Courses related to Civil Aviation course will be absorbed by Department of Atomic Energy.
da
12. Courses related to Shipping For Details :www.nestexam.in
13. Foreign Language Courses MEDICAL AND PARA MEDICAL COURSES
ka
14. Hotel Management and Catering Technology Courses MEDICAL COURSES
zz MBBS , BDS, BAMS (Ayurveda), BHMS (Homoeopathy),
FREE OPPORTUNITIES
vi
BSMS (Siddha), BUMS (Unani Medicine), and BNYS
10 + 2 Technical Entry Scheme given by Indian Army (Naturopathy and Yoga).
al
zz Qualification required 12th Std. with Physics, Chemistry zz All Courses are of 5 ½ Years duration including 1 Year
and Maths. Minimum 60 % Marks.Should appear for IIT Internship except B.D.S which is of 4 ½ Years Duration.
.k
JEE Main Exam.Selection through SSB Interview. (Service zz NEET is compulsory for all Medical Courses except BNYS
(Naturopathy and Yoga) for which there is no need to have
Selection Board Interview)
w
NEET Exam.
zz After selection 10 Months Basic Military Training in Indian zz Eligibility for all the above mentioned Courses : 12th
w
Military Academy, Dehradun and after that Cadets will Standard with Physics, Chemistry and Biology or Physics,
be admitted in Military College of Engineering, Pune for Chemistry, Botany and Zoology with 50 % Marks for
w
B.E Course. After completing B.E a Post Commissioned General Candidates and 40 % Marks for BC, MBC, SC and
Training will be given and after that Employment as ST students. For Details : www.tnmedicalselction.org or
www.tnhealth.tn.gov.in
Lieutenant.
zz For Details : www.joinindianarmy.nic.in PARA MEDICAL COURSES
10 + 2 Cadet Entry Scheme or 10 + 2 Matric Entry Scheme zz B.Pharm, B.Sc (Nursing), B.P.T (Physiotherapy), B.O.T
(Occupational Therapy), B.Sc – MIT (Medical Imaging
zz Qualification – same as 10 + 2 Technical Entry Scheme. Technology), B.Sc Optometry, B.Sc – Operation Theatre and
Selection also as per 10 + 2 TES. Anesthesia Technology, B.Sc – Cardio Pulmonary Perfusion
Care Technology, B.Sc – Dialysis Technology, B.Sc – Medical
zz After Selection 6 Months Basic Naval Training in INS
Laboratory Technology, B.Sc – Cardiac Technology, B.Sc –
Chilka. After that Cadets will be admitted in Naval College Radio Therapy Technology, B.Sc – Cardiac Technology, B.Sc –
of Engineering ,Lonovala, Maharashtra for B.E. After Critical Care Technology, B.Sc – Critical Care Technology, B.Sc
completing B.E Post Commissioned Training will be given – Accident and Emergency Care Technology, B.Sc – Physician
for 10 months and after that Employment as Lieutenant. Assistant, B.Sc – Respiratory Therapy Technology, B.Sc –
Neuro Electro Physiology, B.Sc – Clinical Nutrition, B.A.S.L.P
zz For Details :www.joinindiannavy.gov.in
(Bachelor of Audiology and Speech Language Pathology)
4
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
zz B.Arch.(Architecture) – 5 Years. FASHION TECHNOLOGY AND DESIGN
l.i
zz Eligibility for all the Engineering and Technology Courses
zz B.Des in Many Disciplines. Two Institutes of National Importance
zz 12th Standard with Maths, Physics and Chemistry with 50
zz National Institute of Fashion Technology – www.nift.ac.in
da
% Marks for General Candidates, 45 % for Backward Class
zz National Institute of Design – www.nid.edu
Candidates and 40 % for Most Backward, Scheduled
Caste, and Scheduled Tribe Candidates. FINE ARTS COURSES
ka
zz For B.Plan and B.Des Candidates should have appeared zz B.F.A in Art, Painting, Dance, Drama or Acting,
for IIT – JEE and Clear JEE Main and Advanced Exam. Music,Sculpture. For Details :www.tnjjmfau.ac.in
vi
zz For B.Arch. Students should clear NATA (National
Aptitude Test for Architecture) Exam. For further details : ARTS AND SCIENCE COURSES
al
www.annauniv.edu , www.nata.in , www.jeemain.nta.ac.in zz B.A , B.Com, B.B.A, B.Sc and all other Arts and Science
AGRICULTURE AND ALLIED SCIENCES Courses www.tngasa.in
.k
zz B.E – Agricultural Engineering, B.E – Energy and Training and Courses www.dgca.nic.in
Environmental Engineering, B.Tech. – Agricultural Bio
COURSES RELATED TO SHIPPING
w
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
CONTENTS
Page.
UNIT No. Chapter Title
No
GOVT. PUBLIC EXAM - March 2024 7
n
1 Function 9
l.i
2 Data Abstraction 17
UNIT- I
da
3 Scoping 25
4 Algorithmic Strategies 35
ka
5 Python -Variables and Operators 47
6 Control Structures 57
vi
UNIT- II
7 Python functions 69
al
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
th
Loyola GOVT. PUBLIC EXAM - MARCHEC – 12
2024 Computer Science
12 – COMPUTER SCIENCE
Time Allowed : 3.00 Hours Maximum Marks : 70
PART - I
Note : 1. All questions are compulsory.
2. C
hoose the most suitable answer from the given four alternatives and write the option code
and the corresponding answer. 15 x 1 = 15
1. Which of the following is used to describe the worst case of an algorithm?
a) Big W b) Big A c) Big O d) Big S
2. The datatype whose representation is unknown are called as:
a) Concrete datatype b) Built-in datatype c) Abstract datatype d) Derived datatype
3. Which key is pressed to execute Python Script?
a) F1 b) F5 c) F3 d) F2
4. Which of the following defines what an object can do?
a) Interface b) Operating System c) Interpreter d) Compiler
n
5. Which of the following security technique that regulates who can view or use resources in a computing
l.i
environment?
a) Access control b) Password c) Certification d) Authentication
da
6. Which of the following is the Slicing Operator?
a) < > b) { } c) ( ) d) [ ]
ka
7. In Python the process of creating an object is called as ______
a) Initialize b) Constructor c) Instantiation d) Destructor
8. Pick the correct one to execute the given statement successfully.
vi
a) x / 4 = 0 b) x % 2 = 0 c) x % 4 = 0 d) x % 4==0
9. What symbol is used for SELECT statement?
.k
a) X b) σ c) d)
10. If List = [10, 20, 30, 40, 50] then List [2] = 35 will result:
w
a) [10, 20, 35, 40, 50] b) [35, 10, 20, 30, 40, 50]
w
c) [10, 35, 30, 40, 50] d) [10, 20, 30, 40, 50, 35]
11. A CSV file is also known as a ______
w
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
PART - II
n
26. What are the different ways to access the elements of a list? Give example. Chapter 9
l.i
27. Write a note on Asymptotic notation. Chapter 4
28. Using if....else...elif statement write a suitable program to display largest of 3 numbers. Chapter 6
da
29. Write a short note for the followings with suitable example. Chapter 8
(a) capitalize( ) b) swapcase( )
30. How will you define Constructor and Destructor in Python? Chapter 10
ka
31. What are the applications of scripting language? Chapter 14
32. What is the use of Where clause? Give a Python statement by using Where clause. Chapter 15
vi
33. Write short notes on TCL Commands in SQL. Chapter 12
al
PART - IV
Note: Answer all the questions. 5 x 5 =25
.k
34. a) How will you facilitate data abstraction? Explain it with suitable example. Chapter 2
OR
w
OR
Chapter 3
w
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
FUNCTIONS - An Overview
Expression of Algorithm: Object:
• Algorithms are expressed using statements An object is an instance created from the
of a programming language class.
Subroutine: Interface:
• Subroutines are small sections of code that • An interface is a set of action that an object
are used to perform a particular task that can do.
can be used repeatedly. • Interface just defines what an object can do,
Function : but won’t actually do it.
n
• A function is a unit of code that is often Implementation:
l.i
defined within a greater code structure. • Implementation carries out the instructions
• A function contains a set of code that works defined in the interface.
da
on many kinds of inputs and produces a Pure functions:
concrete output. • Pure functions are functions which will
ka
Definition: give exact result when the same arguments
• Definitions are distinct syntactic blocks. are passed.
Parameters: Impure function:
vi
• Parameters are the variables in a function • The functions which cause side effects to
al
Part - I
Choose the best answer (1 Mark)
1. The small sections of code that are used to perform a particular task is called Aug 2021
a) Subroutines b) Files c) Pseudo code d) Modules Mar 2023
Ans: a) Subroutines
2. Which of the following is a unit of code that is often defined within a greater code structure?
a) Subroutines b) Function c) Files d) Modules Aug 2022
Ans: b) Function
3. Which of the following is a distinct syntactic block? PTA-6 May 2022
a) Subroutines b) Function c) Definition d) Modules
Ans: c) Definition
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
a) Operating System b) Compiler c) Implementation d) Interpreter
Ans: c) Implementation
l.i
9. The functions which will give exact result when same arguments are passed are called
da
PTA-3 March 2020
a) Impure functions b) Partial Functions c) Dynamic Functions d) Pure functions
Ans: d) Pure functions
ka
10. The functions which cause side effects to the arguments passed are called
a) Impure functions b) Partial Functions c) Dynamic Functions d) Pure functions
vi
Ans: a) Impure functions
al
Part - II
Answer the following questions (2 Marks)
.k
be used repeatedly.
w
I nterface defines what an object can do, Implementation carries out the instructions
but won’t actually do it defined in the interface
10
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
5. Which of the following is a normal function definition and which is recursive function
definition
i) let sum x,y:
return x +y
Recursive Function
ii) let disp:
print ‘welcome’
Normal Function
iii) let rec sum num:
if (num!=0) then return num + sum (num-1)
else
return num
Recursive Function
Part - III
Answer the following questions (3 Marks)
n
1. Mention the characteristics of Interface. Sep - 2020 Mar 2023
l.i
• The class template specifies the interfaces to enable an object to be created and operated
da
properly.
• An object’s attributes and behaviour is controlled by sending functions to the object.
2. Why strlen is called pure function?
ka
GMQ - 2019
• strlen() is a pure function because the function takes one variable as a parameter, and
accesses it to find its length.
vi
• It is a pure function because, it will give same results for same input always.
al
3.
What is the side effect of impure function. Give example.
• Impure function has side effects when it has observable interaction with the outside
.k
world.
• Modifying the variable outside of function is one of the side effects.
w
return(y)
Here, the value of 'y' gets changed inside the function definition and thus the result
will change each time.
4. Differentiate pure and impure function. PTA - 6 March 2020 March 2024
11
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
hey do not modify the arguments which They may modify the arguments which are
T
4
are passed to them passed to them
Part - IV
Answer the following questions (5 Marks)
1. What are called Parameters and write a 2. Parameter with Type:
note on PTA - 2 Eg: Function definition with types:
i) Parameter without Type May-2022 (requires: b > = 0 )
ii) Parameter with Type (returns: a to the power of b )
Parameters : let rec pow (a: int) (b: int) : int : =
• Parameters are the variables in a if b=0 then 1
function definition.
n
else a * pow a (b-1)
Arguments:
l.i
• When we write the type annotations
• Arguments are the values which are
for ‘a’ and ‘b’ the parentheses are
da
passed to a function definition.
Parameters passing are of two types mandatory.
namely • Explicitly annotating the types can help
ka
1. Parameter Without Type with debugging such an error message.
2. Parameter With Type 2. Identify in the following program
vi
1. Parameter without Type: PTA - 5
al
(requires: b > =0 )
(returns: a to the power of b)
i) Name of the function
w
variable ‘b’ is the parameter and the let rec gcd a b:=
value which is passed to the variable ‘b’
is the argument. “rec” keyword tells the compiler it is a
• The precondition (requires) and post recursive function
condition (returns) of the function is iii) Name of the argument variable
given. a and b
• We have not mentioned any types (data iv) Statement which invoke the function
types). recursively
• Some language compiler solves this if b<>0 gcd b (a mod b)
type (data type) inference problem v) Statement which terminates the
algorithmically, but some require the recursion
type to be mentioned. return a
12
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
3.
Explain with example Pure and impure an implementation of that interface (the
functions. code that carries out the behaviour).
Pure functions: • An object is an instance created from
• Pure functions are functions which the class.
will give exact result when the same
• The interface defines an object’s
arguments are passed. visibility to the outside world.
• For example, the mathematical function
sin (0) always results 0. • In object oriented programs classes
are the interface and how the object
Eg:
is processed and executed is the
let square x
implementation.
return: x * x
• The above function square is a pure Example : Increasing a car's speed
function because it will not give
different results for the same input. ENGINE
Impure functions:
• The variables used inside the function
n
may cause side effects though the
l.i
getspeed
functions which are not passed with
any arguments.
da
• For example, the mathematical function No
required
random( ) will give different outputs speed
Pull Fuel
for the same function call.
ka
Yes
let random number:=
a := random() Return
vi
if a > 10 then
return: a • The person who drives the car doesn’t
al
• Here the function Random is impure presses the accelerator to get the desired
as it is not sure what will be the result behaviour.
w
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
2. Which is the basic building block of 2. Write notes on Impure function. PTA - 5
computer programs? Sep - 20 • The variables used inside the function
a) Argument may cause side effects though the
b) Parameter
functions are not passed with any
c) Subroutine
d) Interface Ans: c) Subroutine arguments. Such functions are called
II. Short Answer Questions Impure function.
• Example: random(), date()
1. Write the algorithmic function definition
to find the minimum among 3 numbers. 3. Write notes on Pure functions. QY - 2019
let min 3xyz:= • Pure functions are functions which
PTA - 4
if x < y then will give exact result when the same
if x < z then x else z arguments are passed.
else • Example: : strlen(),sqrt()
n
if y < z then y else z
PART III - ADDITIONAL QUESTIONS
l.i
I. Choose the best answer (1 Mark) 7. An _______ is an instance created from
da
the class.
1. The function definition is introduced by a) Interface b) object
the keyword c) member d) function
ka
a) def b) let Ans: b) object
c) rec d) requires
Ans: b) let 8. In object oriented programs _______ are
vi
the interface.
2. The recursive function is defined using a) classes b) object
al
c) return d) static
Ans: d) static II. Answer the following questions
w
(2 and 3 Marks)
4. trlen() is an example of ________function.
a) pure b) impure 1. How Algorithms are expressed?
a) user defined d) recursive Algorithms are expressed using
Ans: a) pure statements of a programming language
5. valuation of__________ functions does 2.
E What is meant by Definition?
not cause any side effects to its output? Definitions are distinct syntactic blocks.
a) Impure b) built-in 3. Define Parameters.
c) Recursive d) pure Parameters are the variables in a function
Ans: d) pure definition.
6. r andom() is an example of ______function. 4. Define Argument.
a) user defined b) impure Arguments are the values which are
c) pure d) recursive passed to a function definition through the
Ans: b) impure
function definition.
14
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
class.
III. Answer the following questions (5 Marks)
l.i
1. Explain the syntax of function • The type x →→ y is the type of a function
that gets an input of type ‘x’ and returns
da
definitions.
• The syntax to define functions is close an output of type ‘y’ where as xl→→ x2
to the mathematical usage. -→→y is a type of a function that takes
ka
• The definition is introduced by the two inputs, the first input is of type ‹xl›
keyword let, followed by the name of and the second input of type ‘xl’ , and
the function and its arguments; then
vi
returns an output of type ‹y’ .
the formula that computes the image of
the argument is written after an = sign. • Likewise x1 →→...→→xn→→y has
al
• If you want to define a recursive type ‘x’ as input of n arguments and ‘y’
type as output.
.k
15
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
4. What happens if you modify a variable outside the function? Give an example
• One of the most popular groups of side effects is modifying the variable outside of
function.
• For example:
let y: = 0
let inc (x:int):int:c
y: =y+x;
return (y)
In the above example the value of y get changed inside the function definition due
to which the result will change each time.
The side effect of the inc () function is it is changing the data of the external visible
variable‘y’.
HANDS ON PRACTICE
1. Write the algorithmic recursive function definition to find the sum of ‘n ‘ natural numbers.
n
let rec sum num:
l.i
If(num!=0) then
return num+sum(num-1)
da
else
return num
ka
☺☺☺☺☺
vi
al
.k
w
w
w
16
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
• The definition of ADT only mentions what operations are to be performed but not how these
l.i
operations will be implemented.
• The process of providing only the essentials and hiding the details is known as abstraction.
da
Constructors and Selectors:
• To facilitate data abstraction, we need to create two types of functions: constructors and
ka
selectors.
• Constructors are functions that build the abstract data type.
vi
• Selectors are functions that retrieve information from the data type.
• The basic idea of data abstraction is to structure programs so that they operate on abstract
al
data.
• A concrete data representation is defined as an independent part of the program.
.k
• The two parts of a program are, the part that operates on abstract data and the part that
defines a concrete representation.
w
17
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
a) Built in b) List c) Tuple d) Derived data
Ans: c) Tuple
l.i
5. The data type whose representation is known are called QY-2019
da
a) Built in datatype b) Derived datatype c) Concrete datatype d) Abstract datatype
Ans: c) Concrete datatype
ka
6. The data type whose representation is unknown are called PTA-2 Hy 2019 Mar 2023
Mar 2024
a) Built in datatype b) Derived datatype c) Concrete datatype d) Abstract datatype
vi
Ans: d) Abstract datatype
al
Ans: a) Pair
PTA-4 GMQ-2019
w
9. Which of the following allow to name the various parts of a multi-item object?
a) Tuples b) Lists c) Classes d) quadrats
w
Ans: c) Classes
10. Which of the following is constructed by placing expressions within square brackets?
a) Tuples b) Lists c) Classes d) quadrats Ans: b) Lists
Answer the following questions (2 Marks)
1. What is abstract data type? Aug-2021 May-2022 Mar 2024
Abstract Data type (ADT) is a type (or class) for objects whose behavior is defined by a set of
value and a set of operations.
2. Differentiate constructors and selectors. PTA - 2 & 3 QY-2019 Aug-2022
Constructors Selectors
Constructors are functions that build the Selectors are functions that retrieve
abstract data type. information from the data type.
18
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
l.i
Answer the following questions (3 Marks)
1. Differentiate Concrete Data Type and Abstract Data Type
da
Concrete Data Type Abstract Data Type
1 Concrete data types or structures (CDT’s) Abstract Data types (ADT’s) offer a
ka
are direct implementations of a relatively high level view (and use) of a concept
simple concept independent of its implementation
vi
2 In Concrete Data Type is a data type whose In Abstract Data Type the representation of
representation is known a data type is unknown
al
3 Dependent of its implementation Offer a high level view and use of a concept
.k
GMQ-2019
• A powerful strategy for designing programs: ‘wishful thinking’.
w
• Wishful Thinking is the formation of beliefs and making decisions according to what
might be pleasing to imagine instead of by appealing to reality.
w
19
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
c student [rno, name, mark] c Class
l.i
d day:= ( sun’, mon’, tue’, wed’) d Tuple
e x:= [2, 5, 6.5, [5, 6], 8.2] e List
da
f employee [eno, ename, esal, eaddress] f Class
IV. Answer the following questions (5Marks)
ka
1. How will you facilitate data abstraction. Explain it with suitable example. PTA - 2 & 4
vi
To facilitate data abstraction we need to create two types of functions namely Jun 2023
1.Constructors 2. Selectors. Mar 2024
al
Constructors :
.k
Selectors :
• Selectors are functions that retrieve information from the data type.
w
Example :
w
20
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
2.
What is a List? Why List can be called as Pairs. Explain with suitable example
PTA-6 Mar 2023
The first way to implement pairs is with the List construct.
List:
List is one of the ways to implement pairs.
List is constructed by placing expressions within square brackets separated by
commas.
Such an expression is called a list literal. List can store multiple values.
Each value can be of any type and can even be another list.
Eg: Lst := [10,20].
Here lst[0] represents the value 10
and lst[1] represents the value 20
We can represent list similar to set as
lst [(0,10), (1,20)] - Where
(0, 10) (1, 20)
n
l.i
Index position Value Index position Value
da
• Any way of bundling two values together into one can be considered as a pair.
• Lists are a common method to do so. Therefore List can be called as Pairs.
Example: Representing rational numbers using list:
ka
• We can now represent a rational number as a pair of two integers in pseudo code : a
numerator and a denominator.
vi
rational(n, d):
return [n, d]
al
numer(x):
return x[0]
.k
denom(x):
w
return x[1]
3. How will you access the multi-item. Explain with example.
w
• We can use the structure construct to represent multi-part objects where each part is
given a name.
w
21
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
}
first Name
last Name
variable (field) belonging to the new data type
id
email
n
-- output of first Name: Padmashri
l.i
The class (structure) construct defines the form for multi-part objects that represent a person.
da
PART II - PTA & GMQ GOVT. EXAM QUESTION ANSWERS
I. Choose the best answer (1 Mark)
ka
1. ADT expansion is _________ PTA - 1
a) Abstract Data Tuple b) All Data Template
vi
c) Abstract Data Type d) All Data Type Ans: c) Abstract Data Type
al
a) Selectors are nothing but the functions that retrieve information from the data type.
Eg:
(i) getname(city)
(ii) getlat(city)
(iii) getlong(city)
are the selectors because these functions extract the information of the city object
b) The two parts of a program are,
i) The part that operates on abstract data
ii) The part that defines a concrete representation, that implements abstract data.
2. Define Abstraction. Aug-2021
The process of providing only the essentials and hiding the details is known as abstraction.
22
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
create _____ types of functions essentials and hiding the details is known
as ________
l.i
a) 2 b) 3
c) 4 d) 5 Ans: a) 2 a) Abstraction b) Pairs
da
c) Encapsulation d) Function
4. List can also be called as _________
Ans: a) Abstraction
a) Functions b) Class
c) Pairs d) Structure 12. Which provides modularity?
ka
Ans: c) Pairs a) Data types b) Abstraction
c) Classes d) Subroutines
5. Which of the following is contracted
vi
Ans: b) Abstraction
by placing expressions within square
al
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
integer values. denominator into a compound value
• Both parts are needed to exactly characterize
l.i
• The pseudo code for the representation of the
the value of the rational number. rational number using the above constructor
• Actually dividing integers produces a float
da
and selector is
approximation, losing the exact precision of x,y:=8,3
integers. rational(n,d)
ka
• However, you can create an exact
numer(x)/denum(y)
representation for rational numbers by - - output : 2.6666666666666665
combining together the numerator and
vi
denominator. ☺☺☺☺☺
al
.k
w
w
w
24
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
SCOPING – An Overview
Scope: Module:
• Scope refers to the visibility of variables, • A module is a part of a program.
parameters and functions in one part of • Programs are composed of one or more
a program to another part of the same independently developed modules.
program.
Modular programming:
• The scope of a variable is that part of the
• The process of sub dividing a computer
code where it is visible.
program into separate sub-programs is
• The LEGB rule is used to decide the order
called Modular programming.
in which the scopes are to be searched for
n
scope resolution Access control:
l.i
• Access control is a security technique that
Mapping:
regulates who or what can view or use
• The process of binding a variable name
da
resources in a computing environment. It
with an object is called mapping.
is a fundamental concept in security that
• = (equal to sign) is used in programming
minimizes risk to the object.
ka
languages to map the variable and object.
Public members:
Namespaces:
• Public members (generally methods
• Namespaces are containers for mapping
vi
declared in a class) are accessible from
names of variables to objects.
outside the class.
al
Local scope:
Protected members:
• Local scope refers to variables defined in
• Protected members of a class are accessible
.k
current function.
from within the class and are also available
Global variable: to its sub-classes.
w
Nested function:
be handled only from within the class.
• A function (method) within another
function is called nested function. Access Specifiers in Python and C++ and Java :
Enclosed Scope: PTA - 1 • Python prescribes a convention of prefixing
• A variable which is declared inside a the name of the variable/method with
function which contains another function single or double underscore to emulate the
definition within it, the inner function can behaviour of protected and private access
also access the variable of the outer function. specifiers.
This scope is called enclosed scope. • C++ and Java, control the access to class
members by public, private and protected
Built-in scope:
keywords
• Built-in scope has all the names that are
• All members in a Python class are public by
pre-loaded into program scope when we
default whereas by default in C++ and java
start the compiler or interpreter.
all members are private.
25
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
a) :: b) := c) = d) == PTA-2 HY-2019
l.i
Ans:c) =
Containers for mapping names of variables to objects is called QY-2019 May-2022 Jun 2023
da
4.
a) Scope b) Mapping c) Binding d) Namespaces
Ans: d) Namespaces
ka
5. Which scope refers to variables defined in current function? Aug-2022
vi
a) Local Scope b) Global scope c) Module scope d) Function Scope
Ans: a) Local Scope
al
26
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
Part - II
Answer the following questions (2 Marks)
1. What is a scope? Mar 2023
• Scope refers to the visibility of variables, parameters and functions in one part of a
program to another part of the same program.
2. Why scope should be used for variable. State the reason.
• It is a good practice to limit a variable’s scope to a single definition.
• Because, changes inside the function can’t affect the variable on the outside of the function
in unexpected ways.
3. What is Mapping? PTA - 5 May-2022 Jul 2022
• The process of binding a variable name with an object is called mapping.
• = (equal to sign) is used in programming languages to map the variable and object.
4. What do you mean by Namespaces? GMQ-2019 March 2020 PTA - 4
• Namespaces are containers for mapping names of variables to objects. Aug-2022
n
• Programming languages keep track of all the mappings with namespaces.
l.i
5. How Python represents the private and protected Access specifiers?
da
• Python prescribes a convention of prefixing the name of the variable/method with single
or double underscore to emulate the behavior of protected and private access specifiers.
Eg: –a → Protected variable
ka
– num → Private variable
Part - III
vi
Answer the following questions (3 Marks)
al
Example:
w
Entire program
w
1. Disp():
Disp ( ) Output of the Program
2. a:=7
a:=7
3. print a 7
Print a
4. Disp()
Disp( )
27
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
Example:
Entire program
1. a:=10 a:=10
2. Disp(): Output of the Program
Disp ( )
3. a:=7
a:=7 7
4. print a Print a
5. Disp(): 10
6. print a Disp 1 ( ) :
Print a
• On execution of the above code the variable a which is defined inside the, function
displays the value 7 for the function call Disp() and then it displays 10, because a is
n
defined in global scope.
l.i
3. Define Enclosed scope with an example PTA - 3
Enclosed Scope :
da
• A variable which is declared, inside a function which contains another function definition
within it, the inner function can also access the variable of the outer function.
ka
Example:
Entire Program
vi
1. Disp():
al
Disp( )
2. a:=10 a:=10
Output of the Program
.k
3. Disp1()
4. print a Disp 1( ) : 10
w
Print a
5. Disp1()
10
w
6. print a Disp 1 ( ) :
7. Disp() Print a
w
Disp 1
28
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
5. Identify the scope of the variables in the following pseudo code and write its output
color:= ‘Red’ Ans:
my color( ): Variables Scope Output:
b:=‘Blue’ Color Global Scope Red Blue Green
myfavcolor( ): Red Blue
b Enclosed Scope
g:=‘Green’ Red
g Local Scope
print color, b, g
myfavcolor( )
print color, b
mycolor( )
print color
Part - IV
Answer the following questions (5Marks)
n
1. Explain the types of scopes for variable or LEGB rule with example. PTA - 1 & 3
l.i
Sep-2020 Mar 2022 Jun 2023 Mar 2024
da
LEGB rule:
• The LEGB rule is used to decide the order in which the scopes are to be searched for
scope resolution.
ka
• The scopes are listed below in terms of hierarchy (highest to lowest).
vi
BUILT IN Local(L) Defined inside function/class
GLOBAL Defined inside enclosing functions (Nested
al
ENCLOSED Enclosed(E)
function concept)
.k
Local
Global (G) Defined at the uppermost level
w
Local Scope :
w
1. Disp(): Disp ( )
2. a:=7 Output of the Program
a:=7
3. print a 7
4. Disp()
Print a
Disp( )
29
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
Global Scope:
• A variable which is declared outside of all the functions in a program.
• Global variable can be accessed inside or outside of all the functions in a program.
Example:
Entire program
1. a:=10 a:=10
2. Disp(): Output of the Program
3. a:=7 Disp ( )
a:=7 7
4. print a
5. Disp(): Print a
10
6. print a Disp 1 ( ) :
Print a
n
• On execution of the above code the variable ‘a’ which is defined inside the function
l.i
displays the value 7 for the function call Disp() and then it displays 10; because a is
da
defined in global scope.
Enclosed Scope:
• A variable which is declared inside a function which contains another function definition
ka
with in it, the inner function can also access the variable of the outer function. This scope
is called enclosed scope.
vi
Example:
al
Entire Program
1. Disp():
.k
2. a:=10 Disp( )
w
4. print a Disp 1( ) : 10
Print a
5. Disp1()
w
10
6. print a Disp 1 ( ) :
Print a
7. Disp()
Disp ( )
30
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
Entire program
Built in/module scope
Disp( )
Disp 1 ( ) :
Print a
Disp ( )
n
• Modules can be included in a program.
• Module segments can be used by invoking a name and some parameters.
l.i
• Module segments can be used by other modules.
da
3. Write any five benefits in using modular programming.
• Less code to be written.
• A single procedure can be developed for reuse, eliminating the need to retype the code
ka
many times.
• Programs can be designed more easily because a small team deals with only a small part
vi
of the entire code.
• Modular programming allows many programmers to collaborate on the same application.
al
1. The kind of scope of the variable ‘a’ used in thepseudo code given below. GMQ-2019
(a) Disp( ): (b) a: = 7 (c) print a (d) Disp( )
a) Local b) Global c) Enclosed d) Built-in Ans: a) Local
2. The SQL command to make a database as current active database is GMQ-2019
a) CURRENT b) USE c) DATABASE d) NEW Ans: b) USE
3. A variable which is declared inside a function which contains another function definition:
a) Local b) Global c) Enclosed d) Built-in PTA-1
Ans: c) Enclosed
4. Which are loaded as soon as the library files are imported to the program? PTA-3
a) Built-in scope variables b) Enclosed scope variables
c) Global scope variables d) Local scope variables
Ans: a) Built-in scope variables
31
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
1. The duration for which a variable is alive is called its_______
l.i
a) End time b) Scope time c) Life time d) Visible time
da
Ans: c) Life time
2. The scope of a_______ is that part of the code where it is visible
ka
a) Variable b) Keyword c) Function d) Operator
Ans: a) Variable
vi
3. A Function always first look up for a variable name in its______ scope
a) Enclosed b) Local c) Global d) Built-in
al
Ans: b) Local
.k
4. The inner function can access the variable of the outer function. This is called ____scope.
a) Local b) Enclosed c) Function d) Global
w
Ans: b) Enclosed
w
Ans: b) Modules
6. In Object Oriented Programming Language Access control is implemented through_____.
a) Access modules b) Access modifiers c) Access variables d) Keywords
Ans: b) Access modifiers
7. ___________is a selective restriction of access to data in a program?
a) Control variable b) Access control c) System authentication d) Module
Ans: b) Access control
8. The part of a program that can see or use the variables are called
a) Parameter b) Scope c) Function d) Indentation
Ans: b) Scope
9. How many variables can be mapped to the same instance?
a) 2 b) 3 c) Multiple d) 4 Ans: c) Multiple
32
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
10. Which of the following keeps track of all these mappings with namespaces?
a) Application software b) Programming languages
c) System software d) MySQL Ans: b) Programming languages
11. Which of the following rule is used to decide the order in which the scopes are to be
searched for scope resolution?
a) LGEB b) LEGB c) LBEG d) LGBEAns: b) LEGB
12. How many types of variable scope are there?
a) 2 b) 3 c) 4 d) 6 Ans: c) 4
13. A variable which is declared outside all the functions in a program is known as
a) Local b) Enclosed c) Global d) Extern
Ans: c) Global
14. Which of the following variable can be accessed inside or outside of all the functions in a
program?
n
a) Local b) Enclosed c) Global d) Built-in
l.i
Ans: c) Global
15. Which of the following programming enables programmers to divide up the work and
da
retry pieces of the program independently?
a) Procedural Programming b) Modular Programming
ka
c) Object Oriented Programming d) Structural Programming
Ans: b) Modular Programming
vi
16. Which of the following contain instructions, processing logic and data?
a) Scopes b) Indentation c) Modules d) Access control
al
Ans: c) Modules
17. Which of the following members of a class are denied access from outside the class?
.k
Ans: b) Private
18. The arrangement of private instance variables and public methods ensure the principle of
w
33
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
1. Define variable.
Variable are addresses references, or pointers, to an object in memory.
2. Write a note on access modifiers of a class.
• Public members (generally methods declared in a class) are accessible from outside the
class.
• Protected members of a class are accessible from within the class and are also available
to its sub-classes.
• Private members of a class are denied access from outside the class. They can be handled
only from within the class.
III. Answer the following questions (5Marks)
1. Explain how Access Specifiers are activated in Python , C++ and Java.
n
• Python prescribes a convention of prefixing the name of the variable/method with single
or double underscore to emulate the behaviour of protected and private access specifiers.
l.i
• C++ and Java, control the access to class members by public, private and protected
da
keywords.
• All members in a Python class are public by default whereas by default in C++ and java
all members are private.
ka
• Any member can be accessed from outside the class environment in Python which is not
possible in C++ and java.
vi
2. Write a note on module
• A module is a part of a program.
al
• A single module can contain one or several statements closely related each other.
• Modules work perfectly on individual level and can be integrated with other modules.
w
• A software program can be divided into modules to ease the job of programming and
debugging as well.
w
• A program can be divided into small functional modules that work together to get the
output.
w
34
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
in ascending or descending . Linear search:
l.i
Searching : • Linear search also called sequential search is
• Searching is a process of finding a particular a sequential method for finding a particular
da
element present in given set of elements. value in a list.
• Some of the searching types are: Binary search:
ka
i) Linear Search • Binary search is also called half-interval
ii) Binary Search. search algorithm.
vi
Algorithmic strategy: • It finds the position of a search element
• The way of defining an algorithm is called within a sorted array.
al
35
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
c) Time and space d) Data and space Ans: c) Time and space
l.i
4. The algorithm that yields expected output for a valid input is called as
a) Algorithmic solution b) Algorithmic outcomes
da
c) Algorithmic problem d) Algorithmic coding
Ans : a) Algorithmic solution
ka
5. Which of the following is used to describe the worst case of an algorithm?
a) Big A b) Big S c) Big W d) Big O Ans : d) Big O
vi
6. Big is the reverse of GMQ - 2019 March 2024
a) Big O b) Big θ c) Big A d) Big S Ans : a) Big O
al
9. If a problem can be broken into subproblems which are reused several times, the problem
possesses which property?
a) Overlapping subproblems b) Optimal substructure
c) Memoization d) Greedy Ans: a) Overlapping subproblems
10. In dynamic programming, the technique of storing the previously calculated values is
called ? HY - 2019 Mar 2023
a) Saving value property b) Storing value property
c) Memoization d) Mapping Ans: c) Memoization
Part - II
Answer the following questions (2 Marks)
1. What is an Algorithm? Aug-2021 March 2020
• An algorithm is a finite set of instructions to accomplish a particular task.
• It is a step-by-step procedure for solving a given problem.
36
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
5.What is searching? Write its types. GMQ - 2019 HY - 2019 May - 2022 March 2024
• Searching is a process of finding a particular element present in given set of elements.
l.i
• Some of the searching types are:
i) Linear Search ii) Binary Search.
da
Part - III
Answer the following questions (3 Marks)
ka
1. List the characteristics of an algorithm Aug-2021 May - 2022
● Input ● Output ● Finiteness ● Definiteness
vi
● Effectiveness ● Correctness ● Simplicity ● Unambiguous
● Feasibility ● Portable ● Independent
al
• The complexity of an algorithm f (n) gives the running time and/or the storage space
required by the algorithm in terms of n as the size of input data.
w
• Time Complexity: It is given by the number of steps taken by the algorithm to complete
the process.
w
• Space Complexity: It is the amount of memory required to run to its completion. The
space required by an algorithm is equal to the sum of fixed part and variable part.
w
Types of complexity:
1. Best case 2. Worst case 3. Average case
3.
What are the factors that influence time and space complexity.
The factors that influence time and space complexity are
1. Time 2. Space
Time Factor : Time is measured by counting the number of key operations like comparisons
in the sorting algorithm.
Space Factor: Space is measured by the maximum memory space required by the algorithm.
4. Write a note on Asymptotic notation QY - 2019 Mar - 2020 Jun 2023 Mar - 2024
• Asymptotic Notations are languages that use meaningful statements about time and
space complexity.
• The following three asymptotic notations are mostly used to represent time complexity
of algorithms:
37
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
Big O:
To describe the worst -case of an algorithm.
Big Ω:
To describe the lower bound (best -case).
Big Θ:
When an algorithm has complexity with lower bound = upper bound, it has the
complexity Θ (n log n), which means the running time of that algorithm always falls
in n log n in the best-case and worst-case.
5. What do you understand by Dynamic programming? Sep - 2020
• Dynamic programming is an algorithmic design method that can be used when the
solution to a problem can be viewed as the result of a sequence of decisions.
• This approach is similar to divide and conquer.
• It is used whenever problems can be divided into similar sub-problems. So that their
results can be re-used to complete the process.
n
• These approaches are used to find the solution in optimized way.
l.i
Part - IV
da
Answer the following questions (5 Marks)
1. Explain the characteristics of an algorithm. HY - 2019 PTA - 5
ka
Input Zero or more quantities to be supplied.
Output At least one quantity is produced.
vi
Finiteness Algorithms must terminate after finite number of steps.
All operations should be well defined. For example, operations involving
Definiteness
al
division by zero or taking square root for negative number are unacceptable.
Effectiveness Every instruction must be carried out effectively.
.k
Simplicity
Unambiguous Algorithm should be clear and must lead to only one meaning.
w
Portable
operating system able to handle all range of inputs.
It should have step-by-step directions, which should be independent of
Independent
any programming code.
2. Discuss about Linear search algorithm March 2020 PTA - 1 & 4 Aug-2022 Mar 2023
• Linear search also called sequential search is a sequential method for finding a particular
value in a list.
• This method checks the search element with each element in sequence until the desired
element is found or the list is exhausted. In this searching algorithm, list need not be
ordered.
Pseudo code:
Traverse the array using for loop
In every iteration, compare the target search key value with the current value of the list.
38
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
If the values match, display the current index and value of the array.
If the values do not match, move on to the next array element.
If no match is found, display the search element not found.
Example:
index 0 1 2 3 4
values 10 12 20 25 30
To search the number 25 in the array given below, a linear search will go step by step in a
sequential order starting from the first element in the given array if the search element is
found that index is returned otherwise the search is continued till the last index of the array.
In this example number 25 is found at index number 3.
3.What is Binary search? Discuss with example. Aug-2021 Jun 2023 Mar 2024
Binary Search:
• Binary search also called half-interval search algorithm.
n
• It finds the position of a search element within a sorted array.
l.i
• The binary search algorithm can be done as a dividend- and -conquer search algorithm
and executes in logarithmic time.
da
Procedure code for Binary search
1. Start with the middle element:
ka
• If the search element is equal to the middle element of the array then return the index
of the middle element.
vi
• If not, then compare the middle element with the search value,
• If the search element is greater than the number in the middle index, then select the
al
ments to the left side of the middle index, and start with Step-1.
w
2. When a match is found, display success message with the index of the element matched.
3. If no match is found for all comparisons, then display unsuccessful message.
w
Example:
1. List of elements in an array must be sorted first for Binary search. The following
w
10 20 30 40 50 60 70 80 90 99
0 1 2 3 4 5 6 7 8 9
39
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
5. Now compare the search element with the value stored at mid value location 4. The
value stored at location or index 4 is 50, which is not match with search element. As the
search value 60 is greater than 50.
10 20 30 40 50 60 70 80 90 99
0 1 2 3 4 5 6 7 8 9
6. Now we change our low to mid + 1 and find the new mid value again using the
formula.
low = mid + 1
mid = low + (high -low) / 2
7. Our new mid is 7 now. We compare the value stored at location 7 with our target value 31.
10 20 30 40 50 60 70 80 90 99
0 1 2 3 4 5 6 7 8 9
8. The value stored at location or index 7 is not a match with search element, rather it is
more than what we are looking for. So, the search element must be in the lower part
n
from the current mid value location
l.i
10 20 30 40 50 60 70 80 90 99
0 1 2 3 4 5 6 7 8 9
da
9. The search element still not found. Hence, we calculated the mid again by using the
formula.
ka
high = mid-1
mid = low + (high -low)/2
Now the mid value is 5.
vi
10 20 30 40 50 60 70 80 90 99
al
0 1 2 3 4 5 6 7 8 9
.k
10. Now we compare the value stored at location 5 with our search element. We found that
it is a match.
w
10 20 30 40 50 60 70 80 90 99
0 1 2 3 4 5 6 7 8 9
w
11. We can conclude that the search element 60 is found at location or index 5.
For example, if we take the search element as 95, For this value this binary search
w
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
• If the current element is greater than the next element of the array, swap them.
If the current element is less than the next or right side of the element, move to the next
element. Go to Step 1 and repeat until the end of the index is reached.
Let’s consider an array with values {15, 11, 16, 12, 14, 13} Below, we have a pictorial
representation of how bubble sort will sort the given array.
n
l.i
da
ka
vi
al
• The above pictorial example is for iteration-d. Similarly, remaining iteration can be done.
The final iteration will give the sorted array. At the end of all the iterations we will get the
.k
11 12 13 14 15 16
w
5. Explain the concept of Dynamic programming with suitable example. Mar 2023
• Dynamic programming is an algorithmic design method that can be used when the
w
41
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
a) Linear b) Half interval c) Decimal d) Boolean
l.i
Ans: b) Half interval
da
2. Which one of the following is not a factor to measure the execution time of an algorithm?
a) Speed of the machine b) Operating system Sep - 2020
c) Programming language used d) Selection Ans: d) Selection
ka
3. Time complexity of bubble sort in best case is PTA-1
a) θ (n) b) θ (n log n) c) θ (n2) d) θ (n(logn)2)
vi
Ans: a) θ (n)
al
Ans: d) Algorithm
w
Ans: b) Program
w
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
• Operating System
• Programming language used
• Volume of data required
2. What are the different phases in the analysis of algorithms and performance ? PTA - 5
Analysis of algorithms and performance evaluation can be divided into two different phases:
1. A Priori estimates : This is a theoretical performance analysis of an algorithm. Efficiency
of an algorithm is measured by assuming the external factors.
2. A Posteriori testing : This is called performance measurement. In this analysis, actual
statistics like running time and required for the algorithm executions are collected.
III. Long Answer Questions
1. Explain the selection Sort Algorithm with an example. QY - 2019
(i) Let us assume a list of n number of values stored in an array. Suppose if we want to search
a particular element in this list, the algorithm that search the key element in the lis among n
n
elements, by comparing the key element with each element in the list sequentially.
l.i
(ii) The best case would be if the first element in the list matches with the key element to be
searched in a list of elements. The efficiency in that case would be expressed as O(1) because
da
only one comparison is enough.
(iii) Similarly, the worst case in this scenario would be if the complete list is searched and the
ka
element is found only at the end of the list or is not found in the list. The efficiency of an
algorithm in that case would be expressed as O(n) because n comparisons required to
complete the search.
vi
(iv) The average case efficiency of an algorithm can be obtained by finding the average number
al
The selection sort is a simple sorting algorithm that improves on the performance of bubble
sort by making only one exchange for every pass through the list.
Procedure:
i) Start from the first element i.e., index-0, we search the smallest element in the array, and
replace it with the element in the first position.
ii) Now we move on to the second element position, and look for smallest element present in
the sub-array, from starting index to till the last index of sub - array.
iii) Now replace the second smallest identifed in step-2 at the second position in the or original
array, or also called first position in the sub array.
iv) This is repeated, until the array is completely sorted.
Let’s consider an array with values {13, 16, 11, 18, 14, 15}
Below, we have a pictorial representation of how selection sort will sort the given array.
43
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
I. Choose the best answer: (1 Marks)
l.i
1. 0(1) is an example of
a) Worst case b) Best case c) Average case d) Null case
da
Ans: b) Best case
2. Linear search is also called
a) Quick search b) Sequential search
ka
c) Binary search d) Selection search Ans: b) Sequential search
3. Binary search also called
vi
a) Half-interval search b) Sequential search
c) Unordered search d) Full-interval search
al
5. Which of the following sorting algorithm is too slow and less efficient?
w
6. Which of the following programming is used whenever problems can be divided into
similar sub-problems?
a) Object oriented b) Dynamic c) Modular d) Procedural
Ans: b) Dynamic
7. _______is a step-by-step procedure for solving a given problem
a) Program b) Algorithm c) Statements d) Structure
Ans: b) Algorithm
8. Which of the following is a finite set of instructions to accomplish a particular task?
a) Flowchart b) Algorithm c) Functions d) Abstraction
Ans: b) Algorithm
9. The way of defining an algorithm is called
a) Pseudo strategy b) Programmic strategy
c) Data structured strategy d) Algorithmic strategy
Ans: d) Algorithmic strategy
44
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
10. An algorithm that yields expected output for a valid input is called an
a) Algorithmic Structure b) Algorithmic Solution
c) Algorithmic Strategy d) Algorithmic Procedure
Ans: b) Algorithmic Solution
11. Efficiency of an algorithm decided by
a) Definiteness, portability b) Time, Space
c) Priori, Postriori d) Input/output Ans: b) Time, Space
12. Which of the following should be written for the selected programming language with
specific syntax?
a) Algorithm b) Pseudocode c) Program d) Process
Ans: c) Program
13. How many components required to find the space required by an algorithm?
a) 4 b) 3 c) 2 d) 6 Ans: c) 2
14. Which of the following component is defined as the total space required to store certain
data and variables for an algorithm?
n
a) Time part b) Variable part c) Memory part d) Fixed part
l.i
Ans: d) Fixed part
da
15. Which of the following component is defined as the total space required by variables,
which sizes depends on the problem and its iteration?
a) Time part b) Variable part c) Fixed part d) Memory part
ka
Ans: b) Variable part
16. Time and Space complexity could be considered for an
vi
17. Which of the following is not a factor use to measure the time efficiency of an algorithm?
w
18. How many asymptotic notations are mostly used to represent time complexity of
algorithms?
a) Two b) Three c) One d) Many Ans: b) Three
45
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
7. Write a note Asymptotic Notations?
Asymptotic Notations are languages that uses meaningful statements about time and space
l.i
complexity.
da
8. Write a note on memoization.
Memoization or memoisation is an optimization technique used primarily to speed up
computer programs by storing the results of expensive function calls and returning the
ka
cached result when the same inputs occur again.
vi
III. Answer the following questions (5 Marks)
al
☺☺☺☺☺
46
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
n
3. Containers for mapping names of variables to object is called _______
l.i
(a) Scope (b) Mapping (c) Binding (d) Namespaces
4. The two main factors which decide the efficiency of an algorithm are ________
da
(a) Processor and Memory (b) Complexity and capacity
(c) Time and Space (d) Data and space
ka
5. The Shortcut key used to create new Python program is :
(a) Ctrl+C (b) Ctrl+F (c) Ctrl+B (d) Ctrl+N
vi
6. "clif" can be considered to be the abbreviation of:
(a) nested if (b) if..else (c) else if (d) if..elif
al
8. _________ is used as placeholders or replacement fields which get replaced along with
w
format( ) function.
(a) { } (b) < > (c) ++ (d) ^^
w
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.
www.kalvikadal.in https://material.kalvikadal.in
PART - II
Note : Answer any six questions. Question No. 24 is Compulsory. 6×2=12
16. Differentiate - Interface and Implementation. Ln-1
17. What is a pair ? Give an example. Ln-2
18. Write short notes on Tokens. Ln-5
19. List the control structures in Python. Ln-6
20. What are the main advantages of function ? Ln-7
21. What is data consistency? Ln-11
22. Write the difference between table constraint and column constraint. Ln-12
23. Write notes on : Ln-7
(i) MAX() function (ii) MIN() function
24. What is Set in Python? Ln-9
PART - II
Note : Answer any six questions. Question No. 33 is compulsory.6×3=18
n
25. Write any three characteristics of modules. Ln-3
l.i
26. Write a note on Asymptotic notation. Ln-4
27. What are string literals ? Ln-5
da
28. Write a note on if..else Structure. Ln-6
29. Write about composition in functions with an example. Ln-7
ka
30. What are the differences between List and Dictionary ? Ln-9
31. What is the role of DBA? Ln-11
vi
32. Differentiate - Python and C++. Ln-14
33. Write a Python code to check whether a given year is leap year or not. Ln-7
al
PART - IV
Note : Answer all the questions. 5x5=25
.k
OR
(b) How will you facilitate data abstraction? Explain it with suitable example. Ln-2
w
35. (a) Explain input() and print() functions with examples. Ln-2
OR
w
Please send your Materials & Question Papers to kalvikadal.in@gmail.com (or) Whatsapp - 9385336929.