Frequency counts for all statements, Data Structure & Algorithms

Evaluate the frequency counts for all statements in the following given program segment.

for (i=1; i ≤ n; i ++)

for (j = 1; j ≤ i; j++)

for (k =1; k ≤ j; k++)

y ++;

Ans.

S1:  for (i=1; i<= n; i++) S2:  for (j=1; j,= i; j++)

S3 : for (k=1; k<= j; k++) S4 : y++;

Frequency counts of

S1=n

S2 = 1+ (1+2)+ (1+2+3) +....... (1+2+....n)

S3 = 1+ [ 1+ (1+2)] + .....[ 1+ (1+2) +....

(1+2+3+...n)]

S4= same as S3.

Posted Date: 7/12/2012 8:26:43 AM | Location : United States







Related Discussions:- Frequency counts for all statements, Assignment Help, Ask Question on Frequency counts for all statements, Get Answer, Expert's Help, Frequency counts for all statements Discussions

Write discussion on Frequency counts for all statements
Your posts are moderated
Related Questions
Example 3: Travelling Salesman problem Given: n associated cities and distances among them Find: tour of minimum length that visits all of city. Solutions: How several

One of the main problems with the linear queue is the lack of appropriate utilization of space. Assume that the queue can store 100 elements & the complete queue is full. Thus, it

Q. Write down an algorithm for finding a key from a sorted list using the binary search technique or method.

When there is requirement to access records sequentially by some key value and also to access records directly by the similar key value, the collection of records may be organized

Hear is given a set of input representing the nodes of a binary tree, write a non recursive algorithm that must be able to give the output in three traversal orders. Write down an

What is Ruby Ruby has numerous simple types, including numeric classes such as Integer, Fixnum, Bignum, Float, Big Decimal, Rational, and Complex, textual classes like String,

Explain in detail the algorithmic implementation of multiple stacks.

Q. What do you mean by the best case complexity of quick sort and outline why it is so. How would its worst case behaviour arise?

Insertion: Records has to be inserted at the place dictated by the sequence of keys. As is obvious, direct insertions into the main data file would lead to frequent rebuilding of

what is tree