Consider the following two sample codes in different language for software complexity analysis using Halstead matrics. Calculate the length, vocabulary, volume, difficulty, Effort, time, and number of delivered Bugs of each code. Create a comparison chart of time, Effort, bugs, and difficulty using any language. Use the below Table to compare Halstead matrics analysis of both example. Halstead Matrics Code 1 Code 2 N1 N2 n1 n2 Length (N) Vocabulary (n) Volume (V) Difficulty (D) Effort (E) Time Bugs Sample code 1 in Java: import java.util.HashSet; // program to remove duplicate values from the array public class DuplicateDetection { // method to remove duplicates static void removeDuplicate(int arr []) { HashSet uniqueSet = new HashSet<>(); for (int i = 0; i < arr.length; i++) { //check whether value exist already or not if(!uniqueSet.add(new Integer(arr[i]))){ System.out.println("Duplicate found : "+ arr[i]); continue; } } // print all unique value of the array for (Integer integer : uniqueSet) { System.out.println(integer); } } public static void main(String[] args) { // take integer array as an input int arr [] = {3,6,2,8,5,9,3,2,0,5,7}; // calling method to remove duplicates removeDuplicate(arr); } } Sample code 2 in Python: # program to remove duplicate value of the array # function to remove duplicates def removeduplicates(arr): s = set() for value in arr: # check whether value already exist or not if value in s: print("Duplicate found ", value) s.add(value) #printing unique values of array print(s) #take array as an input arr = [2,5,6,2,7,4,7,3,5,5]
Comments
Leave a comment