Complexity T(n)

Write a linear-time algorithm that sorts n distinct
integers, each of which is between 1 and 500.

Hint: Use a 500-element array. (Linear-time means your
algorithm runs in time c*n + b, where c and b are any
constants that do not depend on n.

For example, your algorithm can run in time n, or time 2n +
1, or time 5n + 10, or time 100n + 6, but not time c*n*n =
c*n?.)



Complexity T(n) Write a linear-time algorithm that sorts n distinct integers, each of which is ..

Answer / siierbkkueutr

A great resource - many thanks!

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C++ Code Interview Questions

solve the problem in the programming language C++"if a five digit number is input through the keyboard.Write a program to calculate the sum of its digits(hint: use the modulus operator)

0 Answers  


Implement a command console for changing settings on a particular object. The command console should allow you to enter a string and will return the response (very similar to a terminal session). The commands are as follows: SET propertyname=newvalue will change the target object’s member named “propertyname” to have a value equal to “newvalue”. If the input value is incompatible (i.e. an int being set to a string), print out an appropriate error message. GET propertyname will print out the current value of the target object’s member named “propertyname”. GET * will print out a list of all target object members and their current values. The system should be extensible for future commands and should accept an arbitrary object, such that another developer could insert another object into the system and rely on the command console to get and set the properties correctly.

0 Answers   ABC, Guidance Software,


using friend function find the maximum number from given two numbers from two different classes.write all necessary functions and constructor for the classes.

1 Answers   TCS,


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

0 Answers   iGate,


Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)

3 Answers   Nagarro,






Here's the programm code: int magic(int a, int b) { return b == 0 ? a : magic(b, a % b); } int main() { int a, b; scanf("%d%d", &a, &b); printf("%d\n", magic(a, b)); return 0; } on input stream we have integers 4, 45 What's the output integer? How many times will be initiated "magic" function?

1 Answers  


Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.

0 Answers   Facebook, Webyog, Wipro,


Given 1 to n distinct random number of which n+1th element was duplicated. How do find the duplicate element and explain the time complexity of the algorithm.

0 Answers   Microsoft, NetApp,


write a program that reads a series of strings and prints only those strings begging with letter "b"

0 Answers  


Write a program using one dimensional array that accept five values from the keyboard. Then it should also accept a number to search. This number is to be searched if it among the five input values. If it is found, display the message “Search number is found!” otherwise, display “Search is lost”. Example: Enter 5 numbers: 10 15 20 7 8 Enter number to search: 7 Search number is found!

2 Answers   College School Exams Tests,


Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37

0 Answers   Nagarro,


Write a program that print in screen a tree with its height taken from user by entering number of 4 digits and find the odd numbers then calculate the sum of odd numbers so he get the height of tree?

0 Answers  


Categories