in IS&Software Engineering retagged by
593 views
0 votes
0 votes

Given the following algorithm for sorting an array X and N numbers:
                 

 SUBROUTINE SHORT (X, N)
                                IF (N < 2)
                                          RETURN
                                FOR (i = 2) TO N INCREMENT BY 1)
                                FOR (j = 1) TO i INCREMENT BY 1)
                                IF (X [i] > X [j])
                                          CONTINUE
                                TEMP = X[i]
                                X[i] = X[j]
                                X[j] = TEMP
                  END FOR
END SUBROUTINE


A good  approximation of Halstead`s estimated program length is

  1. 20
  2. 50
  3. 80
  4. 110
in IS&Software Engineering retagged by
593 views

1 Answer

1 vote
1 vote
Best answer

Ans:B

Program length (N)

The program length (N) is the sum of the total number of operators and operands in the program:
        N = N1 + N2

  • \,N_{1} = the total number of operators
  • \,N_{2} = the total number of operands

Operators are

Operator Occurences
IF 2
RETURN 1
FOR 2
TO 2
INCREMENT 2
BY 2
CONTINUE 1
END 1
() 4
[] 6
< 1
> 1
= 5

N1=30

OPERAND OCCURENCES
N 2
i 5
j 4
TEMP 2
2 2
1 3
X 2

N2=20

Program Length= 20+30=50

selected by
Answer:

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true