how to determine the complexity of an algorithm as log(n)



how to determine the complexity of an algorithm as log(n)..

Answer / karthik

log(n) is depth of binary tree containing n-elements..
so if we split array into two and omit one part and consider
another part... and continue this process.....
in problems like this the complexity will be log(n)..

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?

0 Answers  


Why cann't whole array can be passed to function as value.

1 Answers  


How can you invoke another program from within a C program?

0 Answers  


How to write a code for reverse of string without using string functions?

0 Answers   TCS,


What are qualifiers and modifiers c?

0 Answers  






Define C in your own Language.

0 Answers   Motorola,


can you explain in brief what is "r+" mode in a file... i know that it si used to read and modify rhe existing content.... but explalanation about the file pointer in "r+" mode i wann to know???????????

2 Answers   Cognizant,


what wud be the output? main() { char *str[]={ "MANISH" "KUMAR" "CHOUDHARY" }; printf("\nstring1=%s",str[0]); printf("\nstring2=%s",str[1]); printf("\nstring3=%s",str[2]); a)string1=Manish string2=Kumar string3=Choudhary b)string1=Manish string2=Manish string3=Manish c)string1=Manish Kumar Choudhary string2=(null) string3=(null) d)Compiler error

9 Answers   Infosys,


Find occurence of a character in a sting.

3 Answers   TCS,


What does sizeof function do?

0 Answers  


Is c is a procedural language?

0 Answers  


wite a programme in c to linear search a data using flag and without using flags?

3 Answers   TCS,


Categories