Anda di halaman 1dari 7

PU11 Computer Science Notes Problem solving Techniquies

1

1. Define Sorting.
Sorting is a method of arranging data items in any order (ascending or descending)
2. What is searching? Mention any one type.
The process of finding a particular element in an array or file is called searching.
Linear search is one of the searching techniques.
3. What do you mean by structured programming?
A programming strategy that encompasses a number of methodologies or techniques to develop
good computer programs and not on only solving the problem.
4. Give one advantage of the linear search method.
Linear searching method works well for small array or for unsorted arrays.
5. What is an array?
An array is a group of elements, all of them are same type, size and having the same name.
6. Name two different types of searching techniques.
The different types of searching techniques are :
i) Binary Search ii) Linear search
7. When linear search can be employed?
Linear search is applicable when the data organized in an array is not in any order.
8. What is the other name of bubble sort?
Sorting by exchange.
9. Why is the bubble sort technique is popular?
Because it is very simple to understand and implement this algorithm.
10. Why is the number of comparison in bubble sort method?
2
N

11. Where does selection sort get its name?
Selection sort got its name because with each iteration the smallest element for a key position is
selected from the list of remaining elements and put in the required position of the array.
12. From which game is the technique of insertion sort formulated?
Card game.
13. Which technique does merge sort follow?
Drive and conquer.
14. What is the operation on which find the maximum in an array depends on?
Comparison Mechanism.
15. What are the constructs used in structured programming?
Sequence, selection, iteration and modularity.




PU11 Computer Science Notes Problem solving Techniquies

2

16. What do you mean by stepwise refinement?
In top-down approach of problem solving, a given problem is solved by breaking down in into
smaller manageable parts called as modules. Thus it is also called stepwise refinement.
17. Define module.
A module is a group of instruction, which may include a paragraph, a block, a subprogram or a
routine confined together as a single unit.
18. Why is the use of GOTO considered as undisciplined?
As it sends control backwards through the program.
19. Give one advantage for structured programming.
Are easy to write as the programming logic is well organized.
20. What is top-down approach also called as?
Stepwise refinement or modular programming.
21. What is top-down analysis?
A problem is decomposed into simple sub problems, each such sub-problem are decomposed into
small problems. Sub-problem becomes simple enough to be solved. This is called top-down
analysis.
22. Define the term modularity.
It is a technique where a given problem is divided into a number of self contained independent
program segments. Each program segment is called as a module.
23. What is the main disadvantage of linear search method?
Even if element is not present, we have to traverse the whole listing.
24. What is sorting? Mention any one method.
Sorting is a method of arranging data items in any order (ascending or descending)
Methods : Bubble sort, selection sort, insertion sort etc. (write any one)
25. Write any one advantage of linear search.
Without performing sorting operation, one can search for an element.
26. Write any one advantage of top-down approach
Top-down analysis divides the problem into independent modules which can solved easily.
27. What is worst case in sorting?
The worse case of sorting can be a selection of a complex algorithm to sort small amount of data.
28. When it is not possible to perform the operation of binary search?
If the array is not sorted it is not possible to perform binary search.
29. Define iteration.
The method of repeating the set of statements based on a condition is called iteration.





PU11 Computer Science Notes Problem solving Techniquies

3

Questions carrying TWO marks each :
1. Write an algorithm to find the maximum of N numbers OR write an algorithm to find the
maximum element in any array.
Given an array A of N elements, this procedure finds the largest element.
Step 1 : [ assume 1
st
element is the largest]
Large = A [0]
Step 2 : POS = 0
Step 3 : [Find the largest element in the array and its position]
For I = 1 TO N-1 Do
Step 4 : If (A [I]>large) Then
Step 5 : large = A [I]
[End lf]
[End of step 3 For loop]
Step 6 : [Print the largest]
Print Largest =, large
Step 7 : Stop.
2. Write an algorithm to find the location of an item in a list using linear search technique.
A is array of N element and ele is the element being searched in the array.
1. LOC - -1
2. For I = 0 TO N-1 DO
3. If (ele = A [1]) Then
4. LOC I
5. GOTO SETP 6
[End lf]
[End of For loop]
6. If (LOC >=0) then
7. Print ele, Found in location, LOC
8. Else
9. Print ele, Not found
[End lf]
10. Exit.
3. Mention different types of program design techniques.
Different types of program design techniques are algorithm, pseudo code and flow chart.
4. What are the advantages of structured program?
Advantages of structured programming are :
a) Structured programs are easy to write as the programming logic is well organized.



PU11 Computer Science Notes Problem solving Techniquies

4

b) Structured programs are easy to test and debug. (Since at any instant we are looking at a small
unit or module)
c) Structured programs are easy to maintain.
d) Structured programs can be functionally decomposed into logical working units.
5. Explain the term structured programming?
It focuses a lot on the methodologies or techniques of developing good computer program not on
only solving the problem. It suggests that will structured or organized program can be written
using various programming constructs such as sequence, selection, iteration and modularity.
6. Mention the advantages of top-down design.
The advantages of top-down approach are :
a) It outlines the broad concepts first and then subsequently going into the details.
b) The data previously used in the module can be used with or without changes.
c) The development or module can take place in parallel.
d) The stepwise refinement of problem into modules reduces burden by increasing clarity.
7. What are the things to be considered for input specifications?
The things to be considered for input specifications are :
i) How many inputs are required to solve problem?
ii) Is the input already in the readable form or should we access it in a certain way?
i) Is the data available or should it be generated?
8. What are the things to be considered for output specifications?
The things to be considered for output specifications are :
i) What form should the output take?
ii) Who will use the output generated.
9. Write and to find the minimum in an array.
Given an array A of N elements :
Step 1 : small = A [0] [assume 1
st
element is the smallest]
Step 2 : Pos = 0
Step 3 : [Find the smallest element in the array and its position]
Step 4 : If (A [I] < small) Then
For I = TO N 1 DO
Step 5 : small = A [I]
Step 6 : Pos = I
[End lf]
[End of step 3 for loop]
Step 7: [Print the smallest and its position]
Print smallest=, small, position=,pos



PU11 Computer Science Notes Problem solving Techniquies

5

Step 8 : Stop
10. How sorting is classified?
Sorting is broadly classified into two categories : sorting of array (called internal sorting) and
sorting of file (called external sorting)
11. Differentiate between internal and external sorting?
In internal sorting, all elements to be sorted are stored in the fast, high-speed, random access
internal memory (RAM) of the computer. On the other hand, the external sorting is concerned
with sorting of files, which is stored in external device send as a disk.
12. What is binary search ? When it is applicable?
First compare the key with the record in the middle position of the array. If there is match, then
the search is successful. If the key is less than the middle key, then the desired record must lie in
the lower half of the array; if it is greater than the middle key, then the record will be in upper half
of the array. The process is repeated to the lower half or upper half of the array. This method is
referred to as binary search.
It is applicable when elements are in the increasing order (sorted order)
13. Write an algorithm to perform selection sort.
Algorithm : Given an array a of n elements, this procedure sorts the elements in the ascending
order. The variables I and j are used to index the array elements.
Step 1 : For I = 0 to n-1
Step 2 : p = i
Step 3 : For j = i + 1 to n-1
Step 4 : if (a [p] > a [i]) then
p = j
[End if]
[End of for loop of step 3]
Temp = a [i]
a [i] = a [p]
a [p] = temp
[End of for loop of step 1]
Step 5 : Stop
14. Justify the need for sorting and mention any one sorting technique.
If the elements are sorted, searching can be done easily. Bubble sort, selection sort, insertion sort
etc. (Give any one)
15. What is top down design?
A given problem is broken down into smaller manage able parts called as modules. This type of
approach is called top down design.



PU11 Computer Science Notes Problem solving Techniquies

6


16. Construct a top-down design to find area of a circle.
Description of the solution :
Input : 1. Base
2. Height
Output 1. All values properly labelled.
2. Output the Area.

Area of triangle







Input data

Calculate Area

Output result











Base Height

Area - 0.5* Base*Height

Base Height Area

17. Briefly explain the analysis of insertion sort method.
In analysing the procedure of insertion sort, we will have to count the number of element
companies and the number of exchanges in the same as that in bubble sort. In the algorithm we
assume that all the elements are distinct.
The first pass of the algorithm results in one comparison and in the worst case may result in one
exchange also. The second pass results in two comparisons and in worst case may result in two
exchanges. Continuing the analysis we observe that as the iterations or pass increases the
comparisons and exchanges increases. Finally the total number of comparisons will be equal to 1+
2 + 3 +.+ (N-3) +(N-2) + (N-1) = (N) (N-1) / 2 = O

2
N

18. Mention the various programming constructs of structured programming.
The various programming constructs of structured programming are sequence, selection, iteration
and modularity.
19. Explain any two properties of Top down approach.
Two properties of Top down approach are :



PU11 Computer Science Notes Problem solving Techniquies

7

I ) Understand ability : The modules should be organized in such a way that they represent the
sequence of execution of the program. This helps the readability of the program and helps in
debugging to a large extent.
Ii) Clear Identification of tasks : Each module created should perform one and only one task. The
name of the module should be such that it can be automatically associated with the task.
20. What is program maintenance? Explain briefly.
Programs developed become outdated with time. sometimes errors creep in. depending on the
rules and users requirements, program need to be modified. Programs maintenance means
periodic review of the programs and modifications based on users requirements. To improve the
clarity, fresh documentation may be needed. Maintenance is a continue task. Documentation plays
an important role in program maintenance. It helps speedy and efficient maintenance.
21. Construct a top-down module chart for finding the area of a rectangle.









22. Construct a top-down design model chart to find the simple interest.
Refer Question No.4 (5 marks)
23. Define structured programming.
The method of programming using the concept of sequence, selection and iteration and
modularity without much use of goto statements is called Structured Programming.
24. Analyse the insertion sort method of sorting data.
In analysing insertion sort we should count number of comparisons and number of array elements
that must be shifted. If n is the number of elements, then in first pass the algorithm results in one
comparison and may result in one exchange. The second pass results in two comparison and may
result in two comparison. Continuing the analysis the total number of comparison will be equal to
1 + 2 + ..+ (n-3) + (n-2) + (n-1)
= (n) * (n-1) / 2
= O

2
n
Area of Rectangle
Input Data
Calculate Area Output result
Length Breadth
Area-
Length*Breadth
Breadth Length
Area

Anda mungkin juga menyukai