0% found this document useful (0 votes)
11 views

Lbps

Problem solving and logic behind
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lbps

Problem solving and logic behind
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

LBPS

Logic Building and Problem Solving

Q1. What is LBPS ?


Ans. Logic building is a technique for finding solutions for a given Problem using a
systematic , technical and simple to implement methodology . That is achieved
by various tools and techniques.

Q2. What are the features of LBPS?


Ans. Logical Building is used to conceptualize and understand a large project in
small –small modules and then to generate a systematic flow of the problem
solving and finally shape it to real life use that is in the form of a software
product.
Q3.What are the Tools of Logical Building for Problem Solving ?
Ans. 1. Algorithm
2.flow Chart
3.Pseudocode
Q4. What is an Algorithm?
An algorithm is a set of well-defined instructions in sequence to solve a problem.

Q5.Why Algorithm?
Ans. An algorithm is important in optimizing a computer program according to
the available resources. Ultimately when anyone decide to solve a problem
through better algorithms then searching for the best combination of program
speed and least amount of memory consumption is desired.
Q6. What are the types of algorithm ?
There are 7 Different types of algorithms those are used by computer
programmers.
1.Brute force
Brute force algorithm emphasis on solving problems in the most straight forward
manner. It implies to use basic techniques to solve problems. In short these are
simplest algorithms to be used. The simplicity costs in speed as this algorithm is
comparatively slow in generating results. The best way is to use it with problems
those are having small input size.
2.Divide and conquer
The basic idea of this method is to make programs based on dividing the size of
problems. In each loop cut the problem in parts with constant factor and then
process further in the same fashion. This is a fast algorithm.
3.Decrease and conquer
This method is having the basic idea as above method but the slight difference is
there. It decreases the size of problem in each iteration. In dive and conquer each
iteration cut the problem with a constant factor.
4.Dynamic programming
If you are searching of one efficient fast algorithm then dynamic programming is
here. In this algorithm all focus is made on speed of execution even it costs
memory space. Simply saying in this method space for time is sacrificed. The
execution speed drastically reduces in this algorithm. This method is particularly
useful to solve problems that those have overlapping sub problems.
5.Greedy algorithm
Greedy algorithm is a step based algorithm. In a greedy algorithm we analyze the
problem in each step. Then use the best locally possible optimum solution to this
particular step .Then the process repeats to all steps. It will lead to a globally
optimal solution.
6.Transform and conquer
This algorithm is based on using approaches we already know. The problem is
transformed in to well familiar step based solutions. At last we accumulate the
solution of each step at final step. Thus the name of this algorithm states self
about the working. For example if we need to find the lcm of a number and we
already know how to calculate GCD. This method says calculate LCM with the help
of GCD as we know
LCM ( a , b ) = (a * b) / GCD ( a , b )
7.Backtracking algorithm
In backtracking we generate a solution and test. If this solution is satisfying all
conditions then and then only we go for further subsequent solutions else we will
take a back gear simply saying backtrack and select a different path of finding
solution. This process continues until we get a final solution.
Q6. What are Qualities of a good algorithm ?
Ans.
1. Input and output should be defined precisely.
2. Each step in the algorithm should be clear and unambiguous.
3. Algorithms should be most effective among many different ways to solve a problem.
4. An algorithm shouldn't include computer code. Instead, the algorithm should be written
in such a way that it can be used in different programming languages.
Q6. Write an algorithm to find sum of two numbers ?
Ans.
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Input values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step 5: Display sum
Step 6: Stop

Q6. Write an algorithm to withdraw money from ATM ?


Ans. Let us now look at the steps to withdraw money from an ATM.

Step 1: Insert ATM Card:


Step 2: Select Language
Step 3: Enter 4-Digit ATM Pin:
Step 4: Select the type of Transaction:
Step 5: Select the Type of Account:
Step 6: Enter the withdrawal amount
Step 7: Collect the Cash:
Step 8: Take a printed receipt , if needed:
Step 9: Another Transaction:
Q7. Write an algorithm to make a cup of Tea ?
Ans. This is an algorithm for making a cup of tea.

1. Put the teabag in a cup.


2. Fill the kettle with water.
3. Boil the water in the kettle.
4. Pour some of the boiled water into the cup.
5. Add milk to the cup.
6. Add sugar to the cup.
7. Stir the tea.
8. Drink Tea

Q8. What is a Flow Chart ?


A flowchart is simply a graphical representation of steps. It shows steps in
sequential order and is widely used in presenting the flow of algorithms,
workflow or processes. Typically, a flowchart shows the steps as boxes of
various kinds, and their order by connecting them with arrows.

Q9..Why a Flow Chart ?


Ans.Flowcharts play an extremely important role in displaying information and
assisting reasoning. They help us visualize complex processes, or make
explicit the structure of problems and tasks. A flowchart can also be used to
define a process or project to be implemented.

Q10. What are Flow Chart Symbols ?


Ans.Flowchart Symbols

Different flowchart shapes have different conventional meanings. The meanings of some of the
more common shapes are as follows:
Terminator
The terminator symbol represents the starting or ending point of the system.

Process

A box indicates some particular operation.


Document

This represents a printout, such as a document or a report.


Decision

A diamond represents a decision or branching point. Lines coming out from the
diamond indicates different possible situations, leading to different sub-processes.
Data/input

It represents information entering or leaving the system. An input

might be an order from a customer. Output can be a product to be delivered.


On-Page Reference
This symbol would contain a letter inside. It indicates that the flow continues on
a matching symbol containing the same letter somewhere else on the same page .

Off-Page Reference
This symbol would contain a letter inside. It indicates that the flow
continues on a matching symbol containing the same letter somewhere else on
a different page.
Delay or Bottleneck
Identifies a delay or a bottleneck.

Flow connection
Lines represent the flow of the sequence and direction of a process.

Q11. Flow chart for sum of two numbers?


Q 12. Draw a Flow chart describing flow of boarding to an aero plane ?
Ans.

Q1.Draw Flow Chart for comparing two numbers ?


Q2.Draw a Flow chart for finding event or odd ?
Q3.Draw a Flow Chart to accept principal amount , rate of interest and time for an amount
depositing in a bank and find out amount at the end of the year that the depositor will get.
Q12.What is Pseudocode?
Ans.Pseudocode is an informal high-level representation of the actual code ( C/C++ Program )
that shows how an algorithm or a computer program works in plain English.

Q13.Why pseudocode?
Ans.It is a common language for writing statements in English / standard language that can be utilized by
any programming languages through programmer before writing actual codes . Writing pseudocode
allows us to get those brilliant ideas in our mind without having to worry about the syntax of the
programming language. Since it has no specific syntax, it is easy to read and write, and programmers can
comfortably communicate ideas and concepts, even if they are working on different programming
languages.

Q14. What are the keywords used in writing pseudocode ?


Ans. The following is the list of keywords used for pseudocode writing :-
// - comments writing
Begin ….End - To start a program
Accept - To accept input
Compute - it is used for the calculation purpose
Display - It is used to display the output.
If…..else… - it is used to test condition on that basis statements
are executed.
Repeat …..until - is used looping // looping is a repeatitive process.
While loop - Looping
For …loop - Looping
Q15. What is a variable ?
Ans. It is name given to an identifier that is used to store data temporarily.
at a particulare location
Ex. Num1,num2
Age, grade,salary,empno,empname
Q16.What are data types ?
Ans. In general purpose there are two types of data i.e. numeric, character

Ex. Numeric rollno, empno

Character studentname, empname,productname

Q17.What are Operators ?

Ans.Operators :
Operators are used to perform various operation in the computer these
are:-
a.Mathematical - +,-,*,/,%
Used in mathematical calculation
ex. a+b, a-b, a*b etc.

b.Relation Operators >< >= <= ==


These are used to compare to or more variables.
ex. a>b, a==b, a>=b
c.Logical - &&, || ,!
These Are used to test a condition and returns true and false values.
Ex.
If ( marks >=33 && marks <=45 )
Your are pass with grade ‘C’
Else
Your are pass with grade ‘C’

Q18.Write an Example to display use of Pseudocode ?


( Using printing nos. from 1 to 10 ).
Ex.1

Begin
set i to 1
for each i from 1 to 10
display i
end for loop
End
Ex.2 write an example to display even number
// display even number
Begin
Set I = 1
For each I from 1 to 50
begin
If modulas of I is equal to 0
begin
Display i
End
End for loop
End
Note: Pseudocode does not have a specific syntax so pseudocode can look
different in each.
Q 15.Write a Pseudocode for adding two numbers ?
Ans.
BEGIN
NUMBER s1, s2, sum
OUTPUT("Input number1:")
INPUT s1
OUTPUT("Input number2:")
INPUT s2
sum=s1+s2
OUTPUT sum
END

Conditional Construct
1. If ….else
2. Switch Case

Q.Write a pseudocode to a menu then let the user select any one of
one selection from the menu and display message.
begin
Declare var ans
Repeat
Begin
Output “Food menu”
Output “=========”
Output ”1.Samosa”
Output “2.Burgar”
Output “3.pizza”
Output “4.icecream”
Output “5.exit”
Output “Enter your choce from 1-5”
Accept ans
Switch( ans )
Begin
Case 1 : //begins
Output “you have opted for samosa”
Break
Case 2 :
Output “you have opted for burgar”
Break

Default :
Output “wrong input”
Break
Case 5 :
Output “exit program”
Break
Switch end
End
Until ans !=5
End
End

You might also like