PAT
薄层
努力就有收获~
展开
-
Today一只菜鸡的PAT甲级测试(PAT1124, PAT1125, PAT1126, PAT1127)
PAT (Advanced Level) Practise1124 Raffle for Weibo Followers (20)1125 Chain the Ropes (25)1126 Eulerian Path (25)1127 ZigZagging on a Tree (30)原创 2017-03-04 23:47:29 · 523 阅读 · 0 评论 -
PAT甲级-1135 Is It A Red-Black Tree
主要是要理解红黑树的定义:There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties:(1) Every node is either red or black.(2) The root is bl原创 2018-03-11 12:18:51 · 357 阅读 · 0 评论 -
PAT-1143 Lowest Common Ancestor(二分寻找BST的LCA)
题意:给定一颗二叉搜索树的前序序列,然后给定两点u, v,寻找其LCA。思路:最直接的思路就是建树,然后寻找Lca,可以发现对于BST上的当前节点,如果其key小于两点u,v中较小的,则u和v的Lca必定会在当前节点的右子树上;如果其key大于两点u,v中较大的,则u和v的Lca必定会在当前节点的左子树上。所以这种想法可以很容易实现并且具有较好的复杂度。但是交题只能过前两组测试点,后三原创 2018-03-18 23:34:53 · 643 阅读 · 2 评论