Consider the following algorithm:
j = 1 ;
while ( j <= n/2) {
i = 1 ;
while ( i <= j ) {
cout << j << i ;
i++;
}
j++;
}
(a) What is the output when n = 6, n = 8, and n = 10?
(b) What is the time complexity T(n)? You may assume that the input n is divisible by 2.
Answer / gokul s
n=6:
(1, 1)
(2, 1)
(2, 2)
(3, 1)
(3, 2)
(3, 3)
n=8:
(1, 1)
(2, 1)
(2, 2)
(3, 1)
(3, 2)
(3, 3)
(4, 1)
(4, 2)
(4, 4)
(4, 4)
n=10:
(1, 1)
(2, 1)
(2, 2)
(3, 1)
(3, 2)
(3, 3)
(4, 1)
(4, 2)
(4, 3)
(4, 4)
(5, 1)
(5, 2)
(5, 3)
(5, 4)
(5, 5)
b) Time complexity is ((n/2) * (n/2)+1)/2
Is This Answer Correct ? | 2 Yes | 3 No |
list the types of linked list with aid of diagram?
Consider the following algorithm: j = 1 ; while ( j <= n/2) { i = 1 ; while ( i <= j ) { cout << j << i ; i++; } j++; } (a) What is the output when n = 6, n = 8, and n = 10? (b) What is the time complexity T(n)? You may assume that the input n is divisible by 2.
How are the k-nearest neigh-bors (knn) algorithms different from k-means clustering?
Which is the most straight forward approach for planning algorithm?
A* algorithm is based on which search method?
What is the uniform cost search algorithm?
When an algorithm is considered completed?
Give an algorithm for the following problem. Given a list of n distinct positive integers, partition the list into two sublists, each of size n/2, such that the difference between the sums of the integers in the two sublists is minimized. You may assume that n is a multiple of 2.
what are the minimum requirements for statr testing?
What was deep learning, & how does it contrast with other machine learning algorithms?
What is software cycle? Give a diagrammatic representation?
What is the iterative deepening depth-first search algorithm?