Write some questions in the form,
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.
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:
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.
A: Options:
– 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.)
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.
A: Array of arrays, or array of linked lists.
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.
Proving is trivial - provide the function between g1 edges to g2 edges (1081 jumpscare (literally a prerequisite))
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.
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
(O(n^2))
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
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.
Do you want to remove this version name and description?
Syncing