§
    �zIfÃ  ã                   ó^   — d Z d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Ze	d	k    r e¦   «          d
S d
S )z·
This module provides a variety of list sorting algorithms, to
illustrate the many different algorithms (recipes) for solving a
problem, and how to analyze algorithms experimentally.
c                 óø   — d}t          t          | ¦  «        dz
  ¦  «        D ]W}|}t          |dz   t          | ¦  «        ¦  «        D ]}| |         | |         k     r|}|dz  }Œ| |         | |         c| |<   | |<   ŒX|S )zÔ
    Selection Sort: scan the list to find its smallest element, then
    swap it with the first element.  The remainder of the list is one
    element smaller; apply the same method to this list, and so on.
    é    é   ©ÚrangeÚlen)ÚaÚcountÚiÚminÚjs        úB/var/www/piapp/venv/lib/python3.11/site-packages/nltk/misc/sort.pyÚ	selectionr      s•   € ð €Eå•3�q‘6”6˜A‘:ÑÔð 	$ð 	$ˆØˆå�q˜1‘u�c !™fœfÑ%Ô%ð 	ð 	ˆAØ�Œt�a˜”fŠ}ˆ}Ø�à�Q‰JˆEˆEà˜”t˜Q˜sœVˆˆˆ#‰��!‘�à€Ló    c                 ó  — d}t          t          | ¦  «        dz
  ¦  «        D ]^}t          t          | ¦  «        |z
  dz
  ¦  «        D ]9}| |dz            | |         k     r"| |dz            | |         c| |<   | |dz   <   |dz  }Œ:Œ_|S )aG  
    Bubble Sort: compare adjacent elements of the list left-to-right,
    and swap them if they are out of order.  After one pass through
    the list swapping adjacent items, the largest item will be in
    the rightmost position.  The remainder is one element smaller;
    apply the same method to this list, and so on.
    r   r   r   )r   r	   r
   r   s       r   Úbubbler   0   s�   € ð €EÝ•3�q‘6”6˜A‘:ÑÔð ð ˆÝ•s˜1‘v”v ‘z A‘~Ñ&Ô&ð 	ð 	ˆAØ��Q‘Œx˜!˜Aœ$ŠˆØ!" 1 q¡5¤¨1¨Q¬4���!‘�a˜˜A™‘hØ˜‘
�øð	ð €Lr   c                 ó¾  — d}dx}}g }|t          | ¦  «        k     r‘|t          |¦  «        k     r~|dz  }| |         ||         k    r!|                     | |         ¦  «         |dz  }n |                     ||         ¦  «         |dz  }|t          | ¦  «        k     r|t          |¦  «        k     °~|t          | ¦  «        k    r|||d …         z  }n|| |d …         z  }||fS ©Nr   r   )r   Úappend)ÚbÚcr	   r
   r   r   s         r   Ú_merge_listsr   F   sã   € Ø€EØ€I€AˆØ
€AØ
�c�!‰fŒfŠ*ˆ*˜�S ™VœVš˜Ø�‰
ˆØˆQŒ4�1�Q”4Š<ˆ<Ø�HŠH�Q�q”T‰NŒNˆNØ�‰FˆAˆAà�HŠH�Q�q”T‰NŒNˆNØ�‰FˆAð �c�!‰fŒfŠ*ˆ*˜�S ™VœVš˜ð 	�C�‰FŒF‚{€{Ø	ˆQˆqˆrˆrŒU‰
ˆˆà	ˆQˆqˆrˆrŒU‰
ˆØˆeˆ8€Or   c                 óü   — d}t          | ¦  «        dk    rft          | ¦  «        dz  }| d|…         }| |d…         }t          |¦  «        }t          |¦  «        }t          ||¦  «        \  }}|| dd…<   ||z   |z   }|S )ze
    Merge Sort: split the list in half, and sort each half, then
    combine the sorted halves.
    r   r   é   N)r   Úmerger   )	r   r	   Úmidpointr   r   Úcount_bÚcount_cÚresultÚcount_as	            r   r   r   Y   s‹   € ð
 €EÝ
ˆ1�v„v�‚z€zÝ�q‘6”6˜Q‘;ˆØˆiˆxˆiŒLˆØˆhˆiˆiŒLˆÝ˜‘(”(ˆÝ˜‘(”(ˆÝ& q¨!Ñ,Ô,‰ˆ�Øˆˆ!ˆ!ˆ!‰Ø˜'Ñ! GÑ+ˆØ€Lr   c                 óV  — | |         }|}|dz   }d}	 ||k     r|dz  }| |         |k    rn||k     °||k    r|dz  }||k     s| |         |k    rn||k    °| |         | |         c| |<   | |<   |dz  }||k    rnŒf| |         | |         c| |<   | |<   | |         | |         c| |<   | |<   ||fS )Nr   r   © )r   ÚlÚrÚpr
   r   r	   s          r   Ú
_partitionr%   p   sÿ   € Ø	ˆ!Œ€AØ	€AØ	ˆA‰€AØ€EðØ�!ŠeˆeØ�‰FˆAØ�Œt�qŠyˆyØð �!Šeˆeð �!ŠeˆeØ�‰FˆAØ�1Šuˆu˜˜!œ š	˜	Øð �!Šeˆeð �q”T˜1˜Qœ4ˆ
ˆˆ!‰ˆa�‰dØ�‰
ˆØ�Š6ˆ6Øðð �1”�q˜”t€J€A€a�Dˆ!ˆA‰$Ø�1”�q˜”t€J€A€a�Dˆ!ˆA‰$Øˆeˆ8€Or   c                 óš   — d}||k     rBt          | ||¦  «        \  }}|t          | ||dz
  ¦  «        z  }|t          | |dz   |¦  «        z  }|S r   )r%   Ú_quick)r   r"   r#   r	   Úss        r   r'   r'   ‡   s^   € Ø€EØˆ1‚u€uÝ˜a  AÑ&Ô&‰ˆˆ5Ø•˜˜1˜a !™eÑ$Ô$Ñ$ˆØ•˜˜1˜q™5 !Ñ$Ô$Ñ$ˆØ€Lr   c                 óD   — t          | dt          | ¦  «        dz
  ¦  «        S r   )r'   r   )r   s    r   Úquickr*   �   s   € Ý�!�Q�˜A™œ ™
Ñ#Ô#Ð#r   c            	      óR  — ddl m}  dD ]�}t          t          |¦  «        ¦  «        } | |¦  «         t	          |¦  «        } | |¦  «         t          |¦  «        } | |¦  «         t          |¦  «        } | |¦  «         t          |¦  «        }t          d|||||fz  ¦  «         Œžd S )Nr   )Úshuffle)é
   é   é2   éd   éÈ   iô  iè  z=size=%5d:  selection=%8d,  bubble=%8d,  merge=%6d,  quick=%6d)	Úrandomr,   Úlistr   r   r   r   r*   Úprint)r,   Úsizer   Úcount_selectionÚcount_bubbleÚcount_mergeÚcount_quicks          r   Údemor:   ™   sÐ   € ØÐÐÐÐÐà1ð 
ð 
ˆÝ•�t‘”ÑÔˆð 	ˆ�‰
Œ
ˆ
Ý# A™,œ,ˆØˆ�‰
Œ
ˆ
Ý˜a‘y”yˆØˆ�‰
Œ
ˆ
Ý˜A‘h”hˆØˆ�‰
Œ
ˆ
Ý˜A‘h”hˆåØOØ�_ l°KÀÐMñNñ	
ô 	
ð 	
ð 	
ð
ð 
r   Ú__main__N)
Ú__doc__r   r   r   r   r%   r'   r*   r:   Ú__name__r!   r   r   ú<module>r>      s«   ððð ðð ð ð6ð ð ð,ð ð ð&ð ð ð.ð ð ð.ð ð ð$ð $ð $ð
ð 
ð 
ð, ˆzÒÐØ€D�F„F€F€F€Fð Ðr   