Partitioningtakestime(n).
Quicksort:
Worst: T ( n)=cn+T (n1)
n2
c ( n1 ) ( n2 )
+c 0=(n2)
2
k=0
Common: T ( n ) = ( n )+ T ( n k 1 ) +T (k )
T ( n ) = c ( n k )+ c0 =cn ( n1 )
Randomized:
T ( n ) c '
9/17/2007
1"?! I927 Cstmw+ SC+' Fawhkon
Well Focus on
+k56 For much
of «Ms Course:
6} much D'F +he
4-0:.
grow) 5
(WCHADAS ' 0'
lot) K\Y\j\vc\4¥ [32316) 26) prinl new: in
col-clefz Submi'H'ec
CSE 241 Algorithms and Data Structures
Solutions to Practice Problems for Homework 4
1. Recall that A = w, m, q, k, f, p, b, a, c, d, b, k, g .
w m k f c d b k p g q b
(a)
a
w m k
(b)
v f p b k g b q
CSE 241 Algorithms and Data Structures
Solutions to Practice Problems for Homework 6 and Final
In the problems in which you are asked to give a bfs, dfs, or shortest path tree, instead of drawing it g
CSE 241 Algorithms and Data Structures
Fall Semester, 2007
Solutions to Practice Problems for Homework 2
1. First the median between 15, 8, and 3 is computed, and swapped into the last element of the
CSE 241 Algorithms and Data Structures
Solutions to Practice Problems for Homework 3
1. Suppose you are given the task to sort one thousand 32-bit keys. You have decided to use radix sort for this pro
241HW3Pb3
Xin Yan
435557
3.
(a)
acta
gaac
ctag
aagc
tcat
gcgt
ttct
Sort this list into lexicographic order with a radix sort that operates on the last string
position at a time.
acta
gaac
aagc
241HW3Pb1
Xin Yan
435557
1.
(a)
A=cfw_3, 9, 2, 7, 1, 6, 4, 5
5 is the pivot and set i=-1, j=0.
(1)
Compare A[j] with pivot: 3<5
Then i+ swap A[i] and A[j]
Then j+
A=cfw_3, 9, 2, 7, 1, 6, 4, 5
(
Xin Yan
435557
HW2Pb5
5.
(a)
When k=0, theres 2! = 1 .
When k=1, therere 2! = 2 .
When k=2, therere 2! = 4 .
When k=3, therere 2! = 8.
Suppose k=n, then therere 2! ,
Assume k=n+1, then there ar
Pb5
Xin Yan
435557
5.
(a)
A single node with k keys requires 3k + 4(k + 1) + 4 bytes, since it has k + 1 child
pointers and (per the problem statement) 4 bytes of additional information. To fit
Pb3
Xin Yan
435557
3.
(a)
(b)
For the insertion of 13: at level 3 we inspect INF
at level 2 we inspect 4 and INF
at level 1 we inspect INF
at level 0 we inspect 6 and INF
For the insertion of 9
Pb4
Xin Yan
435557
4.
(a)
Assume there are n nodes with the largest pillar height h. The link between the head
node and the node with the highest pillar skips at least one node. Also the link
b
CSE 241 Algorithms and Data Structures
Fall Semester 2015
Homework 1
Assigned: 8/31/2015
Due Date: 9/16/2015
This homework must be completed and submitted electronically. Formatting standards, submiss
ConcePh/xml View (4)09 FjijJlE/V/VU/y>
Mc-HoJ,$ IJCdim LS
Ma ak!) loCaql/SC/LYCLD rCVVlDVB
' / mm M W a.
$42, VVVtY In 0X y
° \ M SuaCSSOV m (oz SuccchoFCK) [5 r
:Dt X>NACWW M 6* Prdcccssor (Ls)