12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications மின்னணு தரவு பரிமாற்றம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிக பாதுகாப்பு அமைப்புகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின்னணு செலுத்தல் முறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications திறந்த மூல கருத்துருக்கள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு வடமிடல் Sample Question Papers Study Material - QB365 Set A

Published on: 18/11/2019
Download Tamil Nadu 12th Standard Computer Science question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Science Test1.
Which of the following is the reverse of Big O?
Big \(\Omega \)
Big \(\mu \)
Big symbol
Big O
2.
_________is used to describe the lower bound of asymptotic function.
Big Alpha
Big Beta
Big 0
Big Omega
3.
________is used to describe the upper bound of a asymptotic function.
Big \(\mu \)
Big O
Big \(\Omega \)
Big \(\beta \)
4.
_______are languages that uses meaningful statements about time and space complexity?
Time and space trade
Asymptotic notations
Complexity notations
Algorithmic notations
5.
The ________ of an algorithm is defined as the number of computational resources used by the algorithm.
Simplicity
Efficiency
Feasibility
Potable
6.
Simple variables and constants used in an algorithm is an example of _________component.
Time part
Variable part
Factor part
Fixed part
7.
Recursion used to calculate factorial of a given value n in algorithm is an example of________ component
Fixed part
Variable part
Operator part
Time part
8.
Space required by an algorithm = Fixed part+_________
Constant part
Variable part
Time part
Second part
9.
Efficiency of an algorithm is measured by_______factors.
3
4
2
1
10.
A theoretical performance analysis of an algorithm is called_________
Posteriori testing
Priori estimates
Algorithmic efficiency
Algorithmic testing
11.
Performance evaluation of an algorithm can be_____ divided into different phases
3
4
4
1
12.
Efficiency of an algorithm is defined by the utilization of ______ and _________ complexity
Time, operation
Time, space
Time, latency
Time, speed
13.
Algorithm resembles a _________which can be implemented in any programming language.
Solution
Program
Pseudocode
Function
14.
Each of algorithm steps and there inputs! outputs should be clear and must lead to only one meaning refers to the algorithm characteristics ________.
Unambiguous
Feasibility
Independent
Effectiveness
15.
Data are maintained and manipulated effectively through_________
Algorithm
Data Structures
Pseudocode
Program
16.
_______is a step-by-step procedure for solving a given problem
Algorithm
Program
Statements
Structure
17.
Which of the following optimization technique used in dynamic algorithms
Memorization
Composition
Specification
Decomposition
18.
Which approach is similar to divide and conquer method?
Dynamic programming
Object oriented
Procedural
Modular
19.
Which of the following algorithm used memorization?
Efficient
Dynamic
Effective
Modular
20.
In which programming the solutions of overlapped sub-problems are combined in order to get the better solution?
Object oriented
Procedural
Dynamic
Modular
21.
Which of the following programming is used whenever problems can be divided into similar sub-problems?
Dynamic
Object oriented
Modular
Procedural
22.
Which sorting techniques working by taking elements from the list one by one and inserting them in their correct position into a new sorted list?
Bubble
Selection
Merge
Insertion
23.
Which sorting algorithm repeatedly selects the next smallest element and swaps in into the right place for every pass?
Bubble sort
Sequential sort
Selection sort
Heap sort
24.
Which sorting algorithm sort is by making only one exchange for every pass through the list?
Bubble
Selection
Comparison
Merge
25.
Which sorting algorithm compares each pair of adjacent elements and swaps them if they are in the unsorted order?
Selection
Merge
Insertion
None of these
26.
Which of the following sorting algorithm is too slow and less efficient?
Bubble
Selection
Quick
Merge
27.
Bubble sort is also called
Sequential sort
Quick sort
Half-interval sort
Comparison sort
28.
Which of the following search algorithm executes in logarithmic time?
Linear
Sequential
Binary
Half-interval
c or d
29.
Which search algorithm can be done as divided and conjurer search algorithm?
Half-interval
linear
Sequential
Bubble
30.
Which of the following algorithm finds the position of a search element within a sorted array?
Binary search
Linear search
Sequential search
List search
31.
Binary search also called
Sequential search
Half-interval search
Unordered search
Full-interval search
32.
Which of the following method checks the search element with each element in sequence?
Bubble search
Binary search
Linear search
None of these
33.
Linear search is also called
Sequential search
Quick search
Binary search
Selection search
34.
O(n) is an example of
best case
Average case
worst case
Null case
35.
0(1) is an example of
best case
worst case.
Average case
Null casd
36.
Which of the following notation is often used to describe the worst-case fan algorithm?
Big \(\Omega \)
Big \(\mu \)
Big O
Big \(\alpha \)
37.
How many asymptotic notations are mostly used to represent time complexity of algorithms?
Three
Two
One
Many
38.
Which of the following is not a factor use a to measure the time efficiency of an algorithm?
Speed of the machine
Operating system
Designing algorithm
Programming language
39.
How many factors are used to measure the time efficiency of an algorithm?
Two
Three
Six
Many
40.
Time and Space complexity could be considered for an
Algorithmic strategy
Algorithmic analysis
Algorithmic solution
Algorithmic efficiency
41.
Which of the following component is defined as the total space required by variables, which sizes depends on the problem and its iteration?
Variable part
Time part
Fixed part
42.
Which of the following component is defined as the total space required to store certain data and variables for an algorithm?
Time part
Variable part
Fixed part
Memory part
43.
How many components required to find the space required by an algorithm?
4
3
6
2
44.
The amount of memory required to run an algorithm completion is known by
Efficiency of an algorithm
Performance analysis of an algorithm
Space complexity of an algorithm
Time complexity of an algorithm
45.
Which of the following should be written for the selected programming language with specific syntax?
Algorithm
Pseudocode
Process
Program
46.
The number of steps taken by the algorithm to complete the process is known as
Time complexity of an algorithm
Space complexity of an algorithm
Efficiency of an algorithm
Performance analysis of an algorithm
47.
Efficiency of an algorithm decided by
Time, Space
Definiteness, portability
Priori, Postriori
Input/output
48.
An estimation of the time and space complexities of an algorithm is called
Algorithmic solution
Algorithmic Strategy
Algorithmic performance
Algorithmic analysis
49.
Performance measurement of an algorithm is called
Posteriori testing
Priori estimates
Efficiency testing
Algorithmic analysis
50.
An algorithm that yields expected output for a valid input is called an
Algorithmic Solution
Algorithmic Structure
Algorithmic Strategy
Algorithmic Procedure
51.
Which of the following could be designed to get a solution of a given problem?
Program
Algorithm
Flowchart
Input/Output
52.
Which characteristics of an algorithm should be generic, independent of any programming language?
Independent
Portable
Feasibility
Unambiguous
53.
Which characteristics of algorithm defined the operation involving division by zero?
Finiteness
Definiteness
Input
Correctness
54.
The way of defining an algorithm is called
Pseudo strategy
Programmic strategy
Algorithmic strategy
Data structured strategy
55.
Which of the following is not a sorting technique?
Bubble
Binary
Insertion
Quick
56.
Which of the following is not a searching technique?
(i) Linear
(ii) Binary
(iii) Selection
(iv) Merge
Only i
Only ii
Only iii
iii and iv
57.
Which of the following is an example of data structures?
List
Tuple
Dictionary
All of these.
58.
Which of the following is not an example of data structures?
Control statement
Structure
List
Dictionary
59.
Which of the following is not a characteristic of an algorithm?
Definiteness
Correctness
Data structure
Effectivenes
60.
Which of the following are the characteristics of an algorithm?
(i) Definiteness
(ii) Correctness
(iii) Effectiveness
i, ii
ii, iii
Only ii
i, ii and iii
61.
Which of the following is a finite set of instructions to accomplish a particular task?
Flowchart
Functions
Algorithm
Abstraction
62.
_________members of the class are accessible from outside the class
Private
Privated
Public
All of these
63.
___________is a selective restriction of access to data in a program?
Control variable
System authentication
Access control
Module
64.
In Object Oriented Programming Language security is implanted through_______
Access modifiers
Access modules
Access variables
Keywords
65.
______can be separately compiled and stored in a library
Characteristics
Syntax
Modules
none of these
66.
The inner function can access the variable of the outer function. This is called________scope.
Local
Function
Enclosed
Global
67.
A Function always first look up for a variable name in its______ scope
Local
Enclosed
Global
Built-in
68.
The scope of a_______ is that part of the code where it is visible
Keyword
Variable
Function
Operator
69.
The duration for which a variable is alive is called its_______
End time
Life time
Scope time
Visible time
70.
Fill up the blank in assign a variable with________to an object.
=
! =
: =
= =
71.
Scope refers to the visibility of___________.
Variables
Parameters
Functions
All of these
72.
Programs are composed of one or more independently developed
Access control
Encapsulatio
Modules
Members of a class
73.
By default, the C++ and Java class members are
Private
Protected
Public
Local
74.
By default, the Python. class members are
Private
Protected
Global
Public
75.
Which of the following members of a class are accessible from within the class and available to its subclass?
Private
Protected
Public
All of these
76.
The arrangement of private instance variables and public methods ensure the principle of
Inheritance
Polymorphism
Encapsulation
Abstraction
77.
Find the odd man out
Public
Local
Protected
Private
78.
How many access control keywords are there?
2
3
4
6
79.
Which of the following keywords are not used to control the access to class members?
Public
Protected
Public
Global
80.
Which of the following is not a classical object oriented language
C++
Java
Python
C
81.
Which of the following members of a class are denied access from outside the class?
Private
Protected
Public
Enclosed
82.
The following are the type of variable scopes Find the odd one out
Local
Enclosed
Global
Protected
83.
Which of the following contain instructions, processing logic and data?
Scopes
Modules
Indentation
Access control
84.
The example of modules are
Procedures
Subroutines
Functions
All of these
85.
Which of the following programming enables programmers to divide up the work and retry pieces of the program independently?
Modular Programming
Procedural Programming
Object Oriented Programming
Structural Programming
86.
Which of the following can ease the job of programming and debugging the program?
Statements
Interaction
Modules
Scopes
87.
What is the output of the statement in the following program?
X:=10
Disp ( ):
a:=7
print a
Disp ( ) :
Print a
710
107
7
10
88.
Which of the following variable can be accessed inside or outside of all the functions in a program?
Local
Global
Enclosed
Built-in
89.
A variable which is declared outside all the functions in a program is known as
Local
Enclosed
Extern
Global
90.
Choose the type of scope for a variable '9! defined in the following program.
Disp ( ):
a:=7
Print a
Disp ( )
Global
Enclosed
Local
Built-in
91.
Which of the following is not a variable scope?
Global
Enclosed
List
Built-in
92.
How many types of variable scope are there?
2
4
3
6
93.
Write the below interns of hierarchy (highest to lowest)?
(1) Reversed names in built in functions
(2) Defined inside function
(3) Defined inside enclosing function
(4) Defined at the uppermost level
3,2,1,4
1,4,2,3
2,3, 1,4
2,3,4, 1
94.
95.
The order in which variables have to be mapped to the object in order to obtain the value is called
Rule
Syntax
Scope
Hierarchy
96.
How the names are mapped with objects in programming language?
name == object
name:: object
name:= object
object:= name
97.
Which of the following keeps track of all these mappings with namespaces?
Programming languages
Application software
System software
MySQL
98.
How many variables can be mapped to the same instance?
2
3
4
Multiple
99.
Which of the following refers to the addresses to an object in memory?
Functions
Indentation
Variables
Operators
100.
The part of a program that can see or use the variables are called
Scope
Parameter
Function
Indentation
101.
List is constructed by using ________ and _________.
( ), ,
< >,;
[ ], ,
[ ],:
102.
A________ is not just data, it has functions defined within it.
Class
List
Pair
Object
103.
Tuple is constructed by using ______ and________
( )
[ ]
<>
{}
104.
A ________ is a comma separated values surround with parentheses.
List
Tuple
Set
Dictionary
105.
______is made up of list or Tuples
Set
Pair
Dictionary
Control Structures
106.
______ are functions that retrieve information from the data type.
Constructors
Selectors
List
Tuple
107.
A________ data representation is defined as an independent part of the program.
Abstract
Concrete
List
Tuple
108.
The basic idea of ________ is to structure programs so that they operate on abstract dat(a)
Encapsulation
Polymorphism
Data type
Data Abstraction
109.
The____________ can be implemented using singly linked list or doubly linked list
Tuple ADT
List ADT
Function ADT
List ADT
110.
Classes are the representation for___________
Abstract datatype
Built-in datatype
Concrete datatype
Essential datatype
111.
________are the representation for Abstract Data types.
Objects
Classes
Functions
Lists
112.
Data Abstraction allows programmers to treat code as_______
Objects
Classes
Members
Parameters
113.
CDT expansion is
Collective Data Type
Class Data Type
Concrete Data Type
Central Data Type
114.
I: = [10,20] is an example
Tuple
Set
List
Dictionary
115.
Which of the following as bundled data and the functions that work on that data?
Object
Pair
List
Class
116.
Which of the following defines a data abstraction by grouping related data items?
List
Pair
Class
Tuple
117.
Which of the following does not allow us to name the various parts of a multi-item object?
List
Triple
Pair
All of these
118.
Color = ('red', 'green, 'blue') is an example of
Dictionary
List
Set
Tuple
119.
How many ways are there to represent pair datatypet?
2
4
3
5
120.
List can also be called as
Functions
Class
Structure
Pairs
121.
How many values can be stared in the list?
4
10
100
Multiple
122.
Which of the following is contracted by placing expressions within square brackets separated by commas?
List
Tuple
Set
Dictionary
123.
To implement the concrete level of data abstraction the language python provides a compound structure called
ADT
Concrete data
Pair
User defined function
124.
How many parts are the!"ein the program?
2
3
4
Many
125.
In which data representation, a definition for each function is known
User defined
Buil-in
Abstract
Concrete
126.
Which of the following extract the information of the object?
Constructors
Functions
Selectors
Destructors
127.
Which of the following are functions that build the abstract datatypet?
Constructors
Destructors
Selectors
All of these
128.
Which of the following function that facilitate the data abstraction?
Constructors
Destructors
Selectors
a and c
129.
To facilitate data abstraction, How many types of functions are created?
2
3
4
Only one
130.
Which of the following replicate how we think about the world?
Queue ADT
Data Hiding
Data Abstraction
Stack ADT
131.
Which of the following are implemented using & lists?
Singly linked list ADT
Doubly Linked list ADT
Queue ADT
All of these
132.
How many ways to implement an ADT?
Only one
Two
Three
Many
133.
Which of the following gives an implementation independent view?
Abstract
Concrete
Datatype
Behavior of an object
134.
The process of providing only the essentials and hiding the details is known as
Functions
Abstraction
Encapsulation
Pairs
135.
ADT behavior is defined by
(i) Set of Variables
(ii) Set of Value
(iii) Set of Functions
(iv) Set of Operations
i, ii
ii, iii
ii, iv
i, iii
136.
Which of the following is a type for objects whose behavior is defined by a set of value and a set of operations?
User-defined datatype
Derived datatype
Built-in datatype
Abstract datatype
137.
ADT expansion is
Abstract Data Template
Absolute Data Type
Abstract Data Type
Application Development Tool
138.
Which of the following provides modularity?
Datatypes
Subroutines
Classes
Abstraction
139.
Which of the following is a powerful concept that allows programmers to treat codes as objects?
Encapsulation
Data Abstraction
Inheritance
Polymorphism
140.
Evaluation of__________ functions does not cause any side effects to its output?
Impure
pure
Recursive
built-in
141.
Strlen is an example________function.
user defined
impure
pure
recursive
142.
In object oriented programs, how the object is processed and executed is__________
Implementation
Interface
recursion
function
143.
In object oriented programs__________ are the interface
Implementation
parameters
Interface
Arguments
144.
A_________ combines the external interface with an implementation of the interface
parameter without type
class declaration
function definition
parameter with type
145.
All functions are________ definitions.
static
dynamic
algorithmic
static
146.
Explicitly_________the types can help with debugging.
defining
annotating
informing
computing
147.
_______are the variables in a function definition.
Arguments
Parameters
Identifiers
Operators
148.
Subroutines are called as________
Algorithm
Interface
Parameters
Function
149.
In which type of function the return type does not solely depends on its argument passed?
Pure
Parameterized
Impure
Monochromatize
150.
In which type of function the return type is solely depends on its argument passed?
pure
impure
parameterized
monochromatize
151.
Which of the following is an example of impure function?
Strlent( )
randomt( )
sqrfi( )
puref( )
152.
Which of the following is an instance created from the class?
parameter
function
subroutines
object
153.
Which of the following is a description of all functions in object oriented programming language?
Implementation
parameter
Interface
Arugument
154.
A function definition which call itself is called
user defined function
built-in function
derived function
recursive function
155.
The recursive function is defined using the keyword
let
let rec
name
infer
156.
The function definition is introduced by the keyword
def
rec
let
infer
157.
Which of the following are the values which are passed to a function definition?
Parameters
Algorithm
Data types
Arguments
158.
Which of the following contains a set a code that works an many kinds of input and produces a concrete output?
Function
Algorithm
Arguments
Language
159.
What must the used when a bulk of statements to be repeated for many number of times?
Algorithm
Program
Subroutines
Parameters
160.
Which of the following are expressed using statements of a programming language?
Functions
Algorithm
Interface
Implementation
161.
In dynamic programming, the technique of storing the previously calculated values is called ?
Saving value property
Storing value property
Memoization
Mapping
162.
If a problem can be broken into subproblems which are reused several times, the problem possesses which property?
Overlapping subproblems
Optimal substructure
Memoization
Greedy
163.
The Θ notation in asymptotic evaluation represents
Base case
Average case
Worst case
NULL case
164.
Time complexity of bubble sort in best case is
θ (n)
θ (nlogn)
θ (n2)
θ (n(logn) 2)
165.
Which of the following is not a stable sorting algorithm?
Insertion sort
Quick sort
Merge sort
Selection sort
166.
From the following sorting algorithms which has the lowest worst case complexity?
Bubble sort
Quick sort
Merge sort
Selection sort
167.
The complexity of linear search algorithm is
O(n)
O(log n)
O(n2)
O(n log n)
168.
Two main measures for the efficiency of an algorithm are
Processor and memory
Complexity and capacity
Time and space
Data and space
169.
From the following sorting algorithms which algorithm needs the minimum number of swaps?
Bubble sort
Insertion sort
Selection sort
All the above
170.
The word comes from the name of a Persian mathematician Abu Ja’far Mohammed ibn-i Musa al Khowarizmi is called?
Flowchart
Flow
Algorithm
Syntax
171.
The members that are accessible from within the class and are also available to its sub classes is called
Public members
Protected members
Secured members
Private members
172.
Which members are accessible from outside the class?
Public members
Protected members
Secured members
Private members
173.
Which of the following members of a class can be handled only from within the class?
Public members
Protected members
Secured members
Private members
174.
Which of the following security technique that regulates who can use resources in a computing environment?
Password
Authentication
Access control
Certification
175.
The process of subdividing a computer program into separate sub-programs is called
Procedural Programming
Modular programming
Event Driven Programming
Object oriented Programming
176.
Which scope refers to variables defined in current function?
Local Scope
Global scope
Module scope
Function Scope
177.
Containers for mapping names of variables to objects is called
Scope
Mapping
Binding
Namespaces
178.
Which of the following is used in programming languages to map the variable and object?
::
:=
=
==
179.
The process of binding a variable name with an object is called
Scope
Mapping
late binding
early binding
180.
Which of the following refers to the visibility of variablesin one part of a program to another part of the same program.
Scope
Memory
Address
Accessibility
181.
Which of the following is constructed by placing expressions within square brackets?
Tuples
Lists
Classes
quadrats
182.
Which of the following allow to name the various parts of a multi-item object?
Tuples
Lists
Classes
quadrats
183.
Bundling two values together into one can be considered as
Pair
Triplet
single
quadrat
184.
Which of the following is a compound structure?
Pair
Triplet
single
quadrat
185.
The data type whose representation is unknown are called
Built in datatype
Derived datatype
Concrete datatype
Abstract datatype
186.
The data type whose representation is known are called
Built in datatype
Derived datatype
Concrete datatype
Abstract datatype
187.
A sequence of immutable objects is called
Built in
List
Tuple
Derived data
188.
The data structure which is a mutable ordered sequence of elements is called
Built in
List
Tuple
Derived data
189.
Which of the following functions that retrieve information from the data type?
Constructors
Selectors
recursive
Nested
190.
191.
The functions which cause side effects to the arguments passed are called
Impure function
Partial Functions
Dynamic Functions
Pure functions
192.
The functions which will give exact result when same arguments are passed are called
Impure functions
Partial Functions
Dynamic Functions
Pure functions
193.
Which of the following carries out the instructions defined in the interface?
Operating System
Compiler
Implementation
Interpreter
194.
Which of the following defines what an object can do?
Operating System
Compiler
Interface
Interpreter
195.
Which of the following are mandatory to write the type annotations in the function definition?
{ }
( )
[ ]
< >
196.
The values which are passed to a function definition are called
Arguments
Subroutines
Function
Definition
197.
The variables in a function definition are called as
Subroutines
Function
Definition
Parameters
198.
199.
Which of the following is a unit of code that is often defined within a greater code structure?
Subroutines
Function
Files
Modules
200.
The small sections of code that are used to perform a particular task is called
Subroutines
Files
Pseudo code
Modules
201.
Define memorization.
202.
Write a note on Big omega asymptotic notation.
203.
What are the three asymptotic notations used to represent time complexity of algorithms?
204.
What are asymptotic notations?
205.
What is best algorithm?
206.
Define algorithmetic strategy?
207.
Give an example. How the time efficiency of an algorithm is measured.
208.
Name the two factors, which decide the efficiency of an algorithm.
209.
How the analysis of algorithms and performance evaluation can be divided?Explain.
210.
What is algorithm analysis?
211.
What does analysis of an algorithm deals with?
212.
How the efficiency of an algorithm is defined?
213.
What is algorithmic solution?
214.
What in algorithmic strategy? Give an example.
215.
Give an example of data structures
216.
What is meant by module?
217.
What is modular programming?
218.
Write the output of the following program
Disp()
a:=10
Disp 1():
print a
Disp 1():
print a
Disp()
219.
Write the output of the following program
a:=10
Disp():
a:=7
print a
Disp 1():
print a
220.
Write the output of the following program
Entire Program
Disp():
a:=7
print a
Disp ()
221.
What are the types of variable scope
222.
What is the use of LEGB rule?
223.
Define variable.
224.
How the elements of a list can be accessed?
225.
From the statement P1 : = Preson(), What does P1 and person referred.
226.
How a class defines a data abstraction?
227.
Write a pseudocode to depressant rational numbers using list.
228.
Write a note on pair datatype
229.
How the concrete level of data abstraction implemented?
230.
Write the pseudo code for the representation of the rational number using constructor & selector.
231.
Identify which is the constructor and selector from the following statement.
(i) The Functions that retrieve information from the datatype.
(ii)The function which creates an object.
232.
Give an example of implementing an ADT
233.
Construct on algorithm that arranges meetings between these two types so that they change their color to the third type. In the end, all should display the same color.
234.
Give an example of impure function.
235.
Give an example of pure function.
236.
What is recursive function?
237.
Give an example of function definition parameter with type.
238.
Give an example of function definition parameter without type.
239.
Differentiate parameters and arguments.
240.
What is searching? Write its types.
241.
242.
Who is an Algorist?
243.
Define Pseudo code.
244.
What is an Algorithm?
245.
How Python represents the private and protected Access specifiers?
246.
What do you mean by Namespaces?
247.
What is Mapping?
248.
Why scope should be used for variable. State the reason.
249.
What is a scope?
250.
What is a Tuple? Give an example.
251.
What is a List? Give an example.
252.
253.
Differentiate constructors and selectors.
254.
What is abstract data type?
255.
Which of the following is a normal function definition and which is recursive function definition
i) let rec sum x y:
return x + y
ii) let disp:
print ‘welcome’
iii) let rec sum num:
if (num!=0) then return num + sum (num-1)
else
return num
256.
Differentiate interface and implementation.
257.
Write the inference you get from X : = (78).
258.
Define Function with respect to Programming language.
259.
What is a subroutine?
260.
Write a pseudo code that defines Fibonacci Iterative algorithm with Dynamic programming approach.
261.
What is dynamic programming? What are the steps involved in dynamic programming?
262.
Write a pseudo code for Insertion sort.
263.
Write a pseudo code for selection sort Algorithm.
264.
Write a pseudo code for bubble sort algorithm
265.
Write a pseudo code for Binary search
266.
Write a pseudo code for linear search
267.
Write the different factors in which the time efficiency of an algorithm its measured
268.
Write a note on two factors in which space required by an algorithm is decided.
269.
Write a note on time/space trade off
270.
Design an algorithm to find square of the given number and display the result.
271.
List the manipulation manipulated effectively through data structures by algorithm.
272.
Write a short note on types of variable scope.
273.
Write a note on access modifiers of a class.
274.
How will you ensure the principle of data encapsulation in object - oriented programming?
275.
Write a note on module.
276.
Write a note on built-in scope.
277.
How the changes inside the function can't affect the variable on the outside of the function in unexpected ways?
278.
Give an example of an ADT for rational numbers.
279.
Write a note on Data Abstraction.
280.
Identify the constructor and selector from the following.
(I) City = Make city (name, lat, Ion)
(ii) Get name (city)
(ill) Make point (x,y)
(iv) x coord (point)
(v) y coord (point)
281.
Write a short note an syntax for function types.
282.
Write an algorithm to check whether the entered number is even or odd.
283.
Explain the syntax of function definitions.
284.
What do you understand by Dynamic programming?
285.
Write a note on Asymptotic notation.
286.
What are the factors that influence time and space complexity.
287.
Discuss about Algorithmic complexity and its types.
288.
List the characteristics of an algorithm.
289.
Identify the scope of the variables in the following pseudo code and write its output
color:= 'Red'
mycolor( ):
b:='Blue'
myfavcolor( ):
g:='Green'
printcolor, b, g
myfavcolor( )
printcolor, b
mycolor( )
print color
290.
Why access control is required?
291.
Define Enclosed scope with an example.
292.
293.
Define Local scope with an example.
294.
Identify Which of the following are List, Tuple and class ?
(a) arr [1, 2, 34]
(b) arr (1, 2, 34)
(c) student [rno, name, mark]
(d) day= (‘sun’, ‘mon’, ‘tue’, ‘wed’)
(e) x= [2, 5, 6.5, [5, 6], 8.2]
(f) employee [eno, ename, esal, eaddress]
295.
What are the different ways to access the elements of a list. Give example.
296.
Identify Which of the following are constructors and selectors?
(a) N1:=number()
(b) accetnum (n1)
(c) displaynum (n1)
(d) eval (a/b)
(e) x,y:= make slope (m), make slope (n)
(f) display()
297.
Which strategy is used for program designing? Define that Strategy.
298.
Differentiate Concrete data type and abstract datatype.
299.
Wha happens if you modify a variable outside the function? Give an example.
300.
Differentiate pure and impure function.
301.
What is the side effect of impure function. Give example.
302.
Why strlen is called pure function?
303.
Mention the characteristics of Interface.
304.
Explain the sorting algorithm that uses n-1 number passes to get the final sorted list.
305.
Explain the selection sort Algorithm with an example.
306.
Differentiate Algorithm and program
307.
Define efficiency of an algorithm? How the efficiency of an algorithm was determined?
308.
Explain complexity of an algorithm.
309.
Explain Best, worst and Average case efficiency of an algorithm with an example.
310.
Explain the concept access control.
311.
Explain the representation of Abstract datatype using rational numbers.
312.
Explain the concept of Dynamic programming with suitable example.
313.
Explain the Bubble sort algorithm with example.
314.
What is Binary search? Discuss with example
315.
Discuss about Linear search algorithm.
316.
Explain the characteristics of an algorithm.
317.
Write any five benefits in using modular programming.
318.
Write any Five Characteristics of Modules.
319.
Explain the types of scopes for variable or LEGB rule with example.
320.
How will you access the multi-item. Explain with example.
321.
What is a List? Why List can be called as Pairs. Explain with suitable example.
322.
How will you facilitate data abstraction. Explain it with suitable example.
323.
Explain with an example interface and implementation.
324.
Explain with example Pure and impure functions.
325.
Identify in the following program
| let rec gcd a b:= if b <> 0 then gcd b (a mod b) else return a: |
i) Name of the function
ii) Identify the statement which tells it is a recursive function
iii) Name of the argument variable
iv) Statement which invoke the function recursively
v) Statement which terminates the recursion
326.
What are called Parameters and write a note on
(i) Parameter without Type
(ii) Parameter with Type
327.
Choose the incorrect statement from the following.
(i) Linear search is also called sequential search
(ii) Bubble sort is also called comparison sort
(iii) Dynamic algorithms does not uses optimization technique memorization.
(iv) Binary search algorithm can not be done as
divide and conquer search algorithm.
(a) i and ii
(b) ii and iii
(c) iii and iv
(d) Only iv
328.
Choose the incorrect statement from the following.
(i) There a different types of variable scope
(ii) Enclosed and extended are the type of variable scope
(iii) A variable is declared outside of all the function is called global variable
(iv) Built-in Scope is also called Module scope.
(a) i, iii and iv
(b) ii and ii
(c) i and ii
(d) iii only
329.
Which of the following is and incorrect statement?
(i) ADT is defined by set of values and set of operations
(ii) ADT does specify how data will be organized in the memory.
(iii) Constructors are not used to built abstract data type.
(iv) Selectors are functions that retrieve information from the data type.
(a) i, ii
(b) ii, iv
(c) ii, iii
(d) i, iii, iv
1.
(a)
Big \(\Omega \)
2.
(d)
Big Omega
3.
(b)
Big O
4.
(b)
Asymptotic notations
5.
(b)
Efficiency
6.
(d)
Fixed part
7.
(b)
Variable part
8.
(b)
Variable part
9.
(c)
2
10.
(b)
Priori estimates
11.
(b)
4
12.
(b)
Time, space
13.
(c)
Pseudocode
14.
(a)
Unambiguous
15.
(b)
Data Structures
16.
(a)
Algorithm
17.
(a)
Memorization
18.
(a)
Dynamic programming
19.
(b)
Dynamic
20.
(c)
Dynamic
21.
(a)
Dynamic
22.
(d)
Insertion
23.
(c)
Selection sort
24.
(b)
Selection
25.
(d)
None of these
26.
(a)
Bubble
27.
(d)
Comparison sort
28.
(e)
c or d
29.
(a)
Half-interval
30.
(a)
Binary search
31.
(b)
Half-interval search
32.
(c)
Linear search
33.
(a)
Sequential search
34.
(c)
worst case
35.
(a)
best case
36.
(c)
Big O
37.
(a)
Three
38.
(c)
Designing algorithm
39.
(d)
Many
40.
(d)
Algorithmic efficiency
41.
(a)
Variable part
42.
(c)
Fixed part
43.
(d)
2
44.
(d)
Time complexity of an algorithm
45.
(d)
Program
46.
(a)
Time complexity of an algorithm
47.
(a)
Time, Space
48.
(d)
Algorithmic analysis
49.
(a)
Posteriori testing
50.
(a)
Algorithmic Solution
51.
(b)
Algorithm
52.
(b)
Portable
53.
(b)
Definiteness
54.
(c)
Algorithmic strategy
55.
(b)
Binary
56.
(d)
iii and iv
57.
(d)
All of these.
58.
(a)
Control statement
59.
(c)
Data structure
60.
(d)
i, ii and iii
61.
(c)
Algorithm
62.
(c)
Public
63.
(c)
Access control
64.
(a)
Access modifiers
65.
(c)
Modules
66.
(c)
Enclosed
67.
(a)
Local
68.
(b)
Variable
69.
(b)
Life time
70.
(c)
: =
71.
(d)
All of these
72.
(c)
Modules
73.
(a)
Private
74.
(d)
Public
75.
(b)
Protected
76.
(c)
Encapsulation
77.
(b)
Local
78.
(b)
3
79.
(d)
Global
80.
(d)
C
81.
(a)
Private
82.
(d)
Protected
83.
(b)
Modules
84.
(d)
All of these
85.
(a)
Modular Programming
86.
(c)
Modules
87.
(d)
10
88.
(b)
Global
89.
(d)
Global
90.
(c)
Local
91.
(c)
List
92.
(b)
4
93.
(d)
2,3,4, 1
94.
(a)
95.
(c)
Scope
96.
(c)
name:= object
97.
(a)
Programming languages
98.
(d)
Multiple
99.
(b)
Indentation
100.
(a)
Scope
101.
(c)
[ ], ,
102.
(a)
Class
103.
(a)
( )
104.
(b)
Tuple
105.
(b)
Pair
106.
(b)
Selectors
107.
(b)
Concrete
108.
(d)
Data Abstraction
109.
(b)
List ADT
110.
(a)
Abstract datatype
111.
(b)
Classes
112.
(a)
Objects
113.
(c)
Concrete Data Type
114.
(b)
Set
115.
(d)
Class
116.
(c)
Class
117.
(d)
All of these
118.
(d)
Tuple
119.
(a)
2
120.
(d)
Pairs
121.
(d)
Multiple
122.
(a)
List
123.
(c)
Pair
124.
(a)
2
125.
(d)
Concrete
126.
(c)
Selectors
127.
(a)
Constructors
128.
(d)
a and c
129.
(a)
2
130.
(c)
Data Abstraction
131.
(d)
All of these
132.
(d)
Many
133.
(a)
Abstract
134.
(b)
Abstraction
135.
(c)
ii, iv
136.
(d)
Abstract datatype
137.
(c)
Abstract Data Type
138.
(d)
Abstraction
139.
(b)
Data Abstraction
140.
(b)
pure
141.
(c)
pure
142.
(a)
Implementation
143.
(c)
Interface
144.
(b)
class declaration
145.
(a)
static
146.
(b)
annotating
147.
(b)
Parameters
148.
(d)
Function
149.
(c)
Impure
150.
(a)
pure
151.
(a)
Strlent( )
152.
(d)
object
153.
(c)
Interface
154.
(d)
recursive function
155.
(b)
let rec
156.
(c)
let
157.
(a)
Parameters
158.
(a)
Function
159.
(c)
Subroutines
160.
(b)
Algorithm
161.
(c)
Memoization
162.
(a)
Overlapping subproblems
163.
(b)
Average case
164.
(a)
θ (n)
165.
(d)
Selection sort
166.
(c)
Merge sort
167.
(a)
O(n)
168.
(c)
Time and space
169.
(c)
Selection sort
170.
(c)
Algorithm
171.
(b)
Protected members
172.
(a)
Public members
173.
(d)
Private members
174.
(c)
Access control
175.
(b)
Modular programming
176.
(a)
Local Scope
177.
(d)
Namespaces
178.
(c)
=
179.
(b)
Mapping
180.
(a)
Scope
181.
(b)
Lists
182.
(c)
Classes
183.
(a)
Pair
184.
(a)
Pair
185.
(d)
Abstract datatype
186.
(c)
Concrete datatype
187.
(c)
Tuple
188.
(b)
List
189.
(b)
Selectors
190.
(a)
191.
(a)
Impure function
192.
(d)
Pure functions
193.
(c)
Implementation
194.
(c)
Interface
195.
(b)
( )
196.
(a)
Arguments
197.
(d)
Parameters
198.
(c)
199.
(b)
Function
200.
(a)
Subroutines
201.
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 cached result when the same inputs occur again.
202.
Big Omega is the reverse Big O, if Big O is used to describe the upper bound (worst - case) of a asymptotic function, Big Omega is used to describe the lower bound (best-case).
203.
(i) BigO
(ii) BigW
(Iii) Big \(\mu \)
204.
Asymptotic Notations are languages that uses meaningful statements about time and space complexity
205.
The best algorithm to solve a given problem is one that requires less space in memory and takes less time to execute its instructions to generate output.
206.
A way of designing algorithm is called algorithmic strategy
207.
The time efficiency of an algorithm is measured by different factors. For example, write a program for a defined algorithm, execute it by using any programming language, and measure the total time it takes to run.
208.
(i) Time factor
(ii) Space factor
209.
Analysis of algorithms and performance evaluation can be divided into two different phases:
(i) A Priori estimates: This is a theoretical performance analysis of an algorithm. Efficiency of an algorithm is measured by assuming the external factors.
(ii) A Posterori testing: This is called performance measurement. In this analysis, actual statistics like running time and required for the algorithm executions are collected.
210.
An estimation of the time and space complexities of an algorithm for varying input sizes is called algorithm analysis.
211.
(i) Analysis of an algorithm usually deals with the running and execution time of various operations involved.
(ii) The running time of an operation is calculated as how many programming instructions is executed per operation
212.
Efficiency of an algorithm is defined by the utilization of time and space complexity
213.
An algorithm that yields expected output for a valid input is called an algorithmic solution
214.
(i) The way of defining an algorithm is called J algorithmic strategy.
(ii) For example to calculate factorial for the given value n then it can be done by defining the function to calculate factorial once for the iteration-1 then it can be called recursively until the number of required iteration is reached.
215.
Examples for data structures are arrays, structures, list, tuples, dictionary.
216.
A module is a part of a program. Programs are composed of one or more independently developed modules
217.
The process of subdividing a computer program into separate sub-programs is called modular programming.
218.
The output of the program
10
10
219.
The output of the program
7
10
220.
The output of the program
7
221.
(i) Local scope
(ii) Enclosed scope
(iii) Global scope
(iv) Built-in scope
222.
The LEGB rule is used to decide the order in which the scopes are to be searched for scope resolution. The scopes are listed below in terms of hierarchy (highest to lowest).
223.
Variable are addresses (references, or pointers, to an object in memory
224.
(i) The elements of a list can be accessed in two ways.
(ii) The first way is via multiple assignment and the second method is by the element selection operator
225.
Person is referred to as a class or a type, while p1 is referred to as an object or an instance.
226.
(i) A class defines a data abstraction by grouping related data items. A class is not just data, it has functions defined within it.
(ii) Functions are subordinate to the class because their job is to do things with the data of the class.
227.
rational(n, d):
return [n, d]
numer(x):
return x[0]
denom(x):
return x[1]
228.
(i) A pair is a compound data type that holds two other pieces of data. The two ways of representing the pair data type.
(ii) The first way is using List construct and the second way to implement pairs is with the tuple construct.
229.
(i) To implement the concrete level of data abstraction, languages like Python provides a compound structure called Pair which is made up of list or Tuple.
(ii) The first way to implement pairs is with the List construct
230.
The pseudo code for the representation of the rational number using the above constructor and selector is component
x,y:=8,3
rational(n,d)
numer(x)/numer(y)
- - output: 2.6666666666666665
231.
(i) Selector
(ii) Constructor
232.
(i) There can be different ways to implement an ADT, for example, the, List ADT can be implemented using singly linked list or doubly linked list.
(ii) Similarly, stack ADT and Queue ADT can be implemented using lists
233.
let rec monochromatize a b c :=
if a > 0 then
a, b, c:= a-1, b-1, c+2
else
a:=0, b:=0, c:= a + b + c
return c
234.
let y: = 0
(int) inc (int) x
y: =y+x;
return (y)
235.
let square x
return: x * x
let i: = 0;
ifi < strlen> (s) then
-- Do something which doesn't affect s
++i
236.
A function definition which call itself is called recursive function.
237.
(requires: b > 0 )
(returns: a to the power of b)
let rec pow (a: int) (b: int) : int :=
if (b=0) then 1
else a * pow b (a-1 )
238.
(requires: b>=0 )
(returns: a to the power of b)
let rec pow a b:=
if b=0 then I
else a * pow a (b-1)
239.
Parameters are the variables in a function definition and arguments are the values which are passed to a function definition.
240.
A searching algorithm is the step-by step procedure used to locate specific data among a collection of data. There are two types of searching are.
(i) Linear Search
(ii) Binary Search
241.
242.
Algorist may refer to,
1. A person skilled in the technique of performing basic decimal arithmetic, known as algorism.
2. A person skilled in the design of algorithms.
3. An algorithmic artist.
243.
Pseudo code is an informal way of Programming language syntax.
244.
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.
245.
Python prescribes a convention of prefixing the name of the variable or method with single or double underscore to emulate the behavior of protected and private access specifiers.
Example: self_n2 = n2
246.
Namespaces are containers for mapping names of variables to objects.
Example : a : =5
Here the variable 'a' is mapped to the value '5.
247.
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.
248.
Scope should be used for a variable because; it limits a variables scope to a single definition. That is the variables are visible only to that part of the code. Essentially, variables are addresses to an object in memory. When you assign a variable with := to an instance (object), you're binding (or mapping) the variable to that instance. Multiple variables can be mapped to the same instance.
249.
Scope refers to the visibility of variables, parameters and functions in one part of a program to another part of the same program.
250.
(i) A tuple is a comma-separated sequence of values surrounded with parentheses. Tuple is similar to a list.
(ii) The difference between the two is that you cannot change the elements of a tuple once it is assigned whereas in a list, elements can be changed
(iii) Example : colour = ('red', 'blue, 'Green')
251.
List is constructed by placing expressions within square brackets separated by commas. List can store multiple values.
Example:
1st := [10, 20]
x, y:= 1st
In the above example x will become 10 and y will become 20.
252.
253.
| S.No | Constructors | Selectors |
| (i) |
Constructors are functions that build the abstract data type. |
Selectors are functions that retrieve information from the data type. |
| (ii) | Constructors create an object, bundling together different pieces of information. | Selectors extract individual pieces of information from the object |
254.
(i) 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.
(ii) The definition of ADT only mentions what operations are to be performed but not how these operations will be implemented.
255.
(i) Recursive function
(ii) Normal function
(iii) Recursive function
256.
| Interface | Implementation |
|---|---|
| Interface just defines what an object can do, but won't actually do it. | Implementation carriers out the instructions defined in the interface. |
257.
X: = (78) has an expression in it but (78) is not itself an expression. Rather, it is a function definition. Definitions bind values to names, in this case the value 78 being bound to the name 'X'.
258.
A function is a unit of code that is often defined within a greater code structure. Specifically, a function contains a set of code that works on many kinds of inputs, like variables, expressions and produces a concrete output.
259.
(i) Subroutines are the basic building blocks of computer programs. Subroutines are small sections of code that are used to perform a particular task that can be used repeatedly.
(ii) In Programming languages these subroutines are called as Functions.
260.
The following shows a simple Dynamic programming approach for the generation of Fibonacci series.
Initialize f0 = 0,f1 =1
Step 1 - Print the initial values of Fibonacci f0 and f1
Step 2 - Calculate fibanocci fib \(\leftarrow \) f0+ f1
Step 3 - Assign f0\(\leftarrow \) fl , f1\(\leftarrow \) fib
Step 4 - Print the next consecutive value of fibanocci fib
step 5 - Goto step-2 and repeat until the specified number of terms generated
For example if we generate fibobnacci series upto 10 digits, the algorithm will generate the series as shown below:
The Fibonacci series is : 0 1 1 2 3 5 8 13 21 34 55
261.
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. Dynamic Programming approach is similar to divide and conquer.
(i) The given problem will be divided into smaller overlapping sub-problems.
(ii) An optimum solution for the given problem can be achieved by using result of smaller sub-problem.
(iii) Dynamic algorithms uses Memoization.
262.
Step 1 - If it is the first element, it is already sorted.
Step 2 - Pick next element
Step 3 - Compare with all elements in the sorted sub-list
Step 4 - Shift all the elements in the sorted sub-list that is greater than the value to be sorted
Step 5 - Insert the value
Step 6 - Repeat until list is sorted
263.
(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 identified 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.
264.
(i) Start with the first element i.e., index = 0, compare the current element with the next element of the array.
(ii) If the current element is greater than the next element of the array, swap them.
(iii) 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 end of the index is reached.
265.
Start with the middle element:
(I) If the search element is equal to the middle element of the array i.e., the middle value = number of elements in array/2, then return the index of the middle element.
(ii) If not, then compare the middle element with the search value,
(iii) If the search element is greater than the number in the middle index, then select the elements to the right side of the middle index, and go to Step-1
(iv) If the search element is less than the number in the middle index, then select the elements to the left side of the middle index, and start with Step-1 ( When a match is found, display success message with the index of the element matched.
(vi) If no match is found for all comparisons, then display unsuccessful message
266.
(i) Traverse the array using 'for loop'
(ii) In every iteration, compare the target search key value with the current value of the list.
(iii) If the values match, display the current index and value of the array
(iv) If the values do not match, move on to the next array element
(v) If no match is found, display the search element not found.
267.
The execution time that you measure in this case would depend on a number of factors such as:
(i) Speed of the machine
(ii) Compiler and other system Software tools
(iii) Operating System
(iv) Programming language used
(v) Volume of data required
268.
The space required by an algorithm is equal to the sum of the following two components:
(i) A fixed part is defined as the total space required to store certain data and variables for an algorithm. For example, simple variables and constants used in an algorithm.
(ii) A variable part is defined as the total space required by variables, which sizes depends on the problem and its iteration. For example: recursion used to calculate factorial of a given value n.
269.
(i) A space-time or time-memory trade off is a way of solving in less time by using more storage space or by solving a given algorithm in very little space by spending more time.
(ii) To solve a given programming problem, many different algorithms may be used. Some of these algorithms may be extremely time-efficient and others extremely spaceefficient.
(iii) Time/space trade off refers to a situation where you can reduce the use of memory at the cost of slower program execution, or reduce the running time at the cost of increased memory usage.
270.
The algorithm can be written as:
Step 1: start the process
Step 2: get the input x
Step 3: calculate the square by multiplying the input value ie., square \(\leftarrow \)x* x
Step 4: display the result square
Step 5: stop
271.
| Search | To search an item in a data structure using linear and binary search. |
|---|---|
| Sort | To sort items in a certain order using the methods such as bubble sort, insertion sort, selection sort, etc. |
| Insert | To insert an item (s) in a data structure. |
| Update | To update an existing item (s) in a data structure. |
| Delete | To delete an existing item (s) in a data structure. |
272.
(i) Public members (generally methods declared in a class) are accessible from outside the class.
(ii) A variable which is declared outside of all the functions in a program is known as global variable.
(iii) A variable which is declared inside a function which contains another function definition with in it, the inner function can also access the variable of the outer function. This scope is called enclosed scope.
(iv) Built-in scope the widest scope has all the names that are pre-loaded into program scope when we. start the compiler or interpreter.
273.
(i) Public members (generally methods declared in a class) are accessible from outside the class.
(ii) Protected members of a class are accessible from within the class and are also available to its sub-classes.
(iii) Private members of a class are denied access from outside the class. They can be handled only from within the class.
274.
Public members (generally methods declared in a class) are accessible from outside the class. The object of the same class is required to invoke a public method. This arrangement of private instance variables and public methods ensures the principle of data encapsulation.
275.
(i) A module is a part of a program. Programs are composed of one or more independently developed modules. A single module can contain one or several statements closely related each other.
(ii) Modules work perfectly on individual level and can be integrated with other modules. A software program can be divided into modules to ease the job of programming and debugging as well.
(iii) A program can be divided into small functional modules that work together to get the output. The process of subdividing a computer program into separate subprograms is called Modular programming.
(iv) Modular programming enables programmers to divide up the work and debug pieces of the program independently. The examples of modules are procedures, subroutines, and functions.
276.
(i) Built-in scope is the widest scope. The built -in scope has all the names that are pre-loaded into the program scope when we start the compiler or interpreter.
(ii) Any variable or module which is defined in the library functions of a programming language has Built-in or module scope. They are loaded as soon as the library files are imported to the program.

(iii) Normally only Functions or modules come along with the software, as packages, therefore they will come under Built in scope.
277.
(i) Every variable defined in a program has global scope.
(ii) Once defined, every part of your program can access that variable. But it is a good practice to limit a variable's scope to a single definition.
(iii) This way, changes inside the function can't affect the variable on the outside of the function in unexpected ways.
278.
An ADT for rational numbers:
- - constructor
- - constructs a rational number with numerator n, denominator d
rational(n, d)
- - selector
number(x) \(\rightarrow \) returns the numerator of rational number x
denom(y) \(\rightarrow \) returns the denominator of rational number y
279.
(i) Data abstraction is supported by defining an abstract data type (ADT) which is a collection of constructors and selectors.
(ii) Constructors create an object, bundling together different pieces of information, while selectors extract individual pieces of information from the object.
280.
(i) Constructor
(ii) Selector
(iii) Constructor
(iv) Selector
(v) Selector
281.
The syntax for function types
x\(\rightarrow \)y
x1 \(\rightarrow \)x2\(\rightarrow \)y
x1 \(\rightarrow \) .... \(\rightarrow \)x n\(\rightarrow \)y
The 'x' and 'y' are variables indicating types. The type x \(\rightarrow \) y is the type of a function that gets an input of type 'x' and returns an output of type 'y'. Where as x1\(\rightarrow \) x2 -\(\rightarrow \) y is a type of a function that takes two inputs, the first input is of type 'x1' and the second input of type 'x1', and returns an output of type 'y'. Likewise x1 \(\rightarrow \)...\(\rightarrow \)x n\(\rightarrow \)y has type 'x' as input of n arguments and 'y' type as output.
282.
(requires: x>= 0)
let rec even x :=
x=0II odd (x-I)
return 'even'
(requires: x > = 0)
let odd x :=
x< >0 && even (x-I)
return 'odd'
283.
(i) The syntax to define functions is close to the mathematical usage: the definition is introduced by the keyword let, followed by the name of the function and its arguments; then the formula that computes the image of the argument is written after an = sign. If you want to define a recursive function: use "let rec" instead of "let".
(ii) Syntax: The syntax for function definitions:
let rec fn a1 a2 ... an :;= k
(iii) Here the 'fn' is a variable indicating an identifier being used as a function name. The names 'a1' to 'an' are variables indicating the identifiers used as parameters. The keyword 'rec' is required if 'fn' is to be a recursive function; otherwise it may be omitted.
284.
(i) 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.
(ii) Dynamic programming approach is similar to divide and conquer. The given problem is divided into smaller and yet smaller possible sub-problems.
(iii) Dynamic programming is used whenever problems can be divided into similar sub-problems. So that their results can be re-used to complete the process.
(iv) Dynamic programming approaches are used to find the solution in optimized way. For every inner subproblem, dynamic algorithm will try to check the results of the previously solved sub-problems. The solutions of overlapped sub-problems are combined in order to get the better solution.
285.
Asymptotic Notations are languages that uses meaningful statements about time and space complexity. The following three asymptotic notations are mostly used to represent time complexity of algorithms:
(i) Big O: Big O is often used to describe the worst -case of an algorithm.
(ii) Big \(\Omega \):Big Omega is the reverse Big O, if Big O is used to describe the upper bound (worst - case) of a asymptotic function, Big Omega is used to describe the lower bound (best -case).
(iii) Big \(\Theta \):When an algorithm has complexity with lower bound = upper bound, Say that an algorithm has a complexity O(n log n) and \(\Omega \) (n log n), it's actually has the complexity \(\Theta \) (n log n), which means the running time of that algorithm always falls in n log n in the best-case and worst-case.
286.
(i) Time Factor -Time is measured by counting the number of key operations like comparisons in the sorting algorithm.
(ii) Space Factor -Space is measured by the maximum memory space required by the algorithm.
287.
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.
(i) Time Complexity: The Time complexity of an algorithm is given by the number of steps taken by the algorithm to complete the process.
(ii) Space Complexity: Space complexity of an algorithm is the amount of memory required to run to its completion.
288.
(i) Input
(ii) Output
(iii) Finiteness
(iv) Definiteness
(v) Effectiveness
(vi) Correctness
(vii) Simplicity
(viii) Unambiguous
(ix) Feasibility
(x) Portable
(xi) Independent
289.
Output:
Red, Blue, Green
Red, Blue
Red.
Seope f Variables :

290.
(i) Access control is a security technique that regulates who or what can view or use resources in a computing environment.
(ii) It is a fundamental concept in security that minimizes risk to the object.
(iii) In other words access control is a selective restriction of access to data.
(iv) In object oriented programming languages is implemented through access modifiers.
291.
(i) All programming languages permit functions to be nested. A function (method) within another function is called nested function.
(ii) A variable which is declared, inside a function which contains another function definition with in it, the inner function can also access the variable of the outer function. This scope is called enclosed scope.
(iii) When a compiler or interpreter search for a variable in a program, it first searches Local, and then searches Enclosing scopes. Consider the following example
|
1. Disp(); |
Entire program |
Output of the program 10 10 |
292.
293.
(i) Local scope refers to variables defined in current function. Always, a function will first look up for a variable name in its local scope.
(ii) Only if it does not find it there, the outer scopes are checked.
(iii) Look at this example:
|
1. Disp(): |
Entire program |
Output of the Program 7 |
(iv) On execution of the above code the variable a displays the value 7, because it is defined and available in the local scope.
294.
(a) List
(b) Tuple
(c) Class
(d) Tuple
(e) List
(f) Class
295.
(i) The elements of a list can be accessed in two ways. The first way is via our familiar method of multiple assignment, which unpacks a list into its elements and binds each element to a different name.
lst := [10, 20]
x, y := lst
(ii) In the above example x will become l0 andy will become 20.
(iii) A second method for accessing the elements in a list is by the element selection operator. Unlike a list literal, a square brackets expression directly following another expression does not evaluate to a list value, but instead selects an element from the value of the preceding expression.
Ist [0]
10
lst [1]
20
296.
(a) Constructors
(b) Selectors
(c) Selectors
(d) Selectors
(e) Constructors
(f) Selectors
297.
A powerful strategy for designing programs, 'wishful thinking'. Wishful Thinking is the formation of beliefs and making decisions according to what might be pleasing to imagine instead of by appealing to reality.
298.
| S.No | Concrete data type | Abstract data type |
| (i) | Concrete Data Types or structures (CDT's) are direct implementations of a relatively simple concept | Abstract Data Types (ADT's) offer a high level view (and use) of a concept independent of its implementation. |
| (ii) | A concrete data type is a data type whose representation is known. | Abstract data type the representation of a data type is unknown. |
299.
The most popular groups of side effects is modifying the variable outside of function.
For example:
let y: = 0
(int) inc (int) x
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.
300.
| S.No | Pure Function | Impure Function |
|---|---|---|
| (i) | The return value of the pure functions solely depends on its arguments passed. | The return value of the impure functions does not solely depend on its arguments passed. |
| (ii) | If you call the pure functions with the same set of arguments, you will always get the same return values. | If you call the impure functions with the same set of arguments. You might get the different return values. |
| (iii) | They do not have any side effects. | They cause side effects. For example: random(),Date() |
| (iv) | They do not modify the arguments which are passed to them | They may modify the arguments which are passed to them |
301.
The variables used inside the function may cause side effects though the functions which are not passed with any arguments. In such cases the function is called impure function.
For example the mathematical function random() will give different outputs for the same function call.
let randomnumber :=
a := random()
if a > 10 then
return: a
else
return: 10
302.
(i) Strlen is a pure function because the function takes one variable as a parameter, and accesses it to find its length.
(ii) This function reads external memory but does not change it, and the value returned derives from the external memory accessed.
303.
(i) The class template specifies the interfaces to enable an object to be created and operated properly.
(ii) An object's attributes and behaviour is controlled by sending functions to the object.
304.
(i) Insertion sort is a simple sorting algorithm. It works by taking elements from the list one by one and inserting then in their correct position in to a new sorted list.
(ii) This algorithm builds the final sorted array at the end. This algorithm uses n-1 number of passes to get the final sorted list as per the pervious algorithm as we have discussed.
Pseudo for Insertion sort:
Step 1 - If it is the first element, it is already sorted.
Step 2 - Pick next element
Step 3 - Compare with all elements in the sorted sub-list
Step 4 - Shift all the elements in the sorted sublist that is greater than the value to be sorted Step 5 - Insert the value Step 6 - Repeat until list is sorted.
305.
(i) 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.
(ii) This algorithm will first find the smallest elements in array and swap it with the element in the first position of an array, then it will find the second smallest element and swap that element with the element in the second position, and it will continue until the entire array is sorted in respective order.
(iii) This algorithm repeatedly selects the next smallest element and swaps in into the right place for every pass. Hence it is called selection sort.
Pseudo code:
(i) Start from the first element i.e., index-(), 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 identified 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.
(v) Let's consider an array with values {13, 16, 11, 18, 14, 15}
(vi) Below, we have a pictorial representation of how selection sort will sort the given array respective order.
(i) In the first pass, the smallest element will be 11, so it will be placed at the first position.
(ii) After that, next smallest element will be searched from an array.
(iii) Then leaving the first element, next smallest element will be searched. It get 13 as smallest, so it will be placed at the second position.
(iv) Then leaving 11 and 13. It will search for the next smallest element and put it at third position and keep doing this until array is sorted.
(v) Finally, it will get the sorted array end of the pass.
306.
| Algorithm | Program |
|---|---|
| Algorithm helps to solve a given problem logically and it can be contrasted with the program | Program is an expression of algorithm in a programming language. |
| Algorithm can be categorized based on their implementation methods, design techniques etc | Algorithm can be implemented by structured or object oriented programming approach |
| There is no specific rules for algorithm writing but some guidelines should be followed. | Program should be written for the selected language with specific syntax |
| Algorithm resembles a pseudo code which can be implemented in any language | Program is more specific to a programming language |
307.
(i) Computer resources are limited that should be utilized efficiently. The efficiency of an algorithm is defined as the number of computational resources used by the algorithm.
(ii) An algorithm must be analyzed to determine its resource usage. The efficiency of an algorithm can be measured based on the usage of different resources.
(iii) For maximum efficiency of algorithm we wish to minimize resource usage. The important resources such as time and space complexity cannot be compared directly, so time and space complexity could be considered for an algorithmic efficiency.
Method for determining Efficiency:
(i) The efficiency of an algorithm depends on how efficiently it uses time and memory space.
(ii) The time efficiency of an algorithm is measured by different factors. For example, write a program for a defined algorithm, execute it by using any programming language, and measure the total time it takes to run.
(iii) The execution time that you measure in this case would depend on a number of factors such as: -
1. Speed of the machine
2. Compiler and other system Software tools
3. Operating System
4. Programming language used
5. Volume of data required
(iv) However, to determine: how efficiently an algorithm solves a given problem, you would like to determine how the execution time is affected by the nature of the algorithm.
(v) Therefore, we need to develop fundamental laws that determine the efficiency of a program in terms of the nature of the underlying algorithm.
308.
Suppose A is an algorithm and n is the size of input data, the time and space used by the algorithm A are the two main factors, which decide the efficiency of A.
(i) Time Factor: Time is measured by counting the number of key operations like comparisons in the sorting algorithm.
(ii) Space Factor: Space is measured by the maximum memory space required by the algorithm. 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.
(iii) Time Complexity: The Time complexity of an algorithm is given by the number of steps taken by the algorithm to complete the process.
(iv) Space Complexity: Space complexity of an algorithm is the amount of memory required to run to its completion. The space required by an algorithm is equal to the sum of the following two components:
A fixed part is defined as the total space required to store certain data and variables for an algorithm. For example, simple variables and constants used in an algorithm.
A variable part is defined as the total space required by variables, which sizes depends on the problem and its iteration. For example: recursion used to calculate factorial of a given value n.
309.
(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 list among n elements, by comparing the key element with each element in the list sequentially.
(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 0(1) because only one comparison is enough.
(iii) Similarly, the worst case in this scenario would be if the complete list is searched and the 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.
(iv) The average case efficiency of an algorithm can be obtained by finding the average number of comparisons as given below: Minimum number of comparisons = 1 Maximum number of comparisons = n If the element not found then maximum number of comparison = n Therefore, average number of comparisons = (n + 1)/2
(v) Hence the average case efficiency will be expressed as 0 (n).
310.
(i) Access control is a security technique that regulates who or what can view or use resources in a computing environment.
(ii) It is a fundamental concept in security that minimizes risk to the object.
(iii) In other words access control is a selective restriction of access to data. IN Object oriented programming languages it is implemented through access modifiers.
(iv) Classical object-oriented languages, such as C++ and Java. control the access to class members by public, private and protected keywords.
(v) Private members of a class are denied access from the outside the class. They can be handled only from within the class.
(vi) Public members (generally methods declared in a class) are accessible from outside the class. The object of the same class is required to invoke a public method. This arrangement of private instance variables and public methods ensures the principle of data encapsulation.
(vii) Protected members of a class are accessible from within the class and are also available to its sub-classes. No other process is permitted access to it. This enables specific resources of the parent class to be inherited by the child class.
(viii) Python doesn't have any mechanism that effectively restricts access to any instance variable or method. Python prescribes a convention of prefixing the name of the variable or method with single or double underscore to emulate the behaviour of protected and private access specifiers.
(ix) All members in a Python class are public by default. whereas by default in C++ and java they are private. Any member can be accessed from outside the class environment in Python which is not possible in C++ and java.
311.
(i) The basic idea of data abstraction is to structure programs so that they operate on abstract data. That is, our programs should use data in such a way, as to make as few assumptions about the data as possible.
(li) At the same time, a concrete data representation is defined as an independent part of the program.
(iii) Any program consist of two parts. The two parts of a program are, the part that operates on abstract data and the part that defines a concrete representation, is connected by a small set of functions that implement abstract data in terms of the concrete representation.
(iv) To illustrate this technique, let us consider an example to design a set of functions for manipulating rational numbers.
(v) Example: A rational number is a ratio of integers, and rational numbers constitute an important sub-class of real numbers. A rational number such as 8/3 or 19/23 is typically written as : < numerator > /< denominator >
(vi) where both the < numerator > and <denominator>
(vii) However, you can create an exact representation for rational numbers by combining together the numerator and denominator.
(viii) As we know from using functional abstractions, we can start programming productively before you have an implementation of some parts of our program.
(ix) Let us begin by assuming that you already have a way of constructing a rational number from a numerator and a denominator. You also assume that, given a rational number, you have a way of selecting its numerator and its denominator component.
312.
(i) 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.
(ii) Dynamic programming approach is similar to divide and conquer. The given problem is divided into smaller and yet smaller possible sub-problems.
(iii) Dynamic programming is used whenever problems can be divided into similar subproblems. so that their results can be reused to complete the process.
(iv) Dynamic programming approaches are used to find the solution in optimized way. For every inner subproblem, dynamic algorithm will try to check the results of the previously solved sub-problems.
(v) The solutions of overlapped sub-problems are combined in order to get a better solution.
Steps to doDynamic programming :
(i) The given problem will be divided into smaller overlapping sub-problems.
(ii) An optimum solution for the given problem can be achieved by using result of smaller sub-problem.
(iii) Dynamic algorithms uses Memoization
Fibonacci Series - An example :
(i) Fibonacci series generates the subsequent number by adding two previous numbers. Fibonacci series starts from two numbers -Fib 0 & Fib 1. The initial values of Fib 0 & Fib l can be taken as 0 and 1.
(ii) Fibonacci series satisfies the following conditions:
Fibn = Fiba-1 + Fiba-2
(iii) Hence, a Fibonacci series for the n value 8 can look like this
Fib8 = 0 1 1 2 3 5 8 13
Fibonaeci Iterative Algorithm with Dynamic programning approach : The following example shows a simple Dynamic programning approach for the generation ot Fibonacci series.
Initialize f0 = 0, f1 = 1.
Step- 1: Print the initial values of Fibonacci f0 and f1
Step- 2: Calculate Fibonacci fib \(\leftarrow \) f0+ f1
Step- 3: Assign f0 \(\leftarrow \) f1, f1 \(\leftarrow \) fib
Step- 4: Print the next consecutive value of Fibonacci fib
Step- 5: Go to step-2 and repeat until the specified number of terms generated
Example:
if we generate Fibonacci series up to 10 digits, the algorithm will generate the series as shown below:
The Fibonacci series is:
0 1 1 2 3 5 8 13 21 34 55.
313.
Bubble sort algorithm:
(i) Bubble sort algorithm simple sorting algorithm. The algorithm starts at the beginning of the list of values stored in an array. It compares each pair of adjacent elements and swaps them if they are in the unsorted order.
(ii) This comparison and passed to be continued until no swaps are needed, which indicates that the list of values stored in an array is sorted. The algorithm is a comparison sort, is named for the way smaller elements "bubble" to the top of the list.
(iii) Although the algorithm is simple, it is too slow and less efficient when compared to insertion sort and other sorting methods.
(iv) Assume list is an array of n elements. The swap function swaps the values of the given array elements.
Procedure :
(i) Start with the first element i.e., index = 0, compare the current element with the next element of the array.
(ii) If the current element is greater than the next element of the array, swap them.
(iii) 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.
(iv) 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.
(v) 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 sorted values in an array as given below:
| 11 | 12 | 13 | 14 | 15 | 16 |
314.
Binary Search:
Binary search also called half-interval search algorithm. It finds the position of a search element within a sorted array. The binary search algorithm can be done as a divide- and -conquer search algorithm and executes in logarithmic time.
Pseudo Code:
Start with the middle element:
(i) If the search element is equal to the middle element of the array i.e., the middle value = number of elements in array/2, then return the index of the middle element.
(ii) If not, then compare the middle element with the search value,
(iii) If the search element is greater than the number in the middle index, then select the elements to the right side of the middle index, and go to Step-1.
(iv) If the search element is less than the number in the middle index, then select the elements to the left side of the middle index, and start with Step-1.
(v) When a match is found, display success message with the index of the element matched.
(vi) If no match is found for all comparisons, then display unsuccessful message.
Binary Search Working principles :
(i) List of elements in an array must be sorted first for Binary search. The following example describes the step by step operation of binary search.
(ii) Consider the following array of elements, the array. is being sorted so itenables to do the binary searçh algorithm. Let us assume that the search element is 60 and we need to search the location or index of search element 60 using binary search.

(iii) First, we find index of middle element of. the array byusing this formula:
mid = low + (high - low) /2
(iv) Here it is, 0 + (9-0)/2=4 (fractional part ignored). So, 4 is thè mid value of the array.

(v) 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.

(vi) 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
(vii) Our new mid is 7 now. We compare the value stored at location 7 with our target value 60.

(viii) 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 from the current mid value location.

(ix) The search element still not found. Hence, we calculated the mid again by using the formula.
high = mid -1
mid = low +(high - low)/2
Now the mid value is 5.

(x) Now we compare the value stored at location 5 with our search element. We found that it is a match.

(xi) We can conclude that the search element 60 is found at locationor index 5. For example if we take the search element as 95, For this value this binary search algorithm return unsucessful result.
315.
(i) Linear search also called sequential search is a sequential method for finding a particular value in a list.
(ii) 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.
procedure :
1. Traverse the array using for loop
2. In every iteration, compare the target search key value with the current value of the list.
(i) If the values do not match, move on to the next array element.
(ii) If the values match, display the current index and value of the array.
3. If no match is found, display the search element not found.
(iii) 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.
| index | 0 | 1 | 2 | 3 | 4 |
| values | 10 | 12 | 20 | 25 | 30 |
Example 1:
Input: values[] = {5, 34, 65, 12, 77, 35)
target = 77
Output: 4
Example 2:
Input: values[] = [101, 392, 1, 54, 32, 22, 90, 93) target = 200
Output: -1 (not found)
316.
| Input | Zero or more quantities to be supplied. |
| Output | At least one quantityis produced. |
| Finiteness | Algorithms must terminate after finite number of steps. |
| Definiteness | All operations should be well defined. For example operations involving division by zero or taking square root for negative number are unacceptable. |
| Effectiveness | Every instruction must be carried out effectively. |
| Correctness | The algorithms should be error free. |
| Simplicity | East to implement. |
| Unambiguous | Algorithm should be clear and unambiguous. Each of its steps and their inputs/outputs should be clear and must lead to only one meaning. |
| Feasibility | Should be feasible with the avaliable resources. |
| Portable | An algorithm should be generic, independent of any programming language or an operating system able to handle all range of inputs. |
| Independent | An algorithm should have step-by-step directions, which should be independent of any programming code. |
317.
(i) Less code to be written.
(ii) A single procedure can be developed for reuse, eliminating the need to retype the code many times.
(iii) Programs can be designed more easily because a small teana deals with only a
small part of the entire code.
(iv) Modular programming allowS many programmers to collaborate on the same
application.
(v) The code is stored across multiple files.
(vi) Code is short, sirnple and easy to understand.
(vii) Errors can easily be identified, as they are localized to a subroutine or function.
(viii) The same code can be used in man applications.
(ix) The scoping of variables can easily be controlled.
318.
The following are the desirable characteristics of a module.
(i) Modules contain instructions, processing logic, and data.
(ii) Modules can be separately compiled and stored in a library.
(iii) Modules can be included in a program.
(iv) Module segments can be used by invoking a name and some parameters.
(v) Module segments can be used by other modules.
319.
Types of Variable Scope:
There are 4 types of Variable Scope, let's discuss them one by one:
Local Scope:
(i) Local scope refers to variables defined in current function. Always, a function will first look up for a variable name in its local scope. Only if it does not find it there, the outer scopes are checked.
Look at this example
| 1. Disp(): 2. a:=7 3. print a 4. Disp() |
Entire program |
Output of the Program 7 |
(ii) On execution of the above code the variable a displays the value 7, because it is defined and available in the local scope.
Global Scope:
(i) A variable which is declared outside of all the functions in a program is known as global variable.
(ii) This means, global variable can be accessed inside or outside of all the functions in a program.
Example:
| 1. a:=10 2. Disp(): 3. a:=7 4. print a 5. Disp() 6. print a |
Entire program |
Output of the Program 7 10 |
(iii) 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 defined in global scope.
Enclosed Scope:
(i) All programming languages permit functions to be nested. A function (method) with in another function is called nested function.
(ii) A variable which is declared inside a function which contains another function definition with in it, the inner function can also access the variable of the outer function. This scope is called enclosed scope.
(iii) When a compiler or interpreter search for a variable in a program, it first search Local, and then search Enclosing scopes. Consider
the following example:
| 1. Disp(): 2. a:=10 3. Disp1() 4. print a 5. Disp1() 6. print a 7. Disp() |
Entire Program |
Output of the Program 10 10 |
(iv) In the above example Disp1( ) is defined with in Disp( ). The variable 'a' defined in Disp( ) can be even used by Disp1( ) because it is also a member of Disp( ).
Built-in Scope:
(i) The built-in scope has all the names that are pre-loaded into the program scope when we start the compiler or interpreter.
(ii) Any variable or function which is defined in the modules of a programming language has Built-in or module scope. They are loaded as soon as the library files are imported to the program.Consider the following example.
| Library files associated with the software |
LEGB rule :
The LEGB rule is used to decide the order in which the scopes are to be searched
for scope resolution. The scopes are listed below in terms of hierarchy (highest to
lowest).
.png)
320.
(i) The structure construct (In OOP languages it's called class construct) is used to represent multi-part objects where each part is named (given a name). Consider the following pseudo code:
Class Person:
creation()
first Name:=""
last Name:=""
id :=""
email :=""
The new data type Person is pictorially represented as
In the case of something more complex, like a person, we have a multí-item object where each item is a named thing: the first name, the last name, the id, and the email. One could use a list to represent a person:
Person = ['padmashri', 'Baskar', '994-222-1234', 'compsci@gmail.com']
| Let main() contains | |
| p1:=Person() | statement creates the object |
| first name:= "padmashri" | setting a field called firstName with value padamashri |
| last name:= "Baskar" | setting a field called last name with value Baskar |
| id:= "994-222-1234" | setting a field called id value 994-222-1234 |
| email="compsci@gmail.com" | setting a field called email with value compsci@gmail.com |
| -- output of firstName: Padmashri | |
(ii) The class (structure) construct defines the from for multi-part objects that represent a person.
(iii) Person is referred to as a class or a type, while pl is referred to as an object or an instance.
(iv) Here class Person as a Cookie cutter, and pl as a particular cookie, Using the cookie cutter you can make many cookies, Same way using class created many objects of that type.
(v) A class defines a data abstraction by grouping related data items. A class is not just data, it has functions defined within it, We say such functions are subordinate to the class because their job is to do thngs with the data of the class.
321.
List :
(i) 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.
Example for List [10, 20].
(ii) The elenments of a list can be accessed in two ways. The first way is via our familiar method of multiple assignment, which unpacks a list into its elements and binds each elenment to a different name.
Ist := [10, 20]
x, y = lst
(iii) In the above example x will become l0 and y will become 20. A second method for accessing the elements in a list is by the element selection operator.
(iv) Unlike a list literal, a square-brackets expression directly following another expression does not evaluate to a list value, but instead selects an element from the value of the preceding expression.
lst [0]
10
Ist [1]
20
(v) In both the example mentioned above mathematically we can represent list similar to a set.

Pair :
Any way of bundling two values together into one can be considered as a pair. Lists are a common methodto do so. Therefore List can be called as Pairs.
322.
Data abstraction is used to define an Abstract Data Type (ADT), which is a collection of constructors and selectors. T facilitate data abstraction,you will need to create two types of functions : Constructors and Selectors.
Constructors :
(i) Constructors are functions that build the abstract data type.
(ii) Constructors create an object, bundling together different pieces of information.
(iii) For example, say you have an abstract data type called city.
(iv) This city object will hold the city's name, and its latitude and longitude.
(v) To create a city object, you'd use a function like city = makecity (name, lat, lon).
(vi) Here makecity (name, lat, lon) is the constructor which creates the object city.

Selectors :
(i) Selectors are functions that retrieve information from the data type.
(ii) Selectors extract individual pieces of information fromn the object.
(iii) To extract the information of a city object, you wouldused functions like
getname(city)
getlat(city)
getlon(city)
These are the selectors because these functions extract the information of the city object.
.png)
323.
Interface:
(i) An interface is a set of action that an object can do. For example when you press a light switch, the light goes on, you may not have cared how it splashed the light. In Object Oriented Programnming language, an Interface is a description of all functions.
(ii) In our example, anything that "ACTS LIKE" a light, should have function definitions like turn_on () and a turn_off (). The purpose of interfaces is to allow the Computer to enforce the properties of the class.
Implementation:
(i) Implementation carries out the instructions defined in the interface.
(ii) How the object is processed and executed is the implementation.
(iii) A class declaration combines the external interface (its local state) with an implementation of that interface (the code that carries out the behaviour).
For example, let's take the example of increasing a car's speed.

(iv) The person who drives the car doesn't care about the internal working. To increase the speed of the car he just presses the accelerator to get the desired behaviour. Here the accelerator is the interface between the driver (the calling / invoking object) and the engine ( the called object).
(v) In this case, the function call would be speed (70):, this is the interface Internally, the engine of the car is doing all the things but fuel, air, pressure, and electricity come together to create the power to move the vehicle.
(vi) All of these actions are separated from the driver, who just wants to go faster. Thus we separate interface from implementation.
324.
Pure functions:
(i) Pure functions are functions which will give exact result when the same arguments are passed.
(ii) For example the mathematical function sin (0) always results 0. This means that every time you call the function with the same arguments, you wil always get the same result.
(iii) A function can be a pure function provided it should not have any external variable which will alter the behavior of that variable.
let us see an Example:
Let square x : =
return: x * x
(iv) The above function square is a pure function because it will not give different results for same input.
(v) There are various theoretical advantages of having pure functions. One advantage is that if a function is pure, then if it is called several times with the same arguments, the compiler only needs to actually call the function once.
Example:
let length s:=
i:= 0
let i:= 0;
if i<strlen (s) then
-- Do something which doesn't affect s
++1
(vi) If it is compiled, strlen (s) is called each time and strlen needs to iterate over the whole of 's'. If the compiler is smart enough to work out that strlen is a pure function and that 's' is not updated in the loop, then it can remove the redundant extra calls to strlen and make the loop to execute only one time.
(vii) From these what we can understand, strlen is a pure function because the function takes one variable as a parameter, and accesses it to find its length. This function reads external memory but does not change it, and the value returned derives from the external memory accessed
Impure functions:
(i) The variables used inside the function may cause side effects through the functions which are not passed with any arguments. In which cases the function is called impure function.
(ii) When a function depends on variable or functions outside of its definition block, you can never be sure that the function will behave the same every time it's called. For example, the mathematical functions random ( ) will give different outputs for the same function call.
Example:
let randomnumber:=
a := random()
if a > 10 then
return: a
else
return: 10
(iii) Here the function Random is impure as it is not sure what will be the result when we call the function
325.
(i) gcd
(ii) let rec gcd
(iii) a, b
(iv) gcd(a mod b)
(v) return a
326.
Parameters and arguments:
Parameters are the variable in a function definition and arguments are the values which are passed to a function definition
(i) Parameter without Type: Let us see an example of a function,definition :
(requires: b >=0 )
(returns: a to the power of b)
let rec pow a b:=
if b=0 then 1
else a*powa(b-1)
(i) In the above function definition variable 'b' is the parameter and the value which is passed to the variable 'b' is the argument. The precondition (requires) and postcondition (returns) of the function is given.
(ii) Note we have not mentioned any types (data types). Some language computer solves this type (data type) inference problem algorithmically, but some require the type to be mentioned.
(iii) In, the above function deinition if expression can return 1 in the then branch, shows that as per the typing rule the entire if expression has type int
(iv) Since the if expression is of type 'int', the function's return type also be int. 'b' is compared to 0 with the equality operator. so 'b' is also a type of int: Since 'a' is multiplied with another expression using the operator, 'a' must be an int.
(ii) Parameter with Type: Now let us write the same function definition with types for some reasons:
(requires: b > 0 )
(returns: a to the power of b )
let rec pow (a:int) (b:int): int :=
if b=0 then 1
n else a * pow b (a-1)
(i) When we write the type annotations for ‘a’ and ‘b’ the parentheses are mandatory. Generally, we can leave out these annotations, because it's simpler to let the compiler infer them.
(ii) There are times we may want to explicitly write down types. This is useful on times when you get a type error from the compiler that doesn't make sense. Explicitly annotating the types can help with debugging such an error message.
(iii) The syntax to define functions is close to the mathematical usage: the definition is introduced by the keyword let followed by the name of the function and its arguments; then the formula that computes the image of the argumentis written atter an := sign. If you want to define a recursive function: use "let rec" instead of "let"
Syntax:The syntax for function detinitions: let irec fn al a2 ... an := k
(iv) Here the 'fn' is used as a function name. The nanmes 'a1' to 'an'are variables used as parameters. The keyword 'rec' is required if 'fn' is to be a recursive function; otherwise it may be omitted.
327.
iii and iv
328.
i and ii
329.
ii, iii
12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications களப்பெயர் முறைமை (DNS) Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு எடுத்துக்காட்டுகள் மற்றும் நெறிமுறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications கணினி வலையமைப்பு ஓர் அறிமுகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications PHP-உடன் MySQL-ஐ இணைத்தல் Sample Question Papers Study Material - QB365 Set A
Tamilnadu Stateboard 12th Standard Subjects

Maths

Chemistry

Physics

Biology

Computer Science

Business Maths and Statistics

Economics

Commerce

Accountancy

History

Computer Applications

Biology

Computer Technology

Computer Applications

Computer Science

Business Maths and Statistics

Commerce

Economics

Maths

Chemistry

Physics

Computer Technology

History

Accountancy

Tamil

English

French
Tamilnadu Stateboard Standards