Sorting A List - Algorithem Search

Pages: 1, 2
free web hosting
Free Web Hosting > Computers & Tech > Programming > Programming General > Algorithms (Languageless)

Sorting A List - Algorithem Search

iamrockandroll13
yeah I meant log base 2, I was kind of out of it when I posted

Reply

mdchurchill
Quicksort is average O(log N) time, but at worst O(N^2) if the data is annoyingly constructed. There are algorithms that run in more consistent log time (e.g. mergesort, heapsort) but there algorithms are much simpler. Well definately in the second case. In the former case (in Haskell notation which is so beautiful I AM introducing these forums to the lovely world of FP):

Merge (x:xs) (y:ys) = if (x < y) then x:Merge(xs, y:ys) else
Merge [] ys = ys
Merge xs [] = xs

MergeSort xs = Merge (Mergesort ys) (MergeSort zs)
where ys = odds xs
zs = evens xs

odds (x:y:xs) = x:odds(xs)
odds [x] = x
odds [] = []

evens (x:y:xs) = y:evens(ys)
evens [y] = []
evens [] = []

Where here x:xs represents x at the front of a list of xs, [] the empty list and [] the singleton list.

(In other words - to sort a list [3,2,4,1] we split into odds and evens - [3,4] and [2,1], then sort these recursively into [3,4] and [1,2] and then Merge them together into [1,2,3,4]. Merge takes to (ordered) lists and produces an (ordered) list by looking at the first element of both (see above.))

 

 

 


Reply

wykurz
i think that in most cases the best choice is to use common library algorithms, like C++ quicksort. it's a very smart modification of insertion sort (much better than bubble sort, because it leaves the same element's in order they were in the beginning) and original quicksort. takes one line to write it.

if you don't want to use libraries, you can easily write insertion sort. works pretty fast with lists up to 50 elements (if larger think about QS).

if sorting integers from a certain range you can use algorithm that would work in O(n) (easy to guess how it works, i hope tongue.gif )

if you're just interested in theoretical algorythmic aspect of how fast can i sort a list of X elements (where X is constant), than it's quite easy to think out how can you do it with list of up to 6 elements. for a list of 24 elements it took 3 weeks to compute the result with 3 PCs (pentium III 1GHz).

regards

Reply

BitShift
Many programmers consider the quicksort to be the fastest sorting algorithm available.

Technically its not.


There is a sort called the Merge Sort which takes a recursive means of sorting.

Let me give you a comparison. I hope you understand Big O notation, its pretty easy.




Bubble Sort:
  • Data are in completely random order: O(n^2)
  • Data are ordereed from lowest to highest: O(n)
  • Data are ordered from highest to lowest: O(n^2)
Insertion Sort:
  • Data are in completely random order: O(n log(n))
  • Data are ordereed from lowest to highest: O(n)
  • Data are ordered from highest to lowest: O(n log(n))
-I'm not 100% sure that these are the correct Big O runtimes for the Insertion sort.

Quick Sort:
  • Data are in completely random order: O(n log(n) )
  • Data are ordereed from lowest to highest: O(n^2)
  • Data are ordered from highest to lowest: O(n^2)
Merge Sort:
  • Data are in completely random order: O(n log(n) )
  • Data are ordereed from lowest to highest: O(n log(n) )
  • Data are ordered from highest to lowest: O(n log(n) )
As you can see, the Bubble sort is only good, when the list is already sorted. However your not going to sort an already sorted list.

The Quick sort is awesome when the list is random. However, if the list isn't completely random, and is only off by a few elements, it takes longer.

The Merge sort is consistent, providing O(n log(n) )


If you don't know, "n" is the number of elements in the list you are sorting.

People say the Quick Sort and Binary Search are related, because Binary Search uses the same technique and a Binary Search also has O(n log(n) ).

I have no code on the merge sort in any language I just know its there. One of the reasons that the Merge Sort proves to be more effective then the Quick Sort is that the Quick Sort is implemented in such a way to save Memory. The Merge Sort uses a recursive method and therefore, uses a ton of memory.

The Insertion sort looks better then the Merge sort, but I'm not 100% sure that I have the correct Big O runtimes for the insertion sort.

Anyways, I just posted this because I wanted to share information that I had.

Reply

evought
qsort or quicksort is already implemented in many languages or their add-on libraries (e.g. C++ STL, Java, Python, Ruby) there is seldom a need to write your own sort method these days unless it is just as a learning exercise.

Note that many of these libraries come with source code if you want to look at how they are done.

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Pages: 1, 2
Recent Queries:-
  1. bubble sort characters in assembly - 5.64 hr back. (2)
  2. quicksort alphabetical sort - 10.92 hr back. (2)
  3. mergesort.asm - 16.98 hr back. (1)
  4. haskell sort list alphabetically - 17.66 hr back. (1)
  5. bubble sort keywords to remember - 18.98 hr back. (1)
  6. assembly code for bubble sorting of sign numbers in variable array - 19.54 hr back. (1)
  7. sorting a list - 29.01 hr back. (1)
  8. c timing quicksort array - 29.30 hr back. (1)
  9. open source code mergesort assembler - 34.80 hr back. (1)
  10. java sort seperate evens and odds - 58.22 hr back. (1)
  11. c quicksort calculate time - 62.94 hr back. (1)
  12. merge sort array assembly - 135.56 hr back. (1)
  13. mergesort assembly - 137.09 hr back. (1)
  14. merge sort assembly - 137.47 hr back. (2)
Similar Topics

Keywords : sorting, list, algorithem, search

  1. Download From Ftpz, Using Ftp Search Sitez
    Download From Ftpz, Using Ftp Search Sitez (0)
  2. Homepages Friends
    Get PAID to search! (5)
    I recently signed up for "Homepages Friends", a program which pays you about €0.02 for every search
    you make using their version of Yahoo. The system is very easy to use, as you simply add the toolbar
    to your browser (or you can do it online instead - either way no download is needed). I have yet to
    cash out, as the minimum is €20, and I only have about €2. However, if you are an avid searcher, or
    if you're simply willing to spend a lot of time working on it, you can EASILY get €4 + a day.
    Also, you can invite friends and get a portion of their intake (I believe it&#....
  3. How To: Display A Members/user List.
    With PHP, Mysql, and HTML. (3)
    Alright, some of you might want to display your User's or Members on your site. Notes: 1.This
    is to fit in with Feelay's register and Log-in scripts you can find in the tutorial section. 2.I
    made this to show the members of my site who is a member and what their ID is. First off, we must
    set up a connection to our MySQL Database. CODE $con =
    mysql_connect("localhost","database_username","database_username_password"); if (!$con)   {
      die('Could not connect: ' . mysql_error());   } What it does: 1.It is starting a PHP
    document. 2.Next it sets....
  4. Yahoo! Search Boss
    (5)
    Last wednesday (2008-07-09) Yahoo! Search launched a new service called Yahoo! Search BOSS (Build
    your Own Search Service) which is a web services platform that allows developers and companies to
    create and launch web-scale search products by utilizing the same infrastructure and technology that
    powers Yahoo! Search . Some capabilities of the new Yahoo! Search BOSS service are: Ability to
    re-rank and blend results Unlimited queries Total flexibility on presentation This service is
    based on Python and is available to everybody, to get started and Build your Ow....
  5. Search Engine Keyword Position
    (0)
    So many keywords, so little time -trying to keep track of your site's ranking for every phrase
    can get pretty hectic. That's even more true if you intend to keep tabs on multiple search
    engines. Luckily, the Search Engine Keyword Position tool can help. The Search Engine Keyword
    Position tool is very easy and simple, you only need to enter your site's address and a key
    word or phrase, and it will determine where you stand with Google , Yahoo , and MSN . Best
    regards,....
  6. Get Paid To Search Yahoo!
    New way for you to make money online (10)
    Hi buddies, Is this a good news for you? I've got paid for the first month from this site. Here
    is how you can earn: After you sign up, they ask you to set their page as homepage and install a
    search box.Everyday, when you search once, you will earn up to 3p. How much you can earn depends on
    where you live. I earned 1.5p per search. So, if you search 40 times per day, how much you will earn
    a month? It's very easy, right? In addition, when you refer friends, you will earn more. They
    offer 4 referral levels: 50%, 10%, 5% and 2.5%. If you are interested, sign up a....
  7. New Games.
    Looking for a list of Brand New Games. (0)
    I have just recently stumbaled upon asroempiers just as it was lunching a new server, i thought this
    was great untill my newbiness got the better of me and it soon became very hard work. I was
    woundering if there was any games that have just been lunched or are being alpha testing so that i
    would be in the same boat as everyone.....
  8. Spider Simulator Tool
    See your content the way the search engines do (0)
    The Spider Simulator tool will help you to see your content the way the search engines do! Spiders
    don't operate like normal users, and yet you've got to take their perspective into account.
    Just enter the URL in which you're interested, and the Spider Simulator tool will return
    "spidered" page titles, text, meta descriptions, meta keywords, internal links, and external links.
    Use this information to your advantage and gain new insight into how the search engines work.
    QUOTE A lot of content and links displayed on a web page may not actually be vis....
  9. List Of Free Mmos
    (1)
    I thought I'd make a list of a few of the free MMOs I'm aware of. I know there are more but
    I can't think of any specifics at the moment, so I will add to the listing later. Fly For Fun
    is a 3D cartoony MMO, it seems to be fairly successful. I don't know a whole lot about it but
    there's some general info on Wikipedia Fury is a 3D entirely PvP-centric MMO that was
    released as a retail game, but due to some unpopular changes made to the game it lost alot of its
    fan-base. It was extremely successful during beta and its initial stages, but no lo....
  10. Some Usefull Linux Basic Commands And Utilities. Please Add To This List If You Know One.
    (0)
    Let me give some usefull linux commands and utilities. Please add to this list if you know.
    Work with tar files. To make tar archive use $ tar -cvf filename.tar filename
    To extract tar archive use $ tar -xvf filename.tar To extract tar archive
    with gz use $ tar -xzvf filename.tar.gz Connect to remote system through ssh
    $ ssh name@ip followed by passwd e.g. ssh project@172.16.0.14 passwd: List the
    file in current directory $ ls -l list the running process ....
  11. Url Rewriting Tool
    Useful tool for achieving Search Engine Success (0)
    I receive the last email from the Jayde Listing Notes list some days ago and with it comes an
    excelent SEO tool called URL Rewriting Tool which i think is very useful and i want to share with
    everybody. This useful tool allows you to convert your dynamic URLs into static looking html URLs,
    it is extremely easy to use, is than simple than entering a dynamic URL into a text box and press a
    submit button, once you do it the URL Rewriting Tool returns two type of results: Single Page URL
    Directory Type URL For each type of result the URL Rewriting Tool will generat....
  12. Live Search Webmaster Center
    (1)
    I find that it is very useful in many ways. My site is now included in the listings and if you type
    the name of m,y site it's the first link. I've used the yahoo webmaster tools (site
    explorer), google webmaster tools and Live search webmaster tools. I think that the Live search one
    is better. Yahoo is useless and google is ok but hard to get into listings. This is only my opinion.
    What do you think of Live Search webmaster central?....
  13. Do Google Search Better Than Yahoo?
    This is a question for you all google users!! (15)
    Do you think google search is better than yahoo?? Are they have similar search?? Well for me google
    search is more effective than yahoo search engine.....
  14. Google Restricts The Search Results
    (10)
    I usually hunt for information by searching for the information on various topic of my interest. I
    usually use Google and Live for searching and occassionally Yahoo and AskJeeves. The strange thing
    I found in Google is that I dosent allow me to view the search result beyond 1000 reaults. I dont
    face this in other browsers. I got the following message when I went further beyond the 50th result
    page, CODE Sorry, Google does not serve more than 1000 results for any query. (You asked for
    results starting from 980.) I knew that google had this restriction on the t....
  15. Google- Changing The Search Preferences!
    (3)
    If you want the google site to block more sites, then you will need to go onto the google site. Then
    go onto preferences. There you can change alot .For example the language it should search for only,
    or if the result window should be seperate, or how many results should be displayed per site. This
    window to change preferences is very useful! Have fun!....
  16. List Of Free Applications
    (8)
    I'm posting a small list of FREE applications here! ( Is copied from my own forum
    /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> ) (You can
    reply to the post if you need to add some more stuffs to the list ) 3D Graphics: Anim8or -
    http://www.anim8or.com/ Blender - http://www.blender3d.org/ gmax -
    http://www.discreet.com/products/gmax/ Maya Personal Learning Ed. -
    http://www.alias.com/eng/products-s...ple/index.shtml Now3D -
    http://digilander.libero.it/giulios/Eng/homepage.htm SOFTIMAGE|XSI EXP - ....
  17. Windows Live Search
    The future of MSN Search (14)
    I have used Windows Live Search for that contest that MSN hosted a few months ago (can't
    remember if it was a year). It works if you have the BETTER keywords to search with, otherwise it
    doesn't work that well. It is my preferred ALTERNATE search engine (my favourite is
    Google+Yahoo). MSN Search doesn't work that well. It doesn't come up with that many results
    and Yahoo! generally searches better than it. I don't use MSN Search anymore. After all, Windows
    Live Search will replace it! /smile.gif" style="vertical-align:middle" emoid=":)" border="0" al....
  18. Orkut.com Auto Scrapper - Scrap Ur Friend List In One Go
    For the Orkutters (13)
    hi fellas, as most orkutters know that u cant scrap ur whole friend list in one go. i cant keep
    my friends up to date with myself (since they dun know whats a blog) so i have to scrap them all
    individually. having 100+ friends i decided to use an autoscrapper and came across Scrapboy.
    bugged up with Scrapboy's bulky interface and huge download size, i decided to code my own auto
    scrapper for Orkut.com If you don't know what it is, hit the following link
    http://www.captainron.uni.cc/orkutter (click download to download) its around 570Kb in download
    and ....
  19. A List Abosulutely Free MMORPGs
    Thats right FREE! (6)
    Here is a list of MMORPG i have collected, they are all absolutely free! note: sry theres no
    Pictures or direct links (to find the website, just search it up on google) The pricing of these
    game may change (as in become frome free to pay to play) ___________ Gunbound Rakion Runescape
    Pristontale (free til lvl 40) Auditon Online Dance Battle (online version of DDR) Holy Beast
    Online Dream Of Mirror Online Guild Wars (not free, you need to buy the game, but no monthly
    fees) Lineage 2 (the retail version is not free, although there are very advance private s....
  20. Google Suggest (beta)
    New Google's Search Auto-Complete Feature... (12)
    Lately, Google has been producing so many useful tools and utilities, not to mention its amazing
    search capabilities. Many of those new tools pass through a long phase of BETA testing to ensure
    that they reached their optimum usefulness and are ready to be put to use by the masses. So now,
    Google has released a BETA version of one more tool, called Google Suggest!... You know how many
    of today's Web browsers have an auto-complete feature, where you type a few letters and that
    application tries to recognize the phrase you're typing and complete it for you? W....
  21. Singingfish
    Music Search... (3)
    If you want the best music search on the net, go to www.singingfish.com . Wow. /smile.gif"
    style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I find all my music through
    it. And now AOL owns it. /tongue.gif" style="vertical-align:middle" emoid=":P" border="0"
    alt="tongue.gif" /> Help yall? -Josh....
  22. List Of Free MMORPGs
    (18)
    I wrote this a while ago With the help of some people If you have any questions or anything Message
    Me! 5 Masters Online strategy game. AdventureQuest AdventureQuest is a free lunch break sized
    RPG that you can play daily using your web browser. We are adding new things every week! Join us in
    shaping the direction of this campy yet addictive role playing game. Alien Assult Traders Alien
    Assault Traders is a multiplayer turn based space trading game. Where players use turns that are
    accumilated over time to trade good and build empires and take over the universe....
  23. Blingo Search Engine
    A SE that gives away random prizes (3)
    A friend told me about a search engine that brings back Google results, however the owners of the
    Engine have the site set up to give random prizes away depending on what "turn" you are to search.
    They pick a bunch of random winning times, and if you search at the right time, you win a gift
    certificate, or other prize. The theory is, that if you DO happen to hit your search on one of
    these "winning times", instead of being redirected to your search results, you are notified that you
    have won, and they send you your gift somehow... I have never won on this thing and I ....
  24. How Search Engines Operate
    answering your questions (6)
    When I took a computer class, they said that search engines use "spiders" to register your site and
    have it show up when you type a keyword. I'm pretty sure this is true, coming from a professor
    with a degree in Computer Science but I'm wondering, what exactly are what they call spiders?
    What are spiders hosted on and all the technical questions. If you know anything technically about
    specifically how search engines like Google functions, this is the thread for you. So, please -
    share what you know. Your honest patronage is greatly appreciated and will be listene....
  25. List Of Funny Tech Signatures
    Here are the one's I have encountered. (7)
    Hey guys, I been lurking around checking out some forums, Unix/Linux pages, and I found some funny
    signatures that I want to share with you guys. Videogame forums are also good places to find such
    signatures. If you have any others you want to add up that are good ones feel free to do so. Take
    in mind that the following signatures are Tech-related, cause I like tech stuff. Signatures: 1) One
    picture is worth 128K words. 2)The UNIX philosophy basically involves giving you enough rope to
    hang yourself. And then a couple of feet more, just to be sure. 3)The difference ....
  26. Mud List
    Peoples favourite MUDs (11)
    I am currently an Immortal (member of staff) on a new MUD, IahMUD. It is not entirely open to the
    public yet, but hopefully it will be soon. We have a number of good coders and builders so it should
    turn out well. If you are interested you should check out the website: www.iahmel.com A great MUD in
    the making.......
  27. Array Sorting
    Does anyone hava a decent JAVA method (21)
    does anyone have a decent JAVA method that will sort an array from smallest-to highest?
    /mellow.gif" style="vertical-align:middle" emoid=":mellow:" border="0" alt="mellow.gif" /> The one
    i'm trying to write doesn't seem to work... or if you could look at mine below, and tell me
    what i did wrong, that'd be nice to.(if it reallllyyyyyyyyy sucks, please dont laugh to loud
    /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> ) This should
    take an array and then calculate how many of a number is in it, add it to the first slots....
  28. List Of Free Mmorpg..
    (24)
    Do enjoy this list /wink.gif' border='0' style='vertical-align:middle' alt='wink.gif' /> (ALl
    these are games i have played b4 and are still free): www.runescape.com This game is so called "3D"
    .. although i looks like it, i don't feel it is 3D /tongue.gif' border='0'
    style='vertical-align:middle' alt='tongue.gif' /> .. this is a quite a fun game actually. I played
    this game actually 2 years back. You can do lots of things like mining, blacksmithing, fishing and
    there are many quests in this game. Very typical MMORPG /smile.gif' border='0' style='vertical-ali....
  29. Add A Search Box To My Web Site
    how to? (10)
    I don't know If this topic I should post here, but I'll try! I have a web site and i really
    need to add to my website a feature like searching on the site!I need a simple text boxt and a
    button, that will search the site content! are there already done version of such programs? pleasee
    help! thanks you!....
  30. You can Play now in Linux
    These is a list of the games. (26)
    You can Play a greates gameg in linus as: Unreal Tournament Quake 3 Wolfenstein Enemy teritory Medal
    of Honor And Emule Nintendo 64 and Play Station games. He have your property games as: Tux Raser
    Tux Cart Flith of the amazon queen Beneath a Steel Sky and most more.....

    1. Looking for sorting, list, algorithem, search






*SIMILAR VIDEOS*
Searching Video's for sorting, list, algorithem, search
Similar
Download From Ftpz, Using Ftp Search Sitez - Download From Ftpz, Using Ftp Search Sitez
Homepages Friends - Get PAID to search!
How To: Display A Members/user List. - With PHP, Mysql, and HTML.
Yahoo! Search Boss
Search Engine Keyword Position
Get Paid To Search Yahoo! - New way for you to make money online
New Games. - Looking for a list of Brand New Games.
Spider Simulator Tool - See your content the way the search engines do
List Of Free Mmos
Some Usefull Linux Basic Commands And Utilities. Please Add To This List If You Know One.
Url Rewriting Tool - Useful tool for achieving Search Engine Success
Live Search Webmaster Center
Do Google Search Better Than Yahoo? - This is a question for you all google users!!
Google Restricts The Search Results
Google- Changing The Search Preferences!
List Of Free Applications
Windows Live Search - The future of MSN Search
Orkut.com Auto Scrapper - Scrap Ur Friend List In One Go - For the Orkutters
A List Abosulutely Free MMORPGs - Thats right FREE!
Google Suggest (beta) - New Google's Search Auto-Complete Feature...
Singingfish - Music Search...
List Of Free MMORPGs
Blingo Search Engine - A SE that gives away random prizes
How Search Engines Operate - answering your questions
List Of Funny Tech Signatures - Here are the one's I have encountered.
Mud List - Peoples favourite MUDs
Array Sorting - Does anyone hava a decent JAVA method
List Of Free Mmorpg..
Add A Search Box To My Web Site - how to?
You can Play now in Linux - These is a list of the games.
advertisement




Sorting A List - Algorithem Search