vault backup: 2023-11-10 17:46:05
This commit is contained in:
parent
670f0830c7
commit
c5cd7663f7
2 changed files with 70 additions and 7 deletions
14
.obsidian/workspace.json
vendored
14
.obsidian/workspace.json
vendored
|
@ -13,7 +13,7 @@
|
||||||
"state": {
|
"state": {
|
||||||
"type": "markdown",
|
"type": "markdown",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "4a1s/MFES/PL - Aula 1.md",
|
"file": "4a1s/MFES/PL - Aula 7.md",
|
||||||
"mode": "source",
|
"mode": "source",
|
||||||
"source": false
|
"source": false
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@
|
||||||
"state": {
|
"state": {
|
||||||
"type": "backlink",
|
"type": "backlink",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "4a1s/MFES/PL - Aula 1.md",
|
"file": "4a1s/MFES/PL - Aula 7.md",
|
||||||
"collapseAll": false,
|
"collapseAll": false,
|
||||||
"extraContext": false,
|
"extraContext": false,
|
||||||
"sortOrder": "alphabetical",
|
"sortOrder": "alphabetical",
|
||||||
|
@ -114,7 +114,7 @@
|
||||||
"state": {
|
"state": {
|
||||||
"type": "outgoing-link",
|
"type": "outgoing-link",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "4a1s/MFES/PL - Aula 1.md",
|
"file": "4a1s/MFES/PL - Aula 7.md",
|
||||||
"linksCollapsed": false,
|
"linksCollapsed": false,
|
||||||
"unlinkedCollapsed": true
|
"unlinkedCollapsed": true
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@
|
||||||
"state": {
|
"state": {
|
||||||
"type": "outline",
|
"type": "outline",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "4a1s/MFES/PL - Aula 1.md"
|
"file": "4a1s/MFES/PL - Aula 7.md"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -170,8 +170,10 @@
|
||||||
"digitalgarden:Digital Garden Publication Center": false
|
"digitalgarden:Digital Garden Publication Center": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"active": "3ca14d4a6c304083",
|
"active": "9853b375f7893cb9",
|
||||||
"lastOpenFiles": [
|
"lastOpenFiles": [
|
||||||
|
"4a1s/index.md",
|
||||||
|
"4a1s/MFES/PL - Aula 1.md",
|
||||||
"4a1s/MFES/PL - Aula 7.md",
|
"4a1s/MFES/PL - Aula 7.md",
|
||||||
"4a1s/MFES/PL - Aula 6.md",
|
"4a1s/MFES/PL - Aula 6.md",
|
||||||
"4a1s/DAA/PL - Project.md",
|
"4a1s/DAA/PL - Project.md",
|
||||||
|
@ -197,8 +199,6 @@
|
||||||
"Excalidraw/Drawing 2023-10-25 12.16.38.excalidraw.md",
|
"Excalidraw/Drawing 2023-10-25 12.16.38.excalidraw.md",
|
||||||
"4a1s/MFES/PL - Aula 3.md",
|
"4a1s/MFES/PL - Aula 3.md",
|
||||||
"4a1s/MFES/PL - Aula 4.md",
|
"4a1s/MFES/PL - Aula 4.md",
|
||||||
"4a1s/MFES/PL - Aula 1.md",
|
|
||||||
"4a1s/RAS/Notas Projeto RAS.md",
|
|
||||||
"Images/Pasted image 20231018121319.png",
|
"Images/Pasted image 20231018121319.png",
|
||||||
"Images/Pasted image 20231018120412.png",
|
"Images/Pasted image 20231018120412.png",
|
||||||
"Images/Pasted image 20231018120219.png",
|
"Images/Pasted image 20231018120219.png",
|
||||||
|
|
|
@ -69,3 +69,66 @@ pred insert[n : Node] {
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
//Solved
|
||||||
|
```c
|
||||||
|
// Recall the hash table Alloy model,
|
||||||
|
// now with mutable lists inside the buckets.
|
||||||
|
|
||||||
|
sig Bucket {
|
||||||
|
var head : lone Node
|
||||||
|
}
|
||||||
|
sig Node {
|
||||||
|
key : one Key,
|
||||||
|
var prox : lone Node
|
||||||
|
}
|
||||||
|
sig Key {
|
||||||
|
hash : one Hash
|
||||||
|
}
|
||||||
|
sig Hash {}
|
||||||
|
|
||||||
|
// Specify the operation of inserting a node
|
||||||
|
// in the hash table. The node should be
|
||||||
|
// inserted at the head of a bucket.
|
||||||
|
// If the operation only works well when the
|
||||||
|
// hash of the new node does not exist in the
|
||||||
|
// table you get Two points. If it always
|
||||||
|
// works well you get Five points. Use the
|
||||||
|
// respective commands to check how many
|
||||||
|
// points you have.
|
||||||
|
|
||||||
|
pred nodeToHead[n : Node]{
|
||||||
|
//node not in hash
|
||||||
|
n.key.hash not in Bucket.head.key.hash
|
||||||
|
|
||||||
|
some b : Bucket | {
|
||||||
|
b.head= none and b.head' = n //put node in the head
|
||||||
|
all x : Bucket - b | x.head' = x.head //everything remains the same
|
||||||
|
all y : Node | y.prox' = y.prox //all nodes remain the same
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pred nodeToTail[n: Node]{
|
||||||
|
//node not in linked lists of buckets
|
||||||
|
n not in Bucket.head.*prox
|
||||||
|
|
||||||
|
//node in hash
|
||||||
|
n.key.hash in Bucket.head.key.hash
|
||||||
|
|
||||||
|
some b : Bucket | {
|
||||||
|
b.head.key.hash = n.key.hash and { //same hash
|
||||||
|
(b.head' = n and n.prox' = b.head) //new head
|
||||||
|
all x : Bucket - b | x.head' = x.head //all other buckets remain the same
|
||||||
|
all y : Node - n | y.prox' = y.prox //all other nodes remain the same
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pred insert[n : Node] {
|
||||||
|
nodeToHead[n] or nodeToTail [n]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
http://alloy4fun.inesctec.pt/mnvLbxeXWRuhsnQSd
|
||||||
|
|
Loading…
Add table
Reference in a new issue