1. Consider the following algorithm:
for ( i = 1 ; i <= 1 . 5 n ; i++)
cout << i ;
for ( i = n ; i >= 1 ; i - - )
cout << i ;
(a) What is the output when n = 2, n = 4, and n = 6?
(b) What is the time complexity T(n)? You may assume that the input n is divisible by 2.


No Answer is Posted For this Question
Be the First to Post Answer

Post New Answer

More AI Algorithms Interview Questions

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.

0 Answers  


Tell briefly about the Banker's algorithm and what is it used for?

0 Answers   Impetus,


What is software cycle? Give a diagrammatic representation?

0 Answers  


What is simulated annealing algorithm?

0 Answers  


What is greedy best first search algorithm?

0 Answers  






What is iterative deepening depth-first search algorithm?

0 Answers  


Which algorithm inverts a complete resolution strategy?

0 Answers  


Which algorithm is used for solving temporal probabilistic reasoning?

0 Answers  


What features would you use to build a recommendation algorithm for users?

0 Answers   Twitter,


can anyone help me with some suggestions and improvemnts for sage line 50?

0 Answers  


Which search algorithm will use a limited amount of memory in online search?

0 Answers  


1. Consider the following algorithm: for ( i = 1 ; i <= 1 . 5 n ; i++) cout << i ; for ( i = n ; i >= 1 ; i - - ) cout << i ; (a) What is the output when n = 2, n = 4, and n = 6? (b) What is the time complexity T(n)? You may assume that the input n is divisible by 2.

0 Answers  


Categories