1 / 13

Algorithms & Data structures M. Antczak , S. Wąsik

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:.

locke
Download Presentation

Algorithms & Data structures M. Antczak , S. Wąsik

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Algorithms & Data structures M. Antczak, S. Wąsik

  2. Static tables:

  3. Character tables (string):

  4. Static tables (2):

  5. Pointers: *first_ptr = *second_ptr = ? ? 1 1 Steve Oualline , „Practical C Programming, 3rd Edition”, O’REILLY

  6. * Pointers as Function arguments: & Const pointers:

  7. 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

  8. Dynamic memory allocation:

  9. Dynamic vector & matrix implementation:

  10. 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

  11. Stack (Last In – First Out) Queue (First In – First Out) New element addition New element addition Head element deletion First element deletion

  12. 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

  13. Basic list implementation:

More Related