0% found this document useful (0 votes)
12 views8 pages

IP Unit1 Essay Questions

It is use for in computer

Uploaded by

lusserl43
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)
12 views8 pages

IP Unit1 Essay Questions

It is use for in computer

Uploaded by

lusserl43
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/ 8

Unit - 1

Long Answer Questions

1. Explain in detail about problem-solving techniques.


Problem-solving techniques
Problem solving is a creative process which defines systematization and mechanization.
There are a number of steps that can be taken to raise the level of one’s performance in problem
solving.
Steps for Problem - Solving
To effectively solve problems, follow these structured steps and strategies:
1. Problem Definition Phase: Clearly understand the problem by focusing on what needs to be
done, rather than how to do it. This involves accurately defining the problem to prevent
addressing the wrong issue or missing key aspects.
2. Getting Started on a Problem: Begin by understanding the scope of the problem. Avoid delving
into implementation details too early. Use heuristics or rules of thumb to start with a specific
example or subproblem, which can provide insights into the broader issue.
3. The Use of Specific Examples: Work with specific examples to clarify the problem and explore
potential solutions. This method helps in breaking down the problem into more manageable parts
and defining the relationship between the problem and possible solutions.
4. Similarities Among Problems: Leverage past experiences and identify similarities with
previous problems. Apply known solutions and techniques while being open to different
perspectives to uncover innovative solutions.
5. Working Backwards from the Solution: Start by assuming a solution is already known and
work backwards to outline the steps needed to achieve it. Document your process to avoid
redundant efforts and improve understanding.
6. General Problem-Solving Strategies:
i. Divide and Conquer: Break the problem into smaller, more manageable subproblems. Solve
each subproblem individually, which can be more efficient than tackling the entire problem at
once. Combine the solutions to address the original problem.
ii. Dynamic Programming: Build up a solution through a sequence of intermediate steps. Store
and reuse results of subproblems to avoid redundant calculations and improve computational
efficiency.
Applying these steps and strategies helps in structuring the problem-solving process,
enhancing both clarity and efficiency.

2. Discuss the concept “computer as a problem solving tool” in detail.


Using computer as a problem - solving tool
The computer is a resource - a versatile tool - that can help you solve some of the problems
that you encounter. A computer is a very powerful general-purpose tool. Computers can solve or
help to solve many types of problems. There are also many ways in which a computer can
enhance the effectiveness of the time and effort that you are willing to devote to solving a problem.
Thus, it will prove to be well worth the time and effort you spend to learn how to make effective
use of this tool. So, let us discuss the steps involved in developing a program.
Program development is a multi-step process that requires you to understand the problem,
develop a solution, write the program, and then test it. This critical process determines the overall
quality and success of your program. If you carefully design each program using good structured
development techniques, your programs will be efficient, error-free, and easy to maintain.
The following are the steps in detail:
1. Develop an Algorithm and a Flowchart.
2. Write the program in a computer language (for example say C programming language).
3. Enter the program using some editor.
4. Test and debug the program.
5. Run the program, input data, and get the results.

3. Explain in detail about algorithm and flowchart with an example.


Algorithm:
An algorithm is a finite set of steps defining the solution of a particular problem. An
algorithm is expressed in pseudo code - something resembling C language or Pascal, but with
some statements in English rather than within the programming language. Developing an efficient
algorithm requires lot of practice and skill. It must be noted that an efficient algorithm is one
which is capable of giving the solution to the problem by using minimum resources of the system
such as memory and processor’s time. Algorithm is a language independent, well-structured and
detailed. It will enable the programmer to translate into a computer program using any high-level
language.
Example:
Let us try to develop an algorithm to compute and display the sum of two numbers
1. Start
2. Read two numbers ‘a’ and ‘b’.
3. Calculate the sum of ‘a’ and ‘b’ and store it in ‘sum’.
4. Display the value of ‘sum’.
5. Stop.
Flowchart:
The next step after the algorithm development is the flowcharting. Flowcharts are used in
programming to diagram the path in which information is processed through a computer to
obtain the desired results. Flowchart is a graphical representation of an algorithm. It makes use of
symbols which are connected among them to indicate the flow of information and processing. It
will show the general outline of how to solve a problem or perform a task. It is prepared for better
understanding of the algorithm.
Example:
The flowchart to compute and display the sum of two numbers is shown below:
4. Explain about different flowchart symbols with an example.
Basic Symbols used in flowchart design

Additional Symbols Related to more advanced programming

1. Oval: Rectangle with rounded sides is used to indicate either START/ STOP of the program.
2. Input and output indicators: Parallelograms are used to represent input and output operations.
Statements like INPUT, READ and PRINT are represented in these parallelograms.
3. Process Indicators: Rectangle is used to indicate any set of processing operation such as for
storing arithmetic operations.
4. Decision Makers: The diamond is used for indicating the step of decision making and therefore
known as decision box. Decision boxes are used to test the conditions or ask questions and
depending upon the answers, the appropriate actions are taken by the computer.
5. Flow Lines: Flow lines indicate the direction being followed in the flowchart. In a Flowchart,
every line must have an arrow on it to indicate the direction. The arrows may be in any direction.
6. On-Page connectors: Circles are used to join the different parts of a flowchart and these circles
are called on-page connectors. The uses of these connectors give a neat shape to the flowcharts. In
a complicated problem, a flowchart may run into several pages. The parts of the flowchart on
different pages are to be joined with each other. The parts to be joined are indicated by the circle.
7. Off-page connectors: This connector represents a break in the path of flowchart which is too
large to fit on a single page. It is similar to on-page connector. The connector symbol marks where
the algorithm ends on the first page and where it continues on the second.
Example:
The flowchart to compute and display the sum of two numbers is shown below:

5. Develop an algorithm and design a flowchart for calculating the area of a equilateral triangle.
� �
Area of equilateral triangle is computed by formula ���� = �
� , where ‘a’ is length of side of
triangle.
Algorithm:
1. Start
2. Input: Read the side length ‘a’ of the equilateral triangle.

3. Calculate the area: ���� = � ��
4. Output: Display the calculated area ‘Area’.
5. Stop
Flowchart:
6. Explain about Top-down approach. Draw a Flow chart for reading student marks in three
subjects and print total and average.
Top Down Design
Once we have defined the problem and have an idea of how to solve it, we can then use the
powerful techniques for designing algorithms. Most of the problems are complex or large
problems and to solve them we have to focus on, to comprehend at one time, a very limited span
of logic or instructions. A technique for algorithm design that tries to accommodate this human
limitation is known as top-down design or stepwise refinement.
Top down design provides the way of handling the logical complexity and detail
encountered in computer algorithm. It allows building solutions to problems in step by step. In
this way, specific and complex details of the implementation are encountered only at the stage
when sufficient groundwork on the overall structure and relationships among the various parts of
the problem.
Before the top down design can be applied to any problem, we must at least have the
outlines of a solution. Sometimes this might demand a lengthy and creative investigation into the
problem while at another time the problem description may in itself provide the necessary starting
point for the top-down design.
Top-down design suggests taking the general statements about the solution one at a time,
and then breaking them down into a more precise subtask / sub-problem. These sub-problems
should more accurately describe how the final goal can be reached. The process of repeatedly
breaking a task down into a subtask and then each subtask into smaller subtasks must continue
until the sub-problem can be implemented as the program statement. With each spitting, it is
essential to define how subproblems interact with each other. In this way, the overall structure of
the solution to the problem can be maintained. Preservation of the overall structure is important
for making the algorithm comprehensible and also for making it possible to prove the correctness
of the solution.

7. Explain about the efficiency of algorithm and write an algorithm to find the greatest of three
numbers.
Efficiency of algorithm:
Every algorithm uses some of the computer’s resources like central processing time and
internal memory to complete its task. Because of high cost of computing resources, it is desirable
to design algorithms that are economical in the use of CPU time and memory. Efficiency
considerations for algorithms are tied in with the design, implementation and analysis of
algorithm. Analysis of algorithms is less obviously necessary, but has several purposes:
 Analysis can be more reliable than experimentation. If we experiment, we only know the
behaviour of a program on certain specific test cases, while analysis can give us guarantee
about the performance on all inputs.
 It helps one choose among different solutions to problems. As we will see, there can be many
different solutions to the same problem. A careful analysis and comparison can help us decide
which one would be the best for our purpose, without requiring that all be implemented and
tested.
 We can predict the performance of a program before we take the time to write code. In a large
project, if we waited until after all the code was written to discover that something runs very
slowly, it could be a major disaster, but if we do the analysis first we have time to discover
speed problems and work around them.
Algorithm to find the greatest of three numbers:
1. Start
2. Read three numbers ‘a’, ‘b’ and ‘c’.
3. If (a >= b && a >= c), print “a is the greatest”.
4. Else if (b >= c), print “b is the greatest”.
5. Else print “c is the greatest”.
6. Stop

8. Explain the concept of algorithm complexity.


Algorithm Complexity:
Suppose X is an algorithm and n is the size of input data, the time and space used by the
algorithm X are the two main factors, which decide the efficiency of X.
An algorithm is said to be efficient and fast, if it takes less time to execute and consumes
less memory space. The performance of an algorithm is measured on the basis of following
properties
 Time Factor − Time is measured by counting the number of key operations such as
comparisons in the sorting algorithm.
 Space Factor − Space is measured by counting the maximum memory space required by the
algorithm.
Space Complexity:
Space complexity is the amount of memory used by the algorithm (including the input
values to the algorithm) to execute and produce the result. While executing, algorithm uses
memory space for three reasons:
1. Instruction Space: It's the amount of memory used to save the compiled version of instructions.
2. Environmental Stack: Sometimes an algorithm(function) may be called inside another
algorithm(function). In such a situation, the current variables are pushed onto the system stack,
where they wait for further execution and then the call to the inside algorithm (function) is made.
3. Data Space: Amount of space used by the variables and constants. But while calculating the
Space Complexity of any algorithm, we usually consider only Data Space and we neglect the
Instruction Space and Environmental Stack.
Time Complexity:
Time complexity of an algorithm signifies the total time required by the program to run till
its completion. The time complexity of algorithms is most commonly expressed using the big O
notation. It's an asymptotic notation to represent the time complexity. Time Complexity is most
commonly estimated by counting the number of elementary steps performed by any algorithm to
finish execution.
9. Explain in detail about Big ‘O’ Notation with an example.
Big O notation is a mathematical notation used to describe the upper bound of an
algorithm's time complexity, which helps in understanding how the runtime of an algorithm
grows as the size of the input increases. It's a way to express the worst-case scenario for the
algorithm's performance in terms of its input size.
Definition: Big O notation, denoted as O(f(n)), describes the upper bound of the time complexity
of an algorithm. It provides a way to express the growth rate of an algorithm's runtime relative to
the input size ‘n’. It abstracts away constants and lower-order terms, focusing on the dominant
term that affects the growth rate.
Common Classes:
O(1): Constant time – The runtime does not change with the size of the input.
O(log n): Logarithmic time – The runtime grows logarithmically with the input size.
O(n): Linear time – The runtime grows linearly with the input size.
O(n log n): Linearithmic time – The runtime grows proportionally to n log n.
O(n2): Quadratic time – The runtime grows quadratically with the input size.
O(2n): Exponential time – The runtime doubles with each additional input element.
Example:
Let's use Linear Search to illustrate Big O notation.
Linear Search:
Linear Search is a straightforward algorithm used to find an element in a list. It works by
checking each element in the list one by one until the desired element is found or the list is
exhausted.
Algorithm:
1. Input: A list of ‘n’ elements and a target value.
2. Process:
- Start from the first element of the list.
- Compare the target value with the current element.
- If the target value is found, return the index of the element.
- If not, move to the next element and repeat the comparison.
- If the end of the list is reached without finding the target, return an indication that the
target is not present (often ‘-1’).
Time Complexity Analysis:
1. Best Case: The target value is at the very beginning of the list. In this case, the algorithm only
needs to make one comparison. Hence, the time complexity in this scenario is O(1), which is
constant time.
2. Worst Case: The target value is at the very end of the list, or the target value is not in the list at
all. In this scenario, the algorithm has to check every element in the list. Therefore, it makes n
comparisons. The time complexity in this case is O(n), which means it grows linearly with the size
of the input list.
3. Average Case: On average, the target value might be found halfway through the list. However,
when expressing time complexity in Big O notation, we are primarily concerned with the upper
bound, so the average case still falls under O(n) as it is proportional to the size of the list.
Therefore, for Linear Search algorithm,
Best Case: O(1) – The element is found in the first position.
Worst Case: O(n) – The element is at the last position or not in the list.
Average Case: O(n) – The average position where the element might be found.
In this way, Big O notation helps us understand the efficiency of algorithms by providing a
high-level view of how their runtime or space requirements grow with the input size.
10. Explain best, worst and average case analysis with respect to an algorithm.
Best case:
This is the lower bound on running time of an algorithm. We must know the case that
causes minimum number of operations to be executed. For example, an array A[ ] = {1, 2, 3, 4, 5}
and we are finding if "1" is present in the array or not. So here, after only one comparison, we will
get that your element is present in the array. So, this is the best case of your algorithm.
Average case:
We calculate running time for all possible inputs, sum all the calculated values and divide
the sum by total number of inputs. We must know (or predict) distribution of cases.
Worst case:
This is the upper bound on running time of an algorithm. We must know the case that
causes maximum number of operations to be executed. In our example, the worst case can be if
the given array is A[ ] = {1, 2, 3, 4, 5} and we try to find if element "6" is present in the array or not.
Here, the if-condition of our loop will be executed 5 times and then the algorithm will give "0" as
output.
Worst Case Analysis (Usually Done)
In the worst case analysis, we calculate upper bound on running time of an algorithm. We
must know the case that causes maximum number of operations to be executed. For Linear Search,
the worst case happens when the element to be searched (x in the above code) is not present in the
array. When x is not present, the search() functions compares it with all the elements of array A[ ]
one by one. Therefore, the worst-case time complexity of linear search would be O(n).
Average Case Analysis (Sometimes done)
In average case analysis, we take all possible inputs and calculate computing time for all of
the inputs. Sum all the calculated values and divide the sum by total number of inputs. We must
know (or predict) distribution of cases. For the linear search problem, let us assume that all cases
are uniformly distributed (including the case of x not being present in array). So we sum all the
cases and divide the sum by (n+1). Following is the value of average case time complexity.
Best Case Analysis (Bogus)
In the best case analysis, we calculate lower bound on running time of an algorithm. We
must know the case that causes minimum number of operations to be executed. In the linear
search problem, the best case occurs when x is present at the first location. The number of
operations in the best case is constant (not dependent on n). So time complexity in the best case
would be O(1).
Most of the times, we do worst case analysis to analyze algorithms. In the worst analysis,
we guarantee an upper bound on the running time of an algorithm which is good information.
The average case analysis is not easy to do in most of the practical cases and it is rarely
done. In the average case analysis, we must know (or predict) the mathematical Distribution of all
possible inputs.
The Best Case analysis is bogus. Guaranteeing a lower bound on an algorithm doesn’t
provide any information as in the worst case, an algorithm may take years to run.

You might also like