what is the best algorithm to sort out unique words from a
list of more than 10 million words(1 crore+)?
we need the best technique in the terms of execution time.
Answers were Sorted based on User's Feedback
Answer / thananjayan
Quick sort is better but we group the words and then used
| Is This Answer Correct ? | 18 Yes | 0 No |
Answer / rob
They're looking for unique words, so just sorting isn't good enough. Quicksort can still have a worst case runtime of n^2, or 10 million squared operations. We should use mergesort to guarantee O(nlogn) runtime, and then have a for loop to go through the list comparing element[i] with element [i+1], omitting element[i] if it is equal to element [i+1], and otherwise storing it in a new array or printing it to the screen, an O(n) operation. Then the final runtime is O(nlogn + n), ignoring the constant time to insert elements into a new array.
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / swati
Merge sort or Heap sort ..b'coz these sorting has optimal
running time i.e O(nlogn)..
| Is This Answer Correct ? | 3 Yes | 1 No |
write a c program, using for loop, that accepts and odds two numbers. The output must be the sum and the addens. This should be repeated 5 times while the first number is decremented by one and the second number is incremented by 1.
1. Write a program that performs the following. The user inputs a number and then enters a series of numbers from 1 to that number. Your program should determine which number (or numbers) is missing or duplicated in the series, if any. For example, if the user entered 5 as the initial number and then entered the following sequences, the results should be as shown. Input Sequence Output ---------------------- --------------- 1 2 3 4 5 Nothing bad However, if 7 were the high number, the user would see the results on the right for the following number entries: Input Sequence Output ---------------------- --------------- 1 3 2 4 5 Missing 6 Missing 7 And if 10 were the high number and the user entered the numbers shown on the left, note the list of missing and duplicate numbers: Input Sequence Output ---------------------- --------------- 1 2 4 7 4 4 5 10 8 2 6 Duplicate 2 ( 2 times) Missing 3 Duplicate 4 ( 3 times ) Missing 9
Deriving time complexity of Binary tree and AVL tree, step by step.
Assume in University Every student in university as entity, prepare a class for student that store the roll no, name, dob of student, and make funtion of deletion, manipulation, addition of student record.
Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.
main(){int a=5,b 10,c=2, d;a=b c;d=++a=(--c)*2; printf("%d%d%d%d,a,b,c,d; return o;}
write a proram using exceptional handling create a error & display the message "THERE IS AN ERROR?... PLEASE RECTIFY"?
Code for Method of Handling Factorials of Any Size?
develop a program to calculate and print body mass index for 200 employees
0 Answers Jomo Kenyatta University,
write a program that can locate elements in array.
hello friends, given an expression we have to remove the unwanted brackets in that expression. Eg : (a+b) ---> a+b (a+b)*(c)-----> (a+b)*c. Please mail me if you know the logic. My mail id is : saravana6m@gmail.com. Thank you in advance :-)
1 Answers GrapeCity, Microsoft,
Write a (n) algorithm that sorts n distinct integers, ranging in size between 1 and kn inclusive, where k is a constant positive integer. (Hint: Use a kn-element array.)