Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DO NUMBER 5 4 . Coupling and cohesion - ( 5 pts ) What kind of Cohesion do the following modules have? why? ( a

DO NUMBER 54. Coupling and cohesion -(5 pts) What kind of Cohesion do the following modules have? why? (a)(In a computer) read a file; update this file; save the file (b) type in the username; type in the password; (c) write the specification, finish the project based on it; (d) scan the bar-code of an item; get money from the client; give him the changes; give him the item (e) type in a resume; print out an assignment; scan in a picture -(10 pts) What kind of couplings do the following modules have and why? Module A: private int A state; A state =C(7,8); if ( A state >4) global time =8; else global _time =100; Module B: A state = rand 0%4; if ( A_state ==1) global time =6; Module C: private int C state; parameters i, j=1 ; // a call without defining parameter j is fine if (i%2) C-state =7; else C state =100; return C state + rand (0%4; Module D: if (( module) C( rand 0%8)>10) print( "good"); 5. Coding with quality request Provide brief analyses justifications of the time complexities for both questions. (a)(7 pts) For a sorted array of size n with value from 1 thru n. Suppose one element is randomly chosen and repeated and located next to it, one such array is [1,2,3,3,4,5,6,7] where n is 7 and 3 is repeated. Develop an algorithm with the lowest possible time complexity to find out the only repeated element. (b)(8 pts) Give two sorted arrays A and B, develop a function to generate a new sorted array C that consists of elements strictly from A and B alternatively, i.e., if A=[1,4,5], B=[2,6], then C=[1,2,4,6]; if A=[5,6], B=[2,4], then C=[5]. Your code should handle all possible cases that may arise. (c)(9 pts) Write an iterative function iterativeMerge(A) to sort an unsorted input A into sorted array by iteratively applying the merge function. Assume the merge function merge (B, C) is available for you to call where the two sorted array B and C is merged into a larger sorted array with time complexity linear to the total size B and C.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions

Question

Describe three forms of conflict from the work of Lewin.

Answered: 1 week ago