Patterns & Code: Main

Placeholder

Published: 2013-08-18 Tags: Stubs, Ignore This

quicksort illustration

This is just a site placeholder while the main site is developed.

Next in our Basic Algorithms series, we cover the QuicksortAlgorithm.

Quicksort, or partition-exchange sort, is a sorting algorithm developed by Tony Hoare that, on average, makes O(n log n) comparisons to sort n items.

In the worst case, it makes O(n2) comparisons, though this behavior is rare. Quicksort is often faster in practice than other O(n log n) algorithms.

Additionally, quicksort's sequential and localized memory references work well with a cache. Quicksort is a comparison sort and, in efficient implementations, is not a stable sort. Quicksort can be implemented with an in-place partitioning algorithm, so the entire sort can be done with only O(log n) additional space used by the stack during the recursion.

Article Title Here

Published: 2013-08-18 Tags: Stubs, Ignore This

Directed acyclic graph

Curabitur at orci ipsum. Etiam ut orci erat, in vulputate mauris. Ut id ipsum quam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam ut pulvinar odio. Phasellus tempor lacus in felis porta pulvinar. Nulla sed felis id magna aliquet tempor. Nulla volutpat nulla a dolor suscipit sagittis. Pellentesque vitae dui eu neque luctus accumsan. Nunc pulvinar lectus nulla, sit amet vulputate orci. Quisque malesuada, urna a feugiat consequat, eros turpis viverra augue, eget ornare nunc erat sit amet nunc. Duis rhoncus elit nec justo adipiscing nec auctor eros consectetur.


  @requires_authorization
  def somefunc(param1='', param2=0):
      r'''A docstring'''
      if param1 > param2: # interesting
          print 'Gre\'ater'
      return (param2 - param1 + 1) or None

  class SomeClass:
      pass

Figure #1 Python Snippet.

Article Titles Here.

Published: 2013-08-18 Tags: Stubs, Ignore This

Directed acyclic graph

Sed faucibus euismod pellentesque. Morbi sollicitudin eros ut tellus mattis a cursus sem consequat. Praesent a facilisis mauris. Aliquam in diam vel lorem suscipit volutpat sit amet tincidunt lacus. Sed ligula eros, blandit eget condimentum a, pellentesque et velit. In fringilla hendrerit nulla in laoreet. Nulla a ante nulla, sed iaculis ipsum. Aliquam ornare urna nec est condimentum porta. Vivamus sit amet dolor in neque pulvinar pulvinar.


 -module(echo).
 -export([start/1,server/1,handle_messages/1]).


 start(Port) ->
     spawn(?MODULE,server,[Port]).


 server(Port) ->
     {ok, Socket} = gen_tcp:listen(Port,[{packet,line}]),
     listen(Socket).


 listen(Socket) ->
     {ok, Active_socket} = gen_tcp:accept(Socket),
     Handler = spawn(?MODULE,handle_messages,[Active_socket]),
     ok = gen_tcp:controlling_process(Active_socket, Handler),
     listen(Socket).


 handle_messages(Socket) ->
     receive
         {tcp,error,closed} ->
             done;
         {tcp,Socket,Data} ->
             gen_tcp:send(Socket,Data),
             echo:handle_messages(Socket);
         _Other ->
             unexpected
     end.
Figure #2: Code Example in Erlang

Go to Top