l a b d e a d l i n e s
play

L a b d e a d l i n e s I f y o u ' v e m i s - PowerPoint PPT Presentation

L a b d e a d l i n e s I f y o u ' v e m i s s e d t h e fj n a l d e a d l i n e f o r a l a b , d o n ' t p a n i c ! O n J u n e t h e 6 ( M o n d a y a f t e r t


  1. L a b d e a d l i n e s I f y o u ' v e m i s s e d t h e fj n a l d e a d l i n e f o r a l a b , d o n ' t p a n i c ! O n J u n e t h e 6 ( M o n d a y a f t e r t h e e x a m ) I t h w i l l s i t i n m y o ffj c e ( 5 4 6 9 ) f r o m 1 - 3 a n d y o u c a n s h o w m e y o u r l a b i n p e r s o n

  2. S u mmi n g u p

  3. B a s i c A D T s M a p s : m a i n t a i n a k e y / v a l u e r e l a t i o n s h i p ● A n a r r a y i s a s o r t o f m a p w h e r e t h e k e y s a r e a r r a y i n d i c e s S e t s : l i k e a m a p b u t w i t h o n l y k e y s , n o v a l u e s Q u e u e : a d d t o o n e e n d , r e m o v e f r o m t h e o t h e r S t a c k : a d d a n d r e m o v e f r o m t h e s a m e e n d D e q u e : a d d a n d r e m o v e f r o m e i t h e r e n d P r i o r i t y q u e u e : a d d , r e m o v e m i n i m u m

  4. I m p l e m e n t i n g m a p s a n d s e t s A b i n a r y s e a r c h t r e e ● G o o d p e r f o r m a n c e i f y o u c a n k e e p i t b a l a n c e d : O ( l o g n ) ● H a s g o o d r a n d o m a n d s e q u e n t i a l a c c e s s : t h e b e s t o f b o t h w o r l d s A h a s h t a b l e ● V e r y f a s t i f y o u c h o o s e a g o o d h a s h f u n c t i o n : O ( 1 ) A s k i p l i s t ● Q u i t e s i m p l e t o i m p l e m e n t ● O n l y a p p r o p r i a t e f o r i m p e r a t i v e l a n g u a g e s ● P r o b a b i l i s t i c p e r f o r m a n c e o n l y , t y p i c a l l y : O ( l o g n )

  5. I m p l e m e n t i n g q u e u e s , s t a c k s , p r i o r i t y q u e u e s Q u e u e s : ● a c i r c u l a r a r r a y ( i n a n i m p e r a t i v e l a n g u a g e ) ● a p a i r o f l i s t s ( i n a f u n c t i o n a l l a n g u a g e ) S t a c k s : ● a d y n a m i c a r r a y ( i n a n i m p e r a t i v e l a n g u a g e ) ● a l i s t ( i n a f u n c t i o n a l l a n g u a g e ) P r i o r i t y q u e u e s : ● a b i n a r y h e a p ( i n a n i m p e r a t i v e l a n g u a g e ) ● a s k e w h e a p ( i n a f u n c t i o n a l l a n g u a g e )

  6. W h a t w e h a v e s t u d i e d Tie d a t a s t r u c t u r e s a n d A D T s a b o v e + a l g o r i t h m s t h a t w o r k o n t h e s e d a t a s t r u c t u r e s ( s o r t i n g , D i j k s t r a ' s , e t c . ) + c o m p l e x i t y + d a t a s t r u c t u r e d e s i g n ( i n v a r i a n t , e t c . ) Y o u c a n a p p l y t h e s e i d e a s t o y o u r o w n p r o g r a m s , d a t a s t r u c t u r e s , a l g o r i t h m s e t c . ● U s i n g a p p r o p r i a t e d a t a s t r u c t u r e s t o s i m p l i f y y o u r p r o g r a m s + m a k e t h e m f a s t e r ● T a k i n g i d e a s f r o m e x i s t i n g d a t a s t r u c t u r e s w h e n y o u n e e d t o b u i l d y o u r o w n

  7. D a t a s t r u c t u r e d e s i g n H o w t o d e s i g n y o u r o w n d a t a s t r u c t u r e s ? ● Tii s t a k e s p r a c t i c e ! S t u d y o t h e r p e o p l e ' s i d e a s : ● h t t p : / / e n . w i k i p e d i a . o r g / w i k i / L i s t _ o f _ d a t a _ s t r u c t u r e s ● B o o k : P r o g r a m m i n g P e a r l s ● B o o k : P u r e l y F u n c t i o n a l D a t a S t r u c t u r e s ● B o o k : A l g o r i t h m s b y S e d g e w i c k ● S t u d y y o u r f a v o u r i t e l a n g u a g e ' s s t a n d a r d l i b r a r y

  8. D a t a s t r u c t u r e d e s i g n F i r s t , i d e n t i f y w h a t o p e r a t i o n s t h e d a t a s t r u c t u r e m u s t s u p p o r t ● O f t e n t h e r e ' s a n e x i s t i n g d a t a s t r u c t u r e y o u c a n u s e ● O r p e r h a p s y o u c a n a d a p t a n e x i s t i n g o n e ? Tie n d e c i d e o n : ● A r e p r e s e n t a t i o n ( t r e e , a r r a y , e t c . ) ● A n i n v a r i a n t Tie s e h o p e f u l l y d r i v e t h e r e s t o f t h e d e s i g n !

  9. D a t a s t r u c t u r e d e s i g n F i n a l l y , r e m e m b e r t h e F i r s t a n d S e c o n d R u l e s o f P r o g r a m O p t i m i s a t i o n : 1 . D o n ’ t d o i t . 2 . ( F o r e x p e r t s o n l y ! ) : D o n ’ t d o i t y e t . K e e p t h i n g s s i m p l e ! ● N o p o i n t o p t i m i s i n g y o u r a l g o r i t h m s t o h a v e O ( l o g n ) c o m p l e x i t y i f i t t u r n s o u t n ≤ 1 0 ● P r o fj l e y o u r p r o g r a m t o fj n d t h e b o t t l e n e c k s a r e ● U s e b i g - O c o m p l e x i t y t o g e t a h a n d l e o n p e r f o r m a n c e b e f o r e y o u s t a r t i m p l e m e n t i n g i t

  10. W h a t w e h a v e n ' t h a d t i m e f o r

  11. A m o r t i s e d c o m p l e x i t y a n a l y s i s D y n a m i c a r r a y s , h a s h t a b l e s , s k e w h e a p s e t c . h a v e a m o r t i s e d c o m p l e x i t y ● e . g . s k e w h e a p s : O ( l o g n ) a m o r t i s e d c o m p l e x i t y m e a n s a s e q u e n c e o f n o p e r a t i o n s t a k e s O ( n l o g n ) t i m e W e a n a l y s e d t h e c o m p l e x i t y o f d y n a m i c a r r a y s , b u t f o r e . g . s k e w h e a p s i t ’ s t o o h a r d A m o r t i s e d a n a l y s i s g i v e s u s c u t e t o o l s t o c a l c u l a t e a m o r t i s e d c o m p l e x i t y ● e . g . t h e b a n k e r ’ s m e t h o d : t h e r e i s a “ p i g g y b a n k ” c o n t a i n i n g a n u m b e r o f u n i t s o f t i m e ● o p e r a t i o n s c a n c h o o s e t o p u t t i m e i n t o t h e p i g g y b a n k ; t h i s t i m e i s c o u n t e d a s p a r t o f t h e i r r u n n i n g t i m e ● e x p e n s i v e o p e r a t i o n s c a n e m p t y t h e p i g g y b a n k a n d u s e t h e t i m e i n i t , w h i c h i s s u b t r a c t e d f r o m t h e i r a c t u a l r u n n i n g t i m e ● b y s a v i n g a n d t a k i n g o u t e x a c t l y t h e r i g h t a m o u n t o f t i m e f r o m t h e p i g g y b a n k , y o u c a n a n a l y s e t h e o p e r a t i o n s a s i f t h e y h a d n o n - a m o r t i s e d c o m p l e x i t y

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend