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 |
A suduco given & u hv 2 check if it is incomplete(blanks left),or correct or incorrect
Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?
how to find out the maximum number out of the three inputs.
6 Answers ABC, Apple, C3I, HP, TCS,
Write a program to enter 10 number of integer entries into an array n and then odds up all the odd entries. the program then displays the result. plssss answer assss fast asss u can...
what is virtual constroctor ? give an exam for it?-(parimal dhimmar)
Faster Computers Suppose you have a computer that requires 1 minute to solve problem instances of size 1000. What instance sizes can be run in 1 minute if you buy a new computer that runs 1000 times faster than the old one, assuming the following time complexities T(n) for our algorithm? (a) T(n) = O(n). (b) T(n) = O(n3). (c) T(n) = O(10n).
create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file
Given 1 to n random number, find top 10 maximum numbers and explain the time complexity of the algorithm.
What is the time complexity T(n) of the following program? a) int n, d, i, j; cin >> n; for (d=1; d<=n; d++) for (i=1; i<=d; i++) for (j=1; j<=n; j += n/10) cout << d << " " << i << " " << j << endl; b) void main() { int n, s, t; cin >> n; for (s = 1; s <= n/4; s++) {t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } } c) void main() { int n, r, s, t; cin >> n; for (r = 2; r <= n; r = r * 2) for (s = 1; s <= n/4; s++) { t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } }
3 Answers CTS, IBM, Infosys, Qatar University,
What will be the output- for(i=1;i<=3;i++) { printf("%d",i); continue; i++; }
Write an algorithm that receives a string and reverses it.
write a function that allocates memory for a single data type passed as a parameter.the function uses the new operator and return a pointer to the allocated memory.the function must catch and handle any exception during allocation