Sim Mautner
    • 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
    • Engagement control
    • 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 Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control 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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ## Types of questions: Write some questions in the form, * "given this data, which data type to use" * "if an algorithm produced this from this, which algorithm was used / how could you figure out which was used" ## Questions with Proposed Answers #### Q: Compare and contrast a heap and and array. A: A heap can be implemented using an array. An array is a contiguous block of data, indexed from 0. An array can be ordered, unordered etc, depending on its use. Each element in the array must be of the same data type. Arrays can be used to store data with a range of purposes. A heap on the other hand, whether implemented in an array (draw a picture here) or as a linked data type, must follow the "heap property" (that each element must be greater priority (for a max heap) than either of its children) and the "completeness property" (that when displayed as a tree, is filled row by row, left to right without skipping any spots). A heap is used to store data where we want to access/remove items with the highest (for max heap) priority first (or more often) than the items with lower priority. #### Q: Can we implement a heap by linked list or bst? A: Yes. In class, we looked at visual representations of implementing it as a tree. While you technically can implement it in a linked list or tree, unless you have another reason to do so, it is unadvised as implementing it as an array has the following advantages: 1. Quick movement up and down the tree (parent = n/2 and child = 2n and 2n+1). (Linked list would take too long) 2. Finding "the next empty spot to put a new element so that we maintain the completeness of the tree" is significantly harder in a tree than in an array. (Tree would take too long.) #### Q: cycle checking in graphs - is Kruskal's practical? A: In order to implement Kruskal's, you need to either, check for cycles after adding each edge (and remove it if there is a cycle) or check if there exists a path between two nodes before putting in an edge. So you need cycle checking (or similar) in order to implement Kruskal's. #### Q: but isn't cycle checking slow/expensive compared to Prims A: Options: * Do the "does a path already exist" by maintaining the matrix produced by Warshall's algorithm for our MST graph as it's being built (and update it everytime we add an edge). * Using this data structure and algorithm, we can more efficiently keep track of which verticies are currently connected to each other: https://cmps-people.ok.ubc.ca/ylucet/DS/Kruskal.html #### Q: For situations such as if we're checking if a path exists a lot as justification for Warshall's, how do we know breakpoints? (or is it just by feel) -- Please elaborate. Warshall's is pretty amazing if we don't have many changes to the graph, and just want to see if you can get from A to B. (Eg roads in a city - new roads are rare, and for just one change, iirc isn't too costly to update). Or are you asking about situations where there are lots of changes, with rare questions about paths? I'm asking like at a baseline Warshall's isn't good (if you never actually check whether there's a path), but the more times you check whether there's a path the better it becomes compared to alternatives. So should we have a feel of at what point an algorithm can become better than another. A: Yes, you'd have some idea based on the data. In my limited experience it's usually quite clear whether you're doing mostly updating with very little asking about paths, or more asking about paths. (If asking about paths is a core, often repeated, part of the process.) #### Q: Why doesn't Dijkstra's work with negative edge weights --- any way to fix this, or out of scope for 2521 ![Screenshot 2024-08-01 at 11.53.51 AM](https://hackmd.io/_uploads/Hy-p9wOtR.png) A: Out of scope for 2521. For your own interest and learning, you can see the end of the slides about Dijkstra's algorithm for a list of similar algorithms, some of which handle negative weights. #### Q: Not theory but how should we implement the bucket in radix sort? A: Array of arrays, or array of linked lists. #### Q: Is there a good way to turn a sorted list into a BST? like a reverse in-order traversal A: Off the top of my head, if you know your list is sorted (or near sorted) reference elements in the same order they'd be checked in a binary search and insert them into your tree in that order. This would give you the most balanced tree possible without requiring re-balancing. #### Q: Is there a decent way to check if two graphs are isomorphic 🧌 lmao yeah and even harder figuring out the isomorphism itself ![image](https://hackmd.io/_uploads/r1-OCwOtA.png) Proving is trivial - provide the function between g1 edges to g2 edges (1081 jumpscare (literally a prerequisite)) #### Q: When is a double pointer used in coding? Like why do we use a double pointer for a predecessor array? ![Screenshot 2024-08-01 at 12.21.46 PM](https://hackmd.io/_uploads/B1DBZd_t0.png) #### Q: what is the optimal wordle solving data structure (very hard) I was thinking start with a trie, but you'd also want to sacrifice using some letters you know in exchange for more letters. yeah ai Trie - lacks power because knowing "the third letter is r", means a lot of work within your trie. Data analysis on which words contain the most common letters. Maybe some data analysis on which letters are most commonly found in which elements (position) of the word. #### Q: What is the final question of the exam (impossible) A: 1 + 1 = ? (Solve in at most O(n^2) time) Fib algorithm in O(1) time (hint precompute all the values) isn't there a formula and you just round nah pow is O(log n) int fib(int i) { return [0, 1, 1, ...][i]; // only 30 or so <= MAX_INT // return infinity if out of range } i reckon we do this ![image](https://hackmd.io/_uploads/SkwN4OutR.png) (O(n^2))

    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