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.

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Teta-Omeg-Big-Oh Show that f(n) = n2 + 3n3 is ;(n3).

3193


write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.

3956


How to swap two ASCII numbers?

2449


We need to write the function to check the password entered is correct or not based on the following conditions.. a) It must have atleast one lower case character and one digit. b)It must not have any Upper case characters and any special characters c) length should be b/w 5-12. d) It should not have any same immediate patterns like abcanan1 : not acceptable coz of an an pattern abc11se: not acceptable, coz of pattern 11 123sd123 : acceptable, as not immediate pattern adfasdsdf : not acceptable, as no digits Aasdfasd12: not acceptable, as have uppercase character

3957


Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.

2152






develop a program to calculate and print body mass index for 200 employees

2216


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?

2915


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

2065


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

4577


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!!!)

3272


How can I Draw an ellipse in 3d space and color it by using graph3d?

2137


Ask the user to input three positive integers M, N and q. Make the 2 dimensional array of integers with size MxN, where all the elements of I (I = 1,…,M) line will be members of geometrical progression with first element equal to the number of line (I) and denominator q.

3395


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.)

4451


Code for Method of Handling Factorials of Any Size?

2006


write a program that creates a sequenced array of numbers starting with 1 and alternately add 1 and then 2 to create the text number in the series , as shown below. 1,33,4,6,7,9,............147,148,150 Then , using a binary search , searches the array 100 times using randomly generated targets in the range of 1 to 150

3265