130 likes | 219 Views
Algorithms & Data structures M. Antczak , S. Wąsik. Static tables:. Character tables (string):. Static tables (2) :. Pointers:. * first_ptr = * second_ptr =. ? ?. 1 1. Steve Oualline , „ Practical C Programming, 3rd Edition ”, O’REILLY. *. Pointers as Function arguments:.
E N D
Algorithms & Data structures M. Antczak, S. Wąsik
Pointers: *first_ptr = *second_ptr = ? ? 1 1 Steve Oualline , „Practical C Programming, 3rd Edition”, O’REILLY
* Pointers as Function arguments: & Const pointers:
Pointers as Arrays: *array_ptr == array[0] *(array_ptr + 1) == array[1] *(array_ptr + 2) == array[2] … *(array_ptr) + 1 == array[1] NO! *(array_ptr) + 1 == array[0] + 1 OK! Steve Oualline , „Practical C Programming, 3rd Edition”, O’REILLY
One direction list: Two direction list: New element addition: at beginning Selected element deletion: from the beginning 2) in the middle 3) from the end 2) from the middle 3) at the end
Stack (Last In – First Out) Queue (First In – First Out) New element addition New element addition Head element deletion First element deletion
Let’s build the Binary Search Tree (BST) based on numbers sequence defined below: 12, 18, 5, 19, 2, 15, 9, 17 BST Searching: Pre-order (wzdłużne): Root, LeftSubtree, RightSubtree (R,LS,RS). In-order (poprzeczne): LeftSubtree, Root, RightSubtree (LS,R,RS). Post-order (wsteczne): LeftSubtree, RightSubtree, Root (LS,RS,R). 12 <= > 12 L 19<=18 R 19>18 L 18<=12 R 18>12 L 5<=12 R 5>12 L 17<=15 R 17>15 L 15<=12 R 15>12 L 9<=12 R 9>12 L 9<=5 R 9>5 L 17<=12 R 17>12 L 17<=18 R 17>18 L 15<=18 R 15>18 L 19<=12 R 19>12 L 2<=5 R 2>5 L 2<=12 R 2>12 Pre-order: 12, 5, 2, 9, 18, 15, 17, 19. 5 18 In-order: 2, 5, 9, 12, 15, 17, 18, 19. Post-order : 2, 9, 5, 17, 15, 19, 18, 12. 9 15 19 2 BST removing (e.g. 18): MIN=19 12 1) Maximalnodefromleftsubtree 17 2) Minimalnodefromrightsubtree MAX=17 19 5 12 9 15 2 17 5 17 9 19 2 15