Anton Vorderman
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Samenvatting Algo & Data ## Arrays & Linked Lists Een Array is een data structuur waarbij je random access hebt. Hierdoor kun je op elke willekeurige plek items opzoeken. Een Linked List is een data structuur waarbij je data achter elkaar zet. Als je hier data wilt opzoeken zul je door de hele lijst heen moeten gaan. Het voordeel van een linked list ten opzicht van de array is dat insetion en deletion sneller verloopt. ### Array: |Index|0|1|2|3|4|5|6| |-----|-|-|-|-|-|-|-| |Value| #### Array bigO: |Access|Search|Insetion|Deletion| |------|------|--------|--------| |O(1) |O(n) | O(n) |O(n) | De reden dat insetion en deltion n en niet 1 is na dat een element is toegevoegt moet de overige elementen verplaats worden. n is the worst case. ### Linked List: ![](https://i.imgur.com/hNCpcee.png) #### Linked list bigO: |Access|Search|Insetion|Deletion| |------|------|--------|--------| |O(n) |O(n) |O(1) |O(1) | De rede dat acces en search n is en niet 1 is omdat de gehele lijst moet worden doorgelopen. In de worst case is de waarde die gevonden moet worden aan het einde van de linked list. ## Stack & Heap(memory): Data op de stack is data die daar tijdelijk op wordt gezet. Nadat de functie voorbij is wordt deze data verwijderd. Dit is dus een "short-lived memory" Om data op de heap op te slaan zal memory moeten worden toegewezen (door middel van een allocation functie, malloc). De volgende code allocates 1 megabyte aan memory. Het adres wordt dan opgeslapen in de variabele ptr. ```c= double *ptr; ptr = malloc(1024 * 1024); ``` Zodra je de allocated memory niet meer gebruikt zul je deze moeten vrij maken met de "free()" functie. ## Sorting Data kun je op meerdere manieren sorteren. Zodra data gesorteerd is kun je veel makkelijker iets opzoeken. Vaak wil je data ook gesorteerd toevoegen aan je datastructuur. Selection sort is bijvoorbeeld een erg inefficiente manier van sorteren: ![](https://i.imgur.com/1QTBWtw.png) *Selection Sort proces* Dit komt omdat je door de hele list gaat om de kleinste waarde te zoeken en deze dan omwisselt met de voorste. Daarna ga je opnieuw door de lijst heen en zoek je naar de dan laagste waarde en die wissel je dan om met de tweede plek, enzovoort. dit totdat je de hele lijst hebt gehad. De time complexity hiervan is: O(n^2) Merge sort is de best mogelijke manier van sorteren: ![](https://i.imgur.com/sepczaL.png) *Merge Sort Proces* Hier worden alle getallen opgesplitst in paren en dan per paar gesorteerd. Zodra je dan twee gesorteerde paren moet sorteren hoeft de computer alleen telkens de voorste van de paren te vergelijken. Dit gaat dan zo verder totdat alles gesorteerd is. De time complexity hiervan is: O(n*log(n)) ## Stacks & Queues ### Stacks Stacks is een datatype waar als het ware elementen op elkaar worden gestacked. Een stack heeft altijd een LIFO (Last In First Out). De het element te puchen worden elementen toegevoeg aan de aan de stack. Door de peeken worden het laatste toegevoegte element uitgelezen van de stack. Bij een pop wordt deze waarde ook van de stack afgehaald ![](https://i.imgur.com/WHTotYq.png) *Stack proces* #### Stack BigO: |Access|Search|Insertion|Deletion| |------|------|---------|--------| |O(n) |O(n) |O(1) |O(1) | ### Queue Queue is een datatype waar de eerste of de laatse toegevoegte waarde in de rij kan worden verwijdert. Bij deze datatype is er een sprake van zowel FIFO(fist in first out) als LIFO(Last in First Out). ![](https://i.imgur.com/CBgVRqi.png) *Queue process. Ook gespiegeld toe te passen* #### Queue BigO: |Access|Search|Insetion|Deletion| |------|------|--------|--------| |O(n) |O(n) | O(1) | O(1) | ## Sets(nog niet af) Items zijn vaak gesorteerd in sets op basis van een eigenschap. Auto's kunnen bijvoorbeeld gesorteerd worden op prijs, merk of kleur. Het zoeken op basis van deze eigenschappen wordt "membership testing" ### Binary search Dit is manier van zoeken wat wordt gebruikt bij een sorted array. ![](https://i.imgur.com/K6YqRlN.png) De array wordt telkens opgesplitst en er wordt dan gekeken of de te zoeken waarde groter of kleiner is dan deze middelste waarde. Hierdoor wordt de array telkens in tweeën gesplitst. De time complexity hiervan is: O(log(n)) Sets is nog niet af!!!!!!!!!!!!!!!!!!!!! ## Voordelen & Nadelen typen structuren ### (Sorted) Arrays #### *Voordelen*: 1. Directe access indien index bekend. 2. makkelijk te gebruiken. 3. Sorted is snel m.b.t. zoeken (Zie Binary Search). #### *Nadelen*: 1. Unsorted is langzaam wat befreft zoeken. Worst case moet elke waarde worden ge-iterate. ### Linked Lists #### *Voordelen*: 1. Makkelijk in gebruik waar hele lijst voor nodig is. #### *Nadelen*: 1. Langzaam wat betreft zoeken. Worst case moet elke waarde worden ge-iterate. 2. 2 pointers per 'node' voor verwijzing voorliggende en achterliggende node. ### Stacks #### *Voordelen* 1. LIFO #### *Nadelen* 1. Data verborgen onder is onbereikbaar. ### Queues #### *Voordelen* 1. LIFO en FIFO #### *Nadelen* 1. Data verborgen midden in is onbereikbaar. ### Self Balancing Binary Trees #### *Voordelen* 1. Het principe is al gesorteerd 2. Binary Search toepasbaar #### *Nadelen* 1. 2 extra values per node voor self balancing feature ### Heaps **T.B.D.** ### Priority Queues **T.B.D.** ## Big O Notaties |Structuur|Access|Search|Insert|Delete| |---------|------|------|------|------| |Sorted Dynamic Array|O(1)|O(n)|O(n)|O(n) | |Linked List|O(n)|O(n) |O(1) |O(1) | |Stack |O(n) |O(n) |O(1) |O(1) | |Queue |O(n) |O(n) |O(1) |O(1) | |Self Balancing Tree|O(n)|O(n)|O(n)|O(n)| |Heap | | | | | |Priority Tree| | | | | |Algoritme |Worst Case | |------------------|----------------| |Selection Sort |O(n<sup>2</sup>)| |Merge Sort |O(n * Log(n)) | |Binary Search |O(Log(n)) |

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully