The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
Lecture 6 - linear sorting The Shifflett's of Charlottesville For comparison, note that there are seven Shifflett's (of various spellings) in the 1000 page Manhattan telephone directory. Listen To Part 6-10 Rules for Algorithm Design The secret to successful algorithm design, and problem solving in general, is to make sure you ask the right questions. Below, I give a possible series of questions for you to ask yourself as you try to solve difficult algorithm design problems: 1. Do I really understand the problem? 1. What exactly does the input consist of? 2. What exactly are the desired results or output? 3. Can I construct some examples small enough to solve by hand? What happens when I solve them? 4. Are you trying to solve a numerical problem? A graph algorithm problem? A geometric problem? A string problem? A set problem? Might your problem be formulated in more than one way? Which formulation seems easiest? 2. Can I find a simple algorithm for the problem? 1. Can I find the solve my problem exactly by searching all subsets or arrangements and picking the best one? 1. If so, why am I sure that this algorithm always gives the correct answer? 2. How do I measure the quality of a solution once I construct it? file:///E|/LEC/LECTUR17/NODE6.HTM (5 of 7) [19/1/2003 1:34:38]
Lecture 6 - linear sorting Listen To Part 6-11 3. Does this simple, slow solution run in polynomial or exponential time? 4. If I can't find a slow, guaranteed correct algorithm, am I sure that my problem is well defined enough to permit a solution? 2. Can I solve my problem by repeatedly trying some heuristic rule, like picking the biggest item first? The smallest item first? A random item first? 1. If so, on what types of inputs does this heuristic rule work well? Do these correspond to the types of inputs that might arise in the application? 2. On what types of inputs does this heuristic rule work badly? If no such examples can be found, can I show that in fact it always works well? 3. How fast does my heuristic rule come up with an answer? 3. Are there special cases of this problem I know how to solve exactly? 1. Can I solve it efficiently when I ignore some of the input parameters? 2. What happens when I set some of the input parameters to trivial values, such as 0 or 1? Listen To Part 6-12 3. Can I simplify the problem to create a problem I can solve efficiently? How simple do I have to make it? 4. If I can solve a certain special case, why can't this be generalized to a wider class of inputs? 4. Which of the standard algorithm design paradigms seem most relevant to the problem? 1. Is there a set of items which can be sorted by size or some key? Does this sorted order make it easier to find what might be the answer? 2. Is there a way to split the problem in two smaller problems, perhaps by doing a binary search, or a partition of the elements into big and small, or left and right? If so, does this suggest a divide-and-conquer algorithm? 3. Are there certain operations being repeatedly done on the same data, such as searching it for some element, or finding the largest/smallest remaining element? If so, can I use a data structure of speed up these queries, like hash tables or a heap/priority queue? 5. Am I still stumped? 1. Why don't I go back to the beginning of the list and work through the questions again? Do any of my answers from the first trip change on the second? file:///E|/LEC/LECTUR17/NODE6.HTM (6 of 7) [19/1/2003 1:34:38]
- Page 849 and 850: Lecture 1 - analyzing algorithms Th
- Page 851 and 852: Lecture 1 - analyzing algorithms is
- Page 853 and 854: Lecture 2 - asymptotic notation How
- Page 855 and 856: Lecture 2 - asymptotic notation Not
- Page 857 and 858: Lecture 2 - asymptotic notation alg
- Page 859 and 860: Lecture 2 - asymptotic notation Sup
- Page 861 and 862: Lecture 2 - asymptotic notation Nex
- Page 863 and 864: Lecture 3 - recurrence relations Is
- Page 865 and 866: Lecture 3 - recurrence relations
- Page 867 and 868: Lecture 3 - recurrence relations Li
- Page 869 and 870: Lecture 3 - recurrence relations Su
- Page 871 and 872: Lecture 3 - recurrence relations A
- Page 873 and 874: Lecture 4 - heapsort Note iteration
- Page 875 and 876: Lecture 4 - heapsort The convex hul
- Page 877 and 878: Lecture 4 - heapsort 1. All leaves
- Page 879 and 880: Lecture 4 - heapsort left = 2i righ
- Page 881 and 882: Lecture 4 - heapsort Since this sum
- Page 883 and 884: Lecture 4 - heapsort Selection sort
- Page 885 and 886: Lecture 4 - heapsort Greedy Algorit
- Page 887 and 888: Lecture 5 - quicksort Partitioning
- Page 889 and 890: Lecture 5 - quicksort Listen To Par
- Page 891 and 892: Lecture 5 - quicksort Listen To Par
- Page 893 and 894: Lecture 5 - quicksort The worst cas
- Page 895 and 896: Lecture 5 - quicksort Mon Jun 2 09:
- Page 897 and 898: Lecture 6 - linear sorting Since 2i
- Page 899: Lecture 6 - linear sorting With uni
- Page 903 and 904: Lecture 7 - elementary data structu
- Page 905 and 906: Lecture 7 - elementary data structu
- Page 907 and 908: Lecture 7 - elementary data structu
- Page 909 and 910: Lecture 7 - elementary data structu
- Page 911 and 912: Lecture 7 - elementary data structu
- Page 913 and 914: Lecture 7 - elementary data structu
- Page 915 and 916: Lecture 7 - elementary data structu
- Page 917 and 918: Lecture 8 - binary trees - Joyce Ki
- Page 919 and 920: Lecture 8 - binary trees TREE-MINIM
- Page 921 and 922: Lecture 8 - binary trees Inorder-Tr
- Page 923 and 924: Lecture 8 - binary trees Listen To
- Page 925 and 926: Lecture 8 - binary trees insert(b)
- Page 927 and 928: Lecture 8 - binary trees Not (1) -
- Page 929 and 930: Lecture 9 - catch up Next: Lecture
- Page 931 and 932: Lecture 10 - tree restructuring 1.
- Page 933 and 934: Lecture 10 - tree restructuring Lis
- Page 935 and 936: Lecture 10 - tree restructuring Not
- Page 937 and 938: Lecture 10 - tree restructuring Cas
- Page 939 and 940: Lecture 11 - backtracking Next: Lec
- Page 941 and 942: Lecture 11 - backtracking Only 63 s
- Page 943 and 944: Lecture 11 - backtracking Recursion
- Page 945 and 946: Lecture 11 - backtracking Specifica
- Page 947 and 948: Lecture 12 - introduction to dynami
- Page 949 and 950: Lecture 12 - introduction to dynami
Lecture 6 - linear sorting<br />
<strong>The</strong> Shifflett's of Charlottesville<br />
For comparison, note that there are seven Shifflett's (of various spellings) in the 1000 page Manhattan<br />
telephone directory.<br />
Listen To Part 6-10<br />
Rules for <strong>Algorithm</strong> <strong>Design</strong><br />
<strong>The</strong> secret to successful algorithm design, and problem solving in general, is to make sure you ask the<br />
right questions. Below, I give a possible series of questions for you to ask yourself as you try to solve<br />
difficult algorithm design problems:<br />
1. Do I really understand the problem?<br />
1. What exactly does the input consist of?<br />
2. What exactly are the desired results or output?<br />
3. Can I construct some examples small enough to solve by hand? What happens when I<br />
solve them?<br />
4. Are you trying to solve a numerical problem? A graph algorithm problem? A geometric<br />
problem? A string problem? A set problem? Might your problem be formulated in more<br />
than one way? Which formulation seems easiest?<br />
2. Can I find a simple algorithm for the problem?<br />
1. Can I find the solve my problem exactly by searching all subsets or arrangements and<br />
picking the best one?<br />
1. If so, why am I sure that this algorithm always gives the correct answer?<br />
2. How do I measure the quality of a solution once I construct it?<br />
file:///E|/LEC/LECTUR17/NODE6.HTM (5 of 7) [19/1/2003 1:34:38]