2
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 welldefined and should not create any ambiguity. Termination : Specifies that the instructions described in the algorithm must contain aproper 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:

Solutions to Chapter One Questions1

Embed Size (px)

DESCRIPTION

kuvempu university

Citation preview

Solutions to Chapter One Questions1.___________ is the process ofexecuting a correct program on data setsand measuring the time and spaceit takes tocompute the results?Ans. Profiling2.Define algorithm? What are its properties?Ans.An algorithm is aset 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 welldefined and should notcreate any ambiguity.Termination: Specifies that the instructions described in the algorithm must contain aproper 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 asample dataset.Profiling is the process ofmeasuring the performance of the program by executing it on different data sets. Performanceof a program ismeasured by recording the time andmemory space that the program takes during itsexecution.4.One of the properties ofan 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 ina hand: The bangles wore in a hand follow last-in-first-out (LIFO) strategy ofstack. 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 betaken out.Same circumference circular rings in a pole: The rings having same circumferenceplaced into a pole also follow LIFO strategy. The topmost ring, which was the last to beplaced in the pole, is the first one to betaken out.Sacks full of wheat placed one over other: The sack at the top is removed first and thesack at the bottom isremoved last.The bolts screwed to a single nut: When the bolts are screwed to a single nut, the lastscrewed bolt is unscrewed first and the bolt that was screwed first is unscrewed in the last.Battery cells in a torch: The battery cells in a torch also follow the same LIFO strategy ofstack.