C Board  

Go Back   C Board > Community Boards > General Discussions

Reply
 
LinkBack Thread Tools Display Modes
Old 04-17-2005, 07:38 AM   #1
UT2004 Addict
 
Kleid-0's Avatar
 
Join Date: Dec 2004
Posts: 645
Question 39: Quicksort vs Linear Search

Quote:
Would you rather wait for the results of a quicksort, a linear search, or a bubble sort on a 200000 element array?

Quicksort
Linear Search
Bubble Sort
The answer is linear search but I believe this question is hard to answer because I don't know if the results are coming from a sorting algorithm or a search. If we're talking about a sort the answer would be quicksort, and if we're searching it would obviously be linear search, am I right?
Kleid-0 is offline   Reply With Quote
Old 04-17-2005, 10:47 AM   #2
Crazy Fool
 
Perspective's Avatar
 
Join Date: Jan 2003
Location: Canada
Posts: 2,596
A linear search is O(n). Quick sort is O(n log(n)) [in its best case]. Bubble sort is O(n^2).

Which is the shortest of those three? O(n)

Whether your searching or sorting is irrelevant. The point of the question is to see which algorithm runs in the fastest time.
Perspective is offline   Reply With Quote
Old 04-17-2005, 11:03 AM   #3
It's full of stars
 
adrianxw's Avatar
 
Join Date: Aug 2001
Posts: 4,833
<pedant>Without a statement that says the dataset is not in order, the question is meaningless.</pedant>
__________________
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
adrianxw is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Contest Results - May 27, 2002 ygfperson A Brief History of Cprogramming.com 18 06-18-2002 01:27 PM
Search Engines :: Winsock kuphryn Windows Programming 3 06-18-2002 12:31 PM
Again Character Count, Word Count and String Search client C Programming 2 05-09-2002 11:40 AM
Linear search and 2d arrays? sven C Programming 0 02-08-2002 05:26 AM
Linear Search: the recursive way. Nutshell C Programming 7 01-15-2002 03:15 AM


All times are GMT -6. The time now is 03:28 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22