Group week 3
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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
    • 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 Help
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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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 3 - Sorting and Searching ## Team Team name: Group 3 Date: 01-03-2021 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. |Cas Serrarens | | **Spokesperson** communicates group’s questions and problems to the teacher and talks to other teams; presents the group’s findings. |Raglan Pool | | **Reflector** observes and assesses the interactions and performance among team members. Provides positive feedback and intervenes with suggestions to improve groups’ processes. |Artem Tikhonov | | **Recorder** guides consensus building in the group by recording answers to questions. Collects important information and data. |Adriaan van Nes | ## Activities ### Activity 1: Purpose of sorted lists >"The main advantage is the time taken. The main benefit for an array to be sorted is that it gives a high level of certainty, because we are pretty much sure that the number to be searched is either to the right or left of a randomly selected number of the array sorted in ascending order, depending whether the searched element is greater or smaller than randomly selected number respectively. Then searching the number in only that part. And if the randomly selected number is itself the searched element then bingo, you got the number. Otherwise, continue the process until you are sure that the element does not exist." Reference: https://www.quora.com/What-is-the-advantage-of-searching-in-a-sorted-list-rather-than-in-an-unsorted-list Concrete cases: - Sorting population by age to identify 18+ citizens - Flights arrival and departure at the airport (sort by time) - Grades in school (sort who passed or level of IQ) - Sort playing cards in a deck ### Activity 2: Explanation of selection sort Watched : https://www.youtube.com/watch?v=xWBP4lzkoyM&feature=youtu.be&ab_channel=GeeksforGeeks ### Activity 3: Performance of selection - **How does the runtime of selection sort depend on the number of elements in the array?** Everytime you go through the array of elements, it takes the smallest number, creates a new array and stores it in the index + 1(apart from the first element) The runtime to do this will depend on the amount of elements in the array because the bigger the array, the more times you would have to loop through the array of elements. There wil also be additional runtime to create the new sorted array and add the elements in that array as well. - **How much time (roughly) will the algorithm need to sort a list of 2n or 4n elements?** Selection sort takes one millisecond to sort 1000 items (worst-case time) on a particular computer. This could be diffrent on another computer. In general: ==For an array with 2n elements, let n be 5, will take 2 times as long as the array n.== - **If you were to use a linked list instead of an array, would the performance be any different?** We don't think the performance would be any different. ### Activity 4: Implement selection sort ```c= void selectionSort(Data arr[], int n) { int i, j, min_idx; // One by one move boundary of unsorted subarray for (i = 0; i < n-1; i++) { // Find the minimum element in unsorted array min_idx = i; for (j = i+1; j < n; j++) if (arr[j].year < arr[min_idx].year) min_idx = j; // Swap the found minimum element with the first element swap(&arr[min_idx].year, &arr[i].year); } } ``` ### Activity 5: Explanation of merge sort Watched: https://www.youtube.com/watch?v=4VqmGXwpLqc&feature=youtu.be&ab_channel=MichaelSambol ### Activity 6: Merge sort - step by step |9|3|0|17|12|1|1|5|2|10|8|4|9|3|2| |-|-|-|-|-|-|-|-|-|-|-|-|-|-|-| |3-9||0-17||1-12||1-5||2-10||4-8||3-9||2-/| |0-3-9-17||1-1-5-12||2-4-8-10||2-3-9-/| |0-1-1-3-5-9-12-17||2-2-3-4-8-9-10-/| |0-1-1-2-2-3-3-4-5-8-9-9-10-12-17| ### Activity 7: Implement the merge function ```c= void merge(Data arr[], int l, int m, int r) { int i, j, k; int n1 = m - l + 1; int n2 = r - m; Data L[n1], R[n2]; for (i = 0; i < n1; i++) L[i].year = arr[l + i].year; for (j = 0; j < n2; j++) R[j].year = arr[m + 1 + j].year; i = 0; j = 0; k = l; while (i < n1 && j < n2) { if (L[i].year <= R[j].year) { arr[k].year = L[i].year; i++; } else { arr[k].year = R[j].year; j++; } k++; } while (i < n1) { arr[k].year = L[i].year; i++; k++; } while (j < n2) { arr[k].year = R[j].year; j++; k++; } } ``` ### Activity 8: Implement the divide-and-conquer algorithm ```c= void mergeSort(Data arr[], int l, int r) { if (l < r) { int m = l + (r - l) / 2; mergeSort(arr, l, m); mergeSort(arr, m + 1, r); merge(arr, l, m, r); } } ``` ### Activity 9: Test merge sort When looking at the code provided, we didn't really understand much of it. Therefor we created our own code and used the Spotify struct (years) to test our code and it worked. We randomly filled our songs array with years that the songs were released, then we used the merge sort to sort them in ascending order. This worked as expected. ### Activity 10: Binary search - step by step | Step 1 | Search range | Middle element | Discarded range | | -------- | -------- | -------- | -------- | | 1 | [0 ... 22) | 11 22 | [0 ... 11] | | 2 | [12 ... 22) | 17 55 | [12 ... 17] | | 3 | [18 ... 22) | 19 70 | [18 ... 19] | | 4 | [19 ... 22) | 20 75 | [19 ... 21] | ### Activity 11: Implement binary search ```c= int binarySearch(const Array *pArray, const Data *pValue) { int lpos = 0; int rpos = pArray->count; while (lpos < rpos) { int mid = (lpos + rpos) / 2; int ordering = compare(&pArray->values[mid], pValue); if (ordering > 0) { rpos = mid; } else if (ordering < 0) { lpos = mid; } else { return mid; } } return -1; } ``` ### Activity 12: Test binary search ### Activity 13: Time complexity ### Activity 14: Compare merge sort and selection sort ### Activity 15: Compare naive search and binary search ## Look back ### What we've learnt Cas: This week I've learned that you can divide and then combine arrays to sort them in a full array. Artem: This week, I have worked with arrays, sorting algorithms, and analyzing the benefits of sorted data. After this week I learned about sorting and merging two arrays. Also, I got some knowledge about the efficiency and advantages of these algorithms. ### What were the surprises Cas: I wasn't really surprised by this subject, rather excited that I learned how to merge 2 arrays Artem: I was surprised by the methodology of the binary search algorithm because, at the first time, it seems confusing, but after the key idea becomes pretty clear and logical. ### What problems we've encountered Cas: The problem I encountered is that the code that was provided was not really clear to me. Once i wrote the code myself it wazs easier to understand how to do it. Artem: I do not think that I can emphasize some problems, but I would like to say that the topic regarding Big O was interesting, but sometimes confusing for me at the same time. But I handled it because it was just struggling and unclarity in my understanding and I found a way, how to learn it. Thus, I managed to learn whole this information from this week. ### What was or still is unclear Cas: To me it is still unclear how to to the binary search and the Time complexity. I haven't worked on this part of the assignment this week. Artem: This week, I have worked with my parts of assignments and also, did everything for my personal development; Thus, I would say that I understand the whole of this knowledge base related to this week. ### 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? Cas: At the beginning of this week the whole group worked on activities 1-4. We decided that we should come together on Wednesday to finish the rest of the activities. Unfortunately, Adriaan was not there on Wednesday to work on the activities. Artem was there but was not actively participating when working on them. Raglan and I made activities 4-9 and told the other members of the group that is fair to let them do activities 10-13 and then do activities 14 and 15 when the other activites were done. At the time of writing (21-03-2020 at 21:00), the activites 10-13 are not completed. Therefor the oher activites remain incomplete as well. Artem: After the first meeting, the group was doing great. On Wednesday, when the first meeting was held, I struggled with understanding the organization of the group working process. That was not the group's fault, that was my misunderstanding. After the first meeting, I came up with a plan of what I can do by the end of the week and I successfully managed to complete my plan. I have partly worked on activities 1-4 and 10-13, but from the last activities, I uploaded in HackMD only 10-11 because the remaining part was expected from Adriaan. Also, on Sunday evening was planned a group meeting to solve the last problems (14-15), but unfortunately, the meeting was skipped and as a result, the 14-15 activates were not completed. In addition, I would like to say that the nice work was done by Cas and Raglan, and was sad to do not to get a response from Adriaan, I hope that he is doing well. I also would like to reflect on my actions as I am a reflector person. I would like to improve my management skill as sometimes I can struggle with organization, but talking about code writing, I think that I completed my assigned work and gain a lot of useful experience thanks to my team members.

    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