Determine the input size for each and justify your answer No coding, ONLY NEED T
ID: 2247419 • Letter: D
Question
Determine the input size for each and justify your answer
No coding, ONLY NEED THE INPUT SIZE AND PROVE IT
//determines average of given 4 integers
1. average(int n1, int n2, int n3, int n4)//determines a and returns average of given 4 integers
2. match(String s, String t) //prints all the strings t that appears in given string s as substring
3. gcd(int n, int m) //determines the gratest common divisor of integer m and integer
4. merge(int a[], int b[]) ////merging two sorted array
5. Sort(int a[]) //sort integer array a
6. shortestPath(graph G, int n, int m) //finds the shortest path from vertex n to vertex m
7. multiplication( matrix A, Matrix B) //multiplays n x k matrix A with k x m matrix B
Explanation / Answer
1) average(int n1, int n2, int n3, int n4)
This will take 8 bytes in memory as integer is 2 byte in memory and we have 4 integers as input
2) match(String s, String t)
The memory is 48 bytes as String takes max 24 bytes in memory
3) gcd(int n, int m)
This will take 4 bytes memory as intefer is 2 bytes in memory
4) merge(int a[], int b[])
This will take the size of 2 * ( length of a + length of b )
5) sort(int a[])
This will take 2 * size of a bytes in memory
6)shortestPath(graph G, int n, int m)
This will take 2 * size of ( n * m ) bytes in memory
7) multiplication( matrix A, Matrix B)
This will take size of matrix A * size of matrix B bytes in memory
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.