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
    # Week 2 - Linked Lists ## Team Team name: Date: Members | Role | Name | | ------------------------------------------------------------ | ---- | | **Facilitator** keeps track of time, assigns tasks and makes sure all the group members are heard and that decisions are agreed upon. |Larissa | | **Spokesperson** communicates group’s questions and problems to the teacher and talks to other teams; presents the group’s findings. |Anton | | **Reflector** observes and assesses the interactions and performance among team members. Provides positive feedback and intervenes with suggestions to improve groups’ processes. |Larissa | | **Recorder** guides consensus building in the group by recording answers to questions. Collects important information and data. |Jesse | ## Activities ### Activity 1: Linked lists versus arrays In the courses programming 1 & 2 you have used arrays a lot, and in the previous week, you have revisited them. Common operations performed on arrays and linked lists are retrieval, appending, insertion, and deletion. Discuss how these four operations compare for arrays and linked lists, in terms of the effort it takes to implement these operations, and in terms of the time these operations take. Can you think of a situation where you would not want to use an array, but rather a (singly or doubly) linked list? **Record your answer here:** Bij retrieval is een array stukken beter. Bij een linked list heb je geen random access. Bij appending is een linked list stukken beter. Je hoeft de grootte van een linked list niet te declaren. Bij insertion is een linked list stukken beter. Bij een linked list kun je makkelijk items in het midden toevoegen. Bij deletion is een array stukken beter. Doordat je daarbij random access hebt kun je ook makkelijk items verwijderen. Als je een array aanmaakt en je maakt het bijvoorbeeld voor 100 elementen aan maar je gebruikt niet alle 100 elementen is het een waste of memory dit heb je bij linked lists niet. Voorbeeld: Vorige en volgende pagina in een webbrowser ### Activity 2: Linked list initialization Implement the linkedlist_init function, using the prototype definition listed below. Make sure that the head and tail of the initialized linked list are set to NULL. **Record your answer here:** ```c= typedef struct LLNode { int value; struct LLNode* pPrevious; struct LLNode* pNext; } LinkedListNode; typedef struct { LinkedListNode *pHead; LinkedListNode *pTail; } LinkedList; void linkedlist_init(LinkedList *list){ list->pHead = NULL; list->pTail = NULL; } ``` ### Activity 3: Adding nodes & memory Discuss with your group: when adding a new value to the list, a LinkedListNode structure must be created to hold the value. Should this structure be kept on the stack or on the heap? Why? **Record your answer here:** De linkedListNode structure zal moeten worden opgeslagen in de de heap. De heap memory is er namelijk voor om objecten, zoals de structures van de nodes van de linked list, in op te slaan. ### Activity 4: Appending and prepending elements Implement the two functions to append and prepend a new integer to the list, given by the following prototypes: ```c= void linkedlist_append(LinkedList *pList, int value) { pList->pTail = (struct LinkedListNode*)malloc(sizeof(struct LinkedListNode)); pList->pTail->value = value; pList->pTail->pNext = NULL; if(*pList->pHead->pNext == NULL){ pList->pTail->pPrevious = NULL; return; } } void linkedlist_prepend(LinkedList *pList, int value) { } ``` **Record your answer here:** ### Activity 5: Print the contents of a linked list **Record your answer here:** ```c= void linkedlist_print(const LinkedList *pList) { LinkedListNode *pCurrent = list->pHead; printf("["); if (pCurrent != NULL) { /* TODO: 1. print the value stored in the node referred to 8 by pCurrent. 9 2. make pCurrent refer to the next node. */ while (pCurrent != NULL) { /* TODO: 1. print a comma, followed by the value stored 14 in the node referred to by pCurrent 15 2. make pNode refer to the next node */ } } printf("]\n"); } ``` ### Activity 6: Element retrieval **Record your answer here:** ### Activity 7: The const keyword **Record your answer here:** De const kan handig zijn als je van te voren al weet dat de waarde van hetgene dat je initialiseerd, niet zal veranderen, mits er met pointer wordt gewerkt want dan kan het wel. ### Activity 8: Time complexity of retrieval **Record your answer here:** ### Activity 9: Implementing insertion **Record your answer here:** ### Activity 10: Linked lists and memory management **Record your answer here:** Het geheugen dat is gereserveerd per node zal, tijdens het verwijderen van de node zelf, ook verwijderd moeten worden om te zorgen dat het gereserveerde geuheugen gelijk blijft aan de hoeveelheid nodes die de lijst bezit. ### Activity 11: Implementation of removal **Record your answer here:** ### Activity 12: Implementing merge **Record your answer here:** ### Activity 13: Time complexity of merge **Record your answer here:** Hoe langer de lijsten worden, hoe meer tijd nodig is om beide lijsten samen te voegen omdat alle items die in de lijsten staan moeten worden verwerkt. ### Activity 14: Implementing sorted insert **Record your answer here:** ### Activity 15: Time complexity of sorted insert **Record your answer here:** Het plaatsen van een item in een linked list duurt langer omdat de pointers de hele lijst door moeten configureren voordat het item op de juiste plek kan komen te staan. Bij een array is dit niet het geval, hier kan een item er simpelweg gewoon tussen gezet worden. ## Look back ### What we've learnt Fill in... De verschillen tussen een array en een linked list de uses voor een linked list ### What were the surprises Fill in... ### What problems we've encountered Fill in... Activity 4: Het doorverwijzen naar de LinkedListNode ### What was or still is unclear Fill in... ### How did the group perform? How was the collaboration? What were the reasons for hick-ups? What worked well? What can be improved next time?

    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