Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
P. 1
Java Programming for Bsc It 4th Sem kuvempu university

Java Programming for Bsc It 4th Sem kuvempu university



|Views: 4,301|Likes:
Published by Usha Shaw

More info:

Published by: Usha Shaw on Mar 02, 2012
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less





Assignment: TB (COMPULSORY) 41PART
AI. Say whether the following statements are true or false.
1) Definiteness is one of the properties of an algorithm.Ans:- TRUE2) Graph is a linear data structure.Ans :- FALSE3) A tree is a connected graph.Ans:- TRUE4) The data structure used by recursion is stack.Ans :- TRUE
5) Queue works on the strategy “First in First out”.
Ans :- TRUEII. Using suitable word or phrase fill up the blanks in the following sentences:1)_____________is the process of executing a correct program on data sets andmeasuring the time and space.Ans:- PROFILING2) Tree is a_____________data structure.Ans:-NON-LINEAR
3) For a graph with „n‟ number of nodes the number of edges to form a tree is
 _____________Ans: - n-1
4) “Last in First out” Data structure is referred to as
_____________Ans :- Stacks
5) A binary tree of depth „K‟ has maximum of 
_____________number of nodes.Ans : - 2
-1nodes,k>= 06) A_____________is a graph without self loop and parallel edges.Ans. SIMPLE GRAPH7) The two methods of searching are_____________and_____________ Ans.:- SEQUENTIAL SEARCH AND BINARY SEARCH
III. Write brief answers to the following questions:
1) Define algorithm. What are its properties?Ans :- An algorithm is a set of instructions that provide step-by-step specifications toperform a task.Ex:-Step by step procedure for display 10 natural numbers:-1.
Set the value of counter to 12.
Display counter3.
Increment counter by 14.
If counter <= 10, go to step 2The preceding step -by -step procedure is an algorithm because it produces thecorrect result inA finite number of steps.The properties of an algorithm are:
: Specifies the data set that is applied to the algorithm to check its validity.
: Specifies the data set that is produced as a result of the algorithm execution.
: Specifies that the instructions described in the algorithm should be welldefined and should not create any ambiguity.
: Specifies that the instructions described in the algorithm must contain aproper termination condition.
: Specifies that the algorithm take less time and less memory spaceduring its execution.2) Give atleast four 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 thelast one to be taken out while removing all the bangles from thehand. The bangle that is worn last is the first one to be taken out.
Same circumference circular rings in a pole
: The rings havingsame circumference placed into a pole also follow LIFO strategy.The topmost ring, which was the last to be placed in the pole, is thefirst one to be taken out.
The bolts screwed to a single nut
: When the bolts are screwed to asingle nut, the last screwed bolt is unscrewed first and the bolt thatwas screwed first is unscrewed in the last.
Battery cells in a torch
: The battery cells in a torch also follow thesame LIFO strategy of stack.3) Differentiate full and complete binary trees.Ans:- The following table lists the differences between complete binarytrees and full binary trees:
Complete binary trees Full binary trees
 All the nodes at the previous level are fullyaccommodated before thenext level is accommodated. All levels are maximallyaccommodated. Number of nodes at the last (n) level may or may not equal to 2
. Number of nodes at the last (n)level is exactly equal to 2
. Leaf nodes may or may not be at the same level. All leaf nodes are at the samelevel. A complete binary tree mayor may not be full binarytree. A full binary tree is always acomplete binary tree.
4) What are the demerits of recursion?Ans:- Demerits of recursion are:Many programming languages do not support recursion; hence,recursive mathematical function is implemented using iterativemethods.Even though mathematical functions can be easily implemented usingrecursion, it is always at the cost of execution time and memory space.

Activity (30)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
suresh1776job liked this
suresh1776job liked this
suresh1776job liked this
thangasingson liked this
suresh1776job liked this
suresh1776job liked this
suresh1776job liked this
suresh1776job liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->