Comparison Based Identification of Sorting Algorithm for a Problem 1Satwinder Kaur, 2Harpal Singh & 3Prabhdeep Singh P.I.T

Total Page:16

File Type:pdf, Size:1020Kb

Comparison Based Identification of Sorting Algorithm for a Problem 1Satwinder Kaur, 2Harpal Singh & 3Prabhdeep Singh P.I.T International Journal of Advanced Computational Engineering and Networking, ISSN (p): 2320-2106, Volume – 1, Issue – 1, Mar-2013 COMPARISON BASED IDENTIFICATION OF SORTING ALGORITHM FOR A PROBLEM 1SATWINDER KAUR, 2HARPAL SINGH & 3PRABHDEEP SINGH P.I.T. Kapurthala,India Email: [email protected], [email protected],[email protected] Abstract—Sorting is essential in today’ era of computing as for various operations and arises need for ordered data. Organized data is easy to access and operate upon. There are various sorting algorithms and each has its own merits. For a particular problem, is difficult to find an algorithm which has minimum time complexity (execution time) and minimum space complexity (memory used). So, time-space tradeoff plays an important role to reduce the computational time at the cost of increased memory use. A sorting algorithm cannot be used for every type of problem so depending upon the user inputs and requirements, optimal algorithm from the multiple sorting algorithms can be chosen as these are problem specific. This work analyzes the different sorting algorithms at the implementation level and provides a comparative study which will help in choosing the optimal sorting algorithm for a specific problem. Keywords: Sorting, Algorithm Analysis, Complexity, Time-Space Tradeoff, Optimal Sorting Algorithm. I. INTRODUCTION II.FUNDAMENTAL SORTING ALGORITHMS Sorting is one of the most important operations in A. Selection Sort: - Selection sort has the basic computer programming. Various sorting algorithms principle according to which it find out the smallest are available today, but not a single algorithm can be element in array with each pass and placed it in its stated best for multiple problems. Different type of proper place until the array being sorted completely problem has to be dealt with different algorithm [6]. which is optimal for it. A sorting algorithm may not 1. Algorithm: Selection sort have minimum time complexity and minimum space Description: - A is the array of n element to be sorted complexity for a problem, so we have the concept of .Min denote the smallest element.LOC is a location time-space tradeoff. Time-space tradeoff implies that variable we can minimize the time needed for the execution of STEP: 1 Iterate through Array of N element. an algorithm at the cost of memory space required for Repeat step 2 to 5 When K=1, 2, it. 3………………..N-1 STEP: 2 Set Min= A [K], LOC=K A. Calculating the Complexity of an Algorithm: We STEP: 3 Repeat for T=K+1, K+1…N need to find out the complexity of the algorithm to STEP: 4 IF Min>A [T] Update Min and LOC see how much efficient it is. We have defined the STEP: 5 Min=A [T], LOC=T complexities of each of the sorting algorithm using STEP: 6 Swaps (A [K], A [LOC]) Big Oh notation because it gives the longest running STEP: 7 EXIT. time for any input of size n and an upper bound on the running time for any input. Thus, it guarantees 2. Example:- that the algorithm will never take longer than this. A [25, 20, 10, 15, 2, 0, 3, 7] B. Optimum Sorting Algorithm: From among the Pass A[ A[ A[ A[ A[ A[ A[ A[ different sorting algorithms, some are best for one 1] 2] 3] 4] 5] 6] 7] 8] type of problems and others are best for other type of K=1,LO 25 20 10 15 2 0 3 7 problems. It is difficult to say which sorting C=6 algorithm is optimal. However, we have compared K=2,LO 0 20 10 15 2 25 3 7 the different algorithms to describe the type of C=5 problem they are best for. This will help in choosing K=3,LO 0 2 10 15 20 25 3 7 C=7 the optimal sorting algorithm according to user K=4,LO 0 2 3 15 20 25 10 7 requirements. C=8 K=5,LO 0 2 3 7 20 25 10 15 C. Comparison of different sorting algorithms: C=7 Different sorting algorithms are compared by K=6,LO 0 2 3 7 10 25 20 15 analyzing the time complexity and space complexity C=8 using n input data. For better understanding and easy Sorted 0 2 3 7 10 15 20 25 comparison we have used the same example for So we see here that the selection sort has the basic sorting, using different algorithms. Here we discuss principle according to which it find out the smallest the advanced sorting techniques in detail with element in array with each pass and placed it in its algorithms and examples.. proper place until the array being sorted completely .It is very slow, and has its time complexity O (n2) for Comparison Based Identification Of Sorting Algorithm For A Problem 67 International Journal of Advanced Computational Engineering and Networking, ISSN (p): 2320-2106, Volume – 1, Issue – 1, Mar-2013 both worst-case and best-case due to large number of 1. A [25]>A [20]…………………A [N-1] comparison it performed. In some cases it performs SWAP (PTR, PTR+1), Here in the 1st pass we need to better than bubble sort as fewer swaps are required. make 8- 1=7 comparison to fix 25 for its proper place then we get following result: B. Insertion Sort: Insertion sort is a simple sorting 20 10 15 2 0 3 7 algorithm that is relatively efficient for small lists and 25 it perform sorting by taking element from list one by 2. Now 25 is fixed to proper place from here we need one and insert them in their proper position into new make 7- 1=6 comparison for 2nd pass taking 20 as ordered list. PTR then we get following result by comparing 20 1. Algorithm: Insertion sort with each element. Description: - A is the Array of n element to be 10 15 2 0 3 7 20 sorted. Temp is the variable that keeps the record of 25 element. PTR is the Pointer. 3. From here 25 and 20 are fixed now we need to STEP: 1 Initialize the element make 6-1=5 comparison to for 3rd pass. As 10<15 Set A [0] = - ∞ No swapping so we take 15 as PTR initially and after STEP: 2 Repeat Step 3 to 5 when k=2, 3 ….N 3rd pass we got result as follow. STEP: 3 Set Temp= A[k] and PTR=K-1. 10 2 0 3 7 15 20 25 STEP: 4 Repeat While Temp < A [PTR]. 4. In the 4th pass 15, 20, 25 are positioned so we make a. Set A[PTR+1}=A[PTR] 5-1=4 comparison and we get following result. b. Set PTR=PTR-1 2 0 3 7 10 15 STEP: 5 Set A [PTR+1] = Temp. 20 25 STEP: 6 EXIT. 5. In the 5th pass we need make 4-1= 3 comparison, As 10, 15, 20, 25 are positioned, After this pass 2. Example:- we get following result. A :- 25 20 10 15 2 0 3 7 0 2 3 7 10 15 20 25 Data -∞ 25 20 10 15 2 0 3 7 Here we get sorted list. Bubble sort is approaches to 1st pass -∞ 20 25 10 15 2 0 3 7 the problem by making multiple passes, through the 2nd pass -∞ 10 20 25 15 2 0 3 7 algorithm.it performed sorting by comparing two consecutive values and swap them if they are out of 3rd pass -∞ 10 15 20 25 2 0 3 7 order. 4th pass -∞ 2 10 15 20 25 0 3 7 2 Bubble sort has time complexity O(n ) like selection 5th pass -∞ 0 2 10 15 20 25 3 7 and insertion sort but it is much slower than selection 6th pass -∞ 0 2 3 10 15 20 25 7 sort and insertion sort due to large number of comparison it performed [2]. 7th pass -∞ 0 2 3 7 10 15 20 2 5 D. Quick sort: - Quick sort is a divide and conquer Sorted -∞ 0 2 3 7 10 15 20 2 list 5 algorithm with two phases, a partition phase and a Insertion sort is a simple sorting algorithm that is sort phase. relatively efficient for small lists. It has time 1. Algorithm: Quick Sort complexity O (n2) like bubble sort and selection sort Description: - A is the Array of N element. P, R is but I will perform sorting faster than Bubble sort and the variable used for comparison Selection sort due to fewer comparison it QUICK_SORT (A, P, R) performed[1]. STEP: 1 P>R THEN STEP: 2 Q= PARTITION (A, P, R) C. Bubble Sort: - Bubble work by comparing each STEP: 3 QUICKSORT (A, P, Q-1) item with next item to it and swap them if required.it STEP: 4 QUICKSORT (A, Q+1, R) is oldest and simplest sorting algorithm in use. STEP: 5 EXIT. 1. Algorithm:-Bubble sort Here is the sub-algorithm for partition Description: - A is the Array of N element.PTR PARTITION (A, P, R) denotes the pointer. STEP: 1 X=A [R] STEP: 1 Repeat step 2and 3 for K=1 to N-1 STEP: 2 I =P-1 STEP: 2 Set PTR=1 // initializing PTR STEP: 3 FOR J=P TO R-1 STEP: 3 Repeat When PTR<=N-K. STEP: 4 DO IF A [I] <=X a. IF A [PTR]>A [PTR+1] THEN STEP: 5 THEN I=I+1 SWAP (A [PTR], A [PTR+1]) STEP: 6 SWAP (A [I], A [J]) b.
Recommended publications
  • Sorting Algorithms Correcness, Complexity and Other Properties
    Sorting Algorithms Correcness, Complexity and other Properties Joshua Knowles School of Computer Science The University of Manchester COMP26912 - Week 9 LF17, April 1 2011 The Importance of Sorting Important because • Fundamental to organizing data • Principles of good algorithm design (correctness and efficiency) can be appreciated in the methods developed for this simple (to state) task. Sorting Algorithms 2 LF17, April 1 2011 Every algorithms book has a large section on Sorting... Sorting Algorithms 3 LF17, April 1 2011 ...On the Other Hand • Progress in computer speed and memory has reduced the practical importance of (further developments in) sorting • quicksort() is often an adequate answer in many applications However, you still need to know your way (a little) around the the key sorting algorithms Sorting Algorithms 4 LF17, April 1 2011 Overview What you should learn about sorting (what is examinable) • Definition of sorting. Correctness of sorting algorithms • How the following work: Bubble sort, Insertion sort, Selection sort, Quicksort, Merge sort, Heap sort, Bucket sort, Radix sort • Main properties of those algorithms • How to reason about complexity — worst case and special cases Covered in: the course book; labs; this lecture; wikipedia; wider reading Sorting Algorithms 5 LF17, April 1 2011 Relevant Pages of the Course Book Selection sort: 97 (very short description only) Insertion sort: 98 (very short) Merge sort: 219–224 (pages on multi-way merge not needed) Heap sort: 100–106 and 107–111 Quicksort: 234–238 Bucket sort: 241–242 Radix sort: 242–243 Lower bound on sorting 239–240 Practical issues, 244 Some of the exercise on pp.
    [Show full text]
  • An Evolutionary Approach for Sorting Algorithms
    ORIENTAL JOURNAL OF ISSN: 0974-6471 COMPUTER SCIENCE & TECHNOLOGY December 2014, An International Open Free Access, Peer Reviewed Research Journal Vol. 7, No. (3): Published By: Oriental Scientific Publishing Co., India. Pgs. 369-376 www.computerscijournal.org Root to Fruit (2): An Evolutionary Approach for Sorting Algorithms PRAMOD KADAM AND Sachin KADAM BVDU, IMED, Pune, India. (Received: November 10, 2014; Accepted: December 20, 2014) ABstract This paper continues the earlier thought of evolutionary study of sorting problem and sorting algorithms (Root to Fruit (1): An Evolutionary Study of Sorting Problem) [1]and concluded with the chronological list of early pioneers of sorting problem or algorithms. Latter in the study graphical method has been used to present an evolution of sorting problem and sorting algorithm on the time line. Key words: Evolutionary study of sorting, History of sorting Early Sorting algorithms, list of inventors for sorting. IntroDUCTION name and their contribution may skipped from the study. Therefore readers have all the rights to In spite of plentiful literature and research extent this study with the valid proofs. Ultimately in sorting algorithmic domain there is mess our objective behind this research is very much found in documentation as far as credential clear, that to provide strength to the evolutionary concern2. Perhaps this problem found due to lack study of sorting algorithms and shift towards a good of coordination and unavailability of common knowledge base to preserve work of our forebear platform or knowledge base in the same domain. for upcoming generation. Otherwise coming Evolutionary study of sorting algorithm or sorting generation could receive hardly information about problem is foundation of futuristic knowledge sorting problems and syllabi may restrict with some base for sorting problem domain1.
    [Show full text]
  • CS 106B Lecture 11: Sorting Friday, October 21, 2016
    CS 106B Lecture 11: Sorting Friday, October 21, 2016 Programming Abstractions Fall 2016 Stanford University Computer Science Department Lecturer: Chris Gregg reading: Programming Abstractions in C++, Section 10.2 Today's Topics •Logistics •We will have a midterm review, TBA •Midterm materials (old exams, study guides, etc.) will come out next week. •Throwing a string error •Recursive != exponential computational complexity •Sorting •Insertion Sort •Selection Sort •Merge Sort •Quicksort •Other sorts you might want to look at: •Radix Sort •Shell Sort •Tim Sort •Heap Sort (we will cover heaps later in the course) •Bogosort Throwing an Exception • For the Serpinski Triangle option in MetaAcademy assignment says, "If the order passed is negative, your function should throw a string exception." • What does it mean to "throw a string exception?" • An "exception" is your program's way of pulling the fire alarm — something drastic happened, and your program does not like it. In fact, if an exception is not "handled" by the rest of your program, it crashes! It is not a particularly graceful way to handle bad input from the user. • If you were going to use your Serpinski function in a program you wrote, you would want to check the input before calling the function — in other words, make sure your program never creates a situation where a function needs to throw an exception. Throwing an Exception • To throw an exception: throw("Illegal level: Serpinski level must be non-negative."); • This will crash the program. • You can "catch" exceptions that have been thrown by other functions, but that is beyond our scope — see here for details: https://www.tutorialspoint.com/ cplusplus/cpp_exceptions_handling.htm (that is a creepy hand) Recursion != Exponential Computational Complexity • In the previous lecture, we discussed the recursive fibonacci function: long fibonacci(int n) { • This function happens to have if (n == 0) { return 0; exponential computational complexity } if (n == 1) { because each recursive call has two return 1; } additional recursions.
    [Show full text]
  • Parallel Sorting Algorithms + Topic Overview
    + Design of Parallel Algorithms Parallel Sorting Algorithms + Topic Overview n Issues in Sorting on Parallel Computers n Sorting Networks n Bubble Sort and its Variants n Quicksort n Bucket and Sample Sort n Other Sorting Algorithms + Sorting: Overview n One of the most commonly used and well-studied kernels. n Sorting can be comparison-based or noncomparison-based. n The fundamental operation of comparison-based sorting is compare-exchange. n The lower bound on any comparison-based sort of n numbers is Θ(nlog n) . n We focus here on comparison-based sorting algorithms. + Sorting: Basics What is a parallel sorted sequence? Where are the input and output lists stored? n We assume that the input and output lists are distributed. n The sorted list is partitioned with the property that each partitioned list is sorted and each element in processor Pi's list is less than that in Pj's list if i < j. + Sorting: Parallel Compare Exchange Operation A parallel compare-exchange operation. Processes Pi and Pj send their elements to each other. Process Pi keeps min{ai,aj}, and Pj keeps max{ai, aj}. + Sorting: Basics What is the parallel counterpart to a sequential comparator? n If each processor has one element, the compare exchange operation stores the smaller element at the processor with smaller id. This can be done in ts + tw time. n If we have more than one element per processor, we call this operation a compare split. Assume each of two processors have n/p elements. n After the compare-split operation, the smaller n/p elements are at processor Pi and the larger n/p elements at Pj, where i < j.
    [Show full text]
  • Investigating the Effect of Implementation Languages and Large Problem Sizes on the Tractability and Efficiency of Sorting Algorithms
    International Journal of Engineering Research and Technology. ISSN 0974-3154, Volume 12, Number 2 (2019), pp. 196-203 © International Research Publication House. http://www.irphouse.com Investigating the Effect of Implementation Languages and Large Problem Sizes on the Tractability and Efficiency of Sorting Algorithms Temitayo Matthew Fagbola and Surendra Colin Thakur Department of Information Technology, Durban University of Technology, Durban 4000, South Africa. ORCID: 0000-0001-6631-1002 (Temitayo Fagbola) Abstract [1],[2]. Theoretically, effective sorting of data allows for an efficient and simple searching process to take place. This is Sorting is a data structure operation involving a re-arrangement particularly important as most merge and search algorithms of an unordered set of elements with witnessed real life strictly depend on the correctness and efficiency of sorting applications for load balancing and energy conservation in algorithms [4]. It is important to note that, the rearrangement distributed, grid and cloud computing environments. However, procedure of each sorting algorithm differs and directly impacts the rearrangement procedure often used by sorting algorithms on the execution time and complexity of such algorithm for differs and significantly impacts on their computational varying problem sizes and type emanating from real-world efficiencies and tractability for varying problem sizes. situations [5]. For instance, the operational sorting procedures Currently, which combination of sorting algorithm and of Merge Sort, Quick Sort and Heap Sort follow a divide-and- implementation language is highly tractable and efficient for conquer approach characterized by key comparison, recursion solving large sized-problems remains an open challenge. In this and binary heap’ key reordering requirements, respectively [9].
    [Show full text]
  • Sorting in Linear Time
    Data Structures Sorting in Linear Time 1 Sorting • Internal (external) – All data are held in primary memory during the sorting process. • Comparison Based – Based on pairwise comparisons. – Lower bound on running time is Ω(nlogn). • In Place – Requires very little, O(log n), additional space. • Stable – Preserves the relative ordering of items with equal values. 2 Lower Bounds for Comparison Sorts • Ω(n) to examine all the input. • All sorts seen so far are Ω(n lg n). • We’ll show that Ω(n lg n) is a lower bound for comparison sorts. 3 Lower Bounds for Comparison Sorts • All possible flows of any comparison sort can be modeled by a decision tree. • For example, the decision tree of insertion sort of 3 elements looks like: • There are at least n! leaves, because every permutation appears at least once. 4 Lower Bounds for Comparison Sorts • Theorem: – Any decision tree that sorts n elements has height Ω(n lg n). • Proof: – The number of leaves l ≥ n! – Any binary tree of height h has ≤ 2h leaves. – Hence, n! ≤ l ≤ 2h – Take logs: h ≥ lg(n!) – Use Stirling’s approximation: n! > (n/e)n – We get: 5 Lower Bounds for Comparison Sorts • Lemma: – Any binary tree of height h has ≤ 2h leaves. • Proof: – By induction on h. – Basis: • h = 0. • Tree is just one node, which is a leaf. • 2h = 1. – Inductive step: • Assume true for height = h − 1. • Reduce all leaves and get a tree of height h – 1 • Make the tree full • Then, extend the tree of height h − 1 by adding to each leaf two son leaves.
    [Show full text]
  • Lecture 8.Key
    CSC 391/691: GPU Programming Fall 2015 Parallel Sorting Algorithms Copyright © 2015 Samuel S. Cho Sorting Algorithms Review 2 • Bubble Sort: O(n ) 2 • Insertion Sort: O(n ) • Quick Sort: O(n log n) • Heap Sort: O(n log n) • Merge Sort: O(n log n) • The best we can expect from a sequential sorting algorithm using p processors (if distributed evenly among the n elements to be sorted) is O(n log n) / p ~ O(log n). Compare and Exchange Sorting Algorithms • Form the basis of several, if not most, classical sequential sorting algorithms. • Two numbers, say A and B, are compared between P0 and P1. P0 P1 A B MIN MAX Bubble Sort • Generic example of a “bad” sorting 0 1 2 3 4 5 algorithm. start: 1 3 8 0 6 5 0 1 2 3 4 5 Algorithm: • after pass 1: 1 3 0 6 5 8 • Compare neighboring elements. • Swap if neighbor is out of order. 0 1 2 3 4 5 • Two nested loops. after pass 2: 1 0 3 5 6 8 • Stop when a whole pass 0 1 2 3 4 5 completes without any swaps. after pass 3: 0 1 3 5 6 8 0 1 2 3 4 5 • Performance: 2 after pass 4: 0 1 3 5 6 8 Worst: O(n ) • 2 • Average: O(n ) fin. • Best: O(n) "The bubble sort seems to have nothing to recommend it, except a catchy name and the fact that it leads to some interesting theoretical problems." - Donald Knuth, The Art of Computer Programming Odd-Even Transposition Sort (also Brick Sort) • Simple sorting algorithm that was introduced in 1972 by Nico Habermann who originally developed it for parallel architectures (“Parallel Neighbor-Sort”).
    [Show full text]
  • Sorting Algorithm 1 Sorting Algorithm
    Sorting algorithm 1 Sorting algorithm In computer science, a sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order. Efficient sorting is important for optimizing the use of other algorithms (such as search and merge algorithms) that require sorted lists to work correctly; it is also often useful for canonicalizing data and for producing human-readable output. More formally, the output must satisfy two conditions: 1. The output is in nondecreasing order (each element is no smaller than the previous element according to the desired total order); 2. The output is a permutation, or reordering, of the input. Since the dawn of computing, the sorting problem has attracted a great deal of research, perhaps due to the complexity of solving it efficiently despite its simple, familiar statement. For example, bubble sort was analyzed as early as 1956.[1] Although many consider it a solved problem, useful new sorting algorithms are still being invented (for example, library sort was first published in 2004). Sorting algorithms are prevalent in introductory computer science classes, where the abundance of algorithms for the problem provides a gentle introduction to a variety of core algorithm concepts, such as big O notation, divide and conquer algorithms, data structures, randomized algorithms, best, worst and average case analysis, time-space tradeoffs, and lower bounds. Classification Sorting algorithms used in computer science are often classified by: • Computational complexity (worst, average and best behaviour) of element comparisons in terms of the size of the list . For typical sorting algorithms good behavior is and bad behavior is .
    [Show full text]
  • Visvesvaraya Technological University a Project Report
    ` VISVESVARAYA TECHNOLOGICAL UNIVERSITY “Jnana Sangama”, Belagavi – 590 018 A PROJECT REPORT ON “PREDICTIVE SCHEDULING OF SORTING ALGORITHMS” Submitted in partial fulfillment for the award of the degree of BACHELOR OF ENGINEERING IN COMPUTER SCIENCE AND ENGINEERING BY RANJIT KUMAR SHA (1NH13CS092) SANDIP SHAH (1NH13CS101) SAURABH RAI (1NH13CS104) GAURAV KUMAR (1NH13CS718) Under the guidance of Ms. Sridevi (Senior Assistant Professor, Dept. of CSE, NHCE) DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING NEW HORIZON COLLEGE OF ENGINEERING (ISO-9001:2000 certified, Accredited by NAAC ‘A’, Permanently affiliated to VTU) Outer Ring Road, Panathur Post, Near Marathalli, Bangalore – 560103 ` NEW HORIZON COLLEGE OF ENGINEERING (ISO-9001:2000 certified, Accredited by NAAC ‘A’ Permanently affiliated to VTU) Outer Ring Road, Panathur Post, Near Marathalli, Bangalore-560 103 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING CERTIFICATE Certified that the project work entitled “PREDICTIVE SCHEDULING OF SORTING ALGORITHMS” carried out by RANJIT KUMAR SHA (1NH13CS092), SANDIP SHAH (1NH13CS101), SAURABH RAI (1NH13CS104) and GAURAV KUMAR (1NH13CS718) bonafide students of NEW HORIZON COLLEGE OF ENGINEERING in partial fulfillment for the award of Bachelor of Engineering in Computer Science and Engineering of the Visvesvaraya Technological University, Belagavi during the year 2016-2017. It is certified that all corrections/suggestions indicated for Internal Assessment have been incorporated in the report deposited in the department library. The project report has been approved as it satisfies the academic requirements in respect of Project work prescribed for the Degree. Name & Signature of Guide Name Signature of HOD Signature of Principal (Ms. Sridevi) (Dr. Prashanth C.S.R.) (Dr. Manjunatha) External Viva Name of Examiner Signature with date 1.
    [Show full text]
  • An Ordering Experiment A
    Journal of Economic Behavior & Organization Vol. 50 (2003) 249–262 An ordering experiment A. Norman∗, M. Ahmed, J. Chou, K. Fortson, C. Kurz, H. Lee, L. Linden, K. Meythaler, R. Rando, K. Sheppard, N. Tantzen, I. White, M. Ziegler Department of Economics, The University of Texas at Austin, Austin, TX 78712-1173, USA Received 12 December 2000; accepted 20 April 2001 Abstract Binary comparison operators form the basis of consumer set theory. If humans could only per- form binary comparisons, the most efficient procedure a human might employ to make a complete n n n preference ordering of items would be a log2 algorithm. But, if humans are capable of assigning each item an ordinal utility value, they are capable of implementing a more efficient linear algo- rithm. In this paper, we consider six incentive systems for ordering three different sets of objects: pens, notebooks, and Hot Wheels. All experimental evidence indicates that humans are capable of implementing a linear algorithm, for small sets. © 2003 Elsevier Science B.V. All rights reserved. JEL classification: C9 Design of Experiments; C91 Laboratory, Individual Behavior; D11 Consumer Economics: Theory; C61 Optimization Techniques; Programming Models; C63 Computational Techniques; C69 Other-Complexity Theory Keywords: Linear algorithm; Binary comparison; Ordering 1. Introduction We experimentally examine the algorithms that individuals use to order sets of objects. Our focus is not the static properties of the ordered objects, but rather the properties of the algorithms that humans use to make the ordering. By comparing human algorithms with known computer ordering algorithms, we can determine their properties. We use complex- ity theory to measure cost and to formulate hypotheses to test among alternative human algorithms.
    [Show full text]
  • Practice Quiz 1 Solutions
    Introduction to Algorithms October 2, 2001 Massachusetts Institute of Technology 6.046J/18.410J Singapore-MIT Alliance SMA5503 Professors Professors Erik Demaine, Lee Wee Sun, and Charles E. Leiserson Handout 16 Practice Quiz 1 Solutions Do not open this quiz booklet until you are directed to do so. This quiz starts at 2:35 P.M. and ends at 3:55 P.M. It contains 3 problems, some with multiple parts. The quiz contains 13 pages, including this one. You have 80 minutes to earn 100 points. ¡£¢ ¤¦¥ ¥¨§ © © ¥ This quiz is closed book. You may use one handwritten ¥ crib sheet. No calculators are permitted. When the quiz begins, write your name on every page of this quiz booklet in the space provided. Write your solutions in the space provided. If you need more space, write on the back of the sheet containing the problem. Do not put part of the answer to one problem on the back of the sheet for another problem, since the pages will be separated for grading. Do not spend too much time on any problem. Read them all through first and attack them in the order that allows you to make the most progress. Show your work, as partial credit will be given. You will be graded not only on the correct- ness of your answer, but also on the clarity with which you express it. Be neat. Good luck! Handout 16: Practice Quiz 1 Solutions 2 Problem 1. Integer Multiplication [15 points] The following algorithm multiplies two nonnegative integers and : MULT 1 2 while © 3 do if ¨ "! %$& 4 then # '( *) !,+ 5 !.
    [Show full text]
  • How to Sort out Your Life in O(N) Time
    How to sort out your life in O(n) time arel Číže @kaja47K funkcionaklne.cz I said, "Kiss me, you're beautiful - These are truly the last days" Godspeed You! Black Emperor, The Dead Flag Blues Everyone, deep in their hearts, is waiting for the end of the world to come. Haruki Murakami, 1Q84 ... Free lunch 1965 – 2022 Cramming More Components onto Integrated Circuits http://www.cs.utexas.edu/~fussell/courses/cs352h/papers/moore.pdf He pays his staff in junk. William S. Burroughs, Naked Lunch Sorting? quicksort and chill HS 1964 QS 1959 MS 1945 RS 1887 quicksort, mergesort, heapsort, radix sort, multi- way merge sort, samplesort, insertion sort, selection sort, library sort, counting sort, bucketsort, bitonic merge sort, Batcher odd-even sort, odd–even transposition sort, radix quick sort, radix merge sort*, burst sort binary search tree, B-tree, R-tree, VP tree, trie, log-structured merge tree, skip list, YOLO tree* vs. hashing Robin Hood hashing https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf xs.sorted.take(k) (take (sort xs) k) qsort(lotOfIntegers) It may be the wrong decision, but fuck it, it's mine. (Mark Z. Danielewski, House of Leaves) I tell you, my man, this is the American Dream in action! We’d be fools not to ride this strange torpedo all the way out to the end. (HST, FALILV) Linear time sorting? I owe the discovery of Uqbar to the conjunction of a mirror and an Encyclopedia. (Jorge Luis Borges, Tlön, Uqbar, Orbis Tertius) Sorting out graph processing https://github.com/frankmcsherry/blog/blob/master/posts/2015-08-15.md Radix Sort Revisited http://www.codercorner.com/RadixSortRevisited.htm Sketchy radix sort https://github.com/kaja47/sketches (thinking|drinking|WTF)* I know they accuse me of arrogance, and perhaps misanthropy, and perhaps of madness.
    [Show full text]