This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- GHCi, version 8.8.4 | |
| -- author: Evgeniy Malov | |
| -- AVL delete: https://www.youtube.com/watch?v=DfSeb2fDH3s | |
| -- AVL insert: https://www.youtube.com/watch?v=SlAJirZ0KTE&t=0s | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| import Control.Monad | |
| import Data.Maybe | |
| import qualified Data.List as L | |
| import qualified Data.Map as M | |
| import PrettyT -- https://gist.github.com/evgenii-malov/1fc29a652751451dbca0d54d454cc1ef |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE ScopedTypeVariables #-} | |
| import Control.Monad | |
| import Data.Maybe | |
| import qualified Data.List as L | |
| import qualified Data.Map as M | |
| data Uedge a = Ue (a,a) deriving Show | |
| instance Eq a => Eq (Uedge a) where | |
| (==) (Ue (a,b)) (Ue (a1,b1)) = (a == a1 && b==b1 ) || (a==b1 && b==a1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- video https://studio.youtube.com/video/KJkpvt2787g/edit | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| --{-# LANGUAGE AllowAmbiguousTypes #-} | |
| import Control.Monad | |
| import Data.List | |
| import Data.Maybe | |
| import qualified Data.Map as M | |
| import qualified Data.Set as S | |
| import qualified Bheap as H -- https://gist.github.com/evgenii-malov/78e690007a60b2230676bc3f1ee50052 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- https://www.youtube.com/watch?v=NRzjkrrDJyQ | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| -- GHCi, version 8.8.4 | |
| import qualified Bheap as H -- https://gist.github.com/evgenii-malov/78e690007a60b2230676bc3f1ee50052 | |
| import Control.Monad | |
| import Data.List | |
| import Data.Maybe | |
| import qualified Data.Map as M | |
| -- Dijkstra's algorithm solves the shortest-path problem for any weighted, directed graph |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Whatch videos about binary heap | |
| -- https://www.youtube.com/watch?v=2uWbUd-sEgM | |
| -- https://www.youtube.com/watch?v=hSVC1fHzGQ0 | |
| -- https://www.youtube.com/watch?v=bfrXhzRNL2g | |
| -- https://www.youtube.com/watch?v=8oRm3jCpBoE | |
| {-# LANGUAGE FlexibleInstances #-} | |
| --{-# LANGUAGE AllowAmbiguousTypes #-} -- ?? | |
| module Bheap where | |
| import PrettyT -- https://gist.github.com/evgenii-malov/1fc29a652751451dbca0d54d454cc1ef |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE FlexibleInstances #-} | |
| --{-# LANGUAGE AllowAmbiguousTypes #-} -- ?? | |
| import PrettyT | |
| import Data.List | |
| import qualified Data.Map as M | |
| import Data.Maybe | |
| import Control.Monad | |
| import Control.Applicative | |
| -- data Btree a = Empty | Node a (Btree a) (Btree a) deriving Show |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE ScopedTypeVariables #-} | |
| -- GHCi, version 8.8.4 | |
| -- explanation video https://www.youtube.com/watch?v=gcjL7BlrsTM | |
| import Control.Monad | |
| import Data.List | |
| import Data.Maybe | |
| import qualified Data.Map as M | |
| -- Dijkstra's algorithm solves the shortest-path problem for any weighted, directed graph | |
| -- with non-negative weights. It can handle graphs consisting of cycles, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import PrettyT -- https://www.youtube.com/watch?v=Ud-1Z0hBlB8&t=15s | |
| import Data.List | |
| import Data.Maybe | |
| import Control.Monad | |
| import Control.Applicative | |
| -- data Btree a = Empty | Node a (Btree a) (Btree a) deriving Show | |
| --In a complete binary tree every level, except possibly the last, is completely filled, | |
| -- and all nodes in the last level are as far left as possible. | |
| -- It can have between 1 and 2h nodes at the last level h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- see video - https://www.youtube.com/watch?v=PWL68hPTwxQ | |
| import PrettyT | |
| import Data.List | |
| --In a complete binary tree every level, except possibly the last, is completely filled, | |
| -- and all nodes in the last level are as far left as possible. | |
| -- It can have between 1 and 2h nodes at the last level h | |
| ctb :: Int -> [a] -> Btree a | |
| ctb _ [] = Empty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- see videos https://www.youtube.com/watch?v=UM0sggwLXk4&t=974s | |
| -- https://www.youtube.com/watch?v=RS7eIkETdIQ | |
| -- https://www.youtube.com/watch?v=UM0sggwLXk4&t=974s | |
| import Control.Monad | |
| import Data.List | |
| import Data.Maybe | |
| data Uedge a = Ue (a,a) deriving Show | |
| (<->) a b = Ue (a,b) |