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
i:=1 while(i { x:=x+1; i:=i+1; }

Data array A has data series from 1,000,000 to 1 with step size 1, which is in perfect decreasing order. Data array B has data series from 1 to 1,000,000, which is in random order.

In this unit, we described about the data structure Queue. It had two ends. One is front from where the elements can be removed and the other is rear where the elements can be inse

Loops There are 3 common ways of performing a looping function: for ... to ... next, while ... endwhile and repeat ... until The below example input 100 numbers and find

The quick sort algorithm exploit design technique Divide and Conquer

Binary: Each node has one, zero, or two children. This assertion creates many tree operations efficient and simple. Binary Search : A binary tree where each and every left

Q. Assume that we have separated n elements in to m sorted lists. Explain how to generate a single sorted list of all n elements in time O (n log m )?

Given is the structure of an AVL tree: struct avl { struct node *left; int info; int bf; struct node *right; }; 2) A multiway tree of n order is an ord

State about the pre- and post conditions Programmers can easily document other pre- and post conditions and class invariants, though, and insert code to check most value preco

In this assignment, you are invited to design and implement a software system for catalogue sale. A catalogue is organised in a tree structure. Each node of the catalogue tree repr