Professional Documents
Culture Documents
Solutions To Chapter One Questions1
Solutions To Chapter One Questions1
___________ is the process of executing a correct program on data sets and measuring the
time and space it takes tocompute the results?
Ans. Profiling2.
Define algorithm? What are its properties?
Ans.
An algorithm is a set of instructions that provide step-by-step specifications to perform a
task.The properties of an algorithm are:
Input
: Specifies the data set that is applied to the algorithm to check its validity.
Output
: Specifies the data set that is produced as a result of the algorithm execution.
Definiteness
: Specifies that the instructions described in the algorithm should be well defined and
should not create any ambiguity.
Termination
: Specifies that the instructions described in the algorithm must contain a proper
termination condition.
Effectiveness
: Specifies that the algorithm take less time and less memory space duringits execution.
3.
What is debugging and what is profiling?
Ans.
Debugging is the process of identifying and fixing the errors in a program. Errors in a program
can be identified byexecuting the program with a sample dataset.Profiling is the process
of measuring the performance of the program by executing it on different data sets.
Performanceof a program is measured by recording the time and memory space that the
program takes during its execution.
4.
One of the properties of an algorithm is beauty (true/false)
Ans. FalseSolutions to Chapter Two Questions1.
Give at least 5 real life examples where we use stack operations.
Ans.
The real life examples of stacks are:
Bangles in a hand
: The bangles wore in a hand follow last-in-first-out (LIFO) strategy of stack. The bangle that you
wear first is the last one to be taken out while removing all thebangles from the hand. The
bangle that is worn last is the first one to be taken out.
: The sack at the top is removed first and thesack at the bottom is removed last.