mirror of
https://github.com/BreizhHardware/cours-ISEN-MD.git
synced 2026-03-18 21:50:46 +01:00
Obisidian vault auto-backup: 03-03-2025 07:41:57 on . 277 files edited
This commit is contained in:
@@ -1,121 +1,121 @@
|
||||
`````C
|
||||
mergeSort(array, left, right){ (left = left index of the array, right = right index of the array)
|
||||
if left > right{
|
||||
return
|
||||
}
|
||||
middle = (left+right) / 2
|
||||
mergeSort(array, left, mid) T(n/2)
|
||||
mergeSort(array, mid+1, right) T(n/2)
|
||||
merge(array, left, mid, right) M(n)
|
||||
}
|
||||
``````
|
||||
|
||||
|
||||
`````C
|
||||
merge(array, left, mid, right){
|
||||
n1 = mid - left + 1
|
||||
n2 = right - mid
|
||||
leftArray[n1]
|
||||
rightArray[n2]
|
||||
for i = 0 to n1 - 1{
|
||||
leftArray[i] = array[left + i]
|
||||
}
|
||||
for j = 0 to n2 - 1{
|
||||
rightArray[j] = array[mid + 1 + j]
|
||||
}
|
||||
i = 0
|
||||
j = 0
|
||||
k = left
|
||||
|
||||
while i < n1 and j < n2{
|
||||
if leftArray[i] <= rightArray[j]{
|
||||
array[k] = leftArray[i]
|
||||
i = i + 1
|
||||
}
|
||||
else{
|
||||
array[k] = rightArray[j]
|
||||
j = j + 1
|
||||
}
|
||||
k = k + 1
|
||||
}
|
||||
|
||||
while i < n1{
|
||||
array[k] = leftArray[i]
|
||||
i = i + 1
|
||||
k = k + 1
|
||||
}
|
||||
|
||||
while j < n2{
|
||||
array[k] = rightArray[j]
|
||||
j = j + 1
|
||||
k = k + 1
|
||||
}
|
||||
}
|
||||
`````
|
||||
|
||||
````C
|
||||
T(N) = 2 * T(N/2) + M(N) = 2 * T(N/2) + constant * N
|
||||
|
||||
……
|
||||
|
||||
= 2^k * T(N/2^k) + k * N * constant with k = number of sub array
|
||||
|
||||
= N * T(1) + N * log(N) * constant
|
||||
|
||||
= N + N * log(N)
|
||||
|
||||
= N * log(N)
|
||||
|
||||
````
|
||||
|
||||
````C
|
||||
BubbleSort (array, size){SS
|
||||
O(n)for int = 1 to size{
|
||||
O(n)for j = 0 to size -1{
|
||||
if array[j] > array[j+1]{
|
||||
swap(array[j], array[j+1])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
````C
|
||||
swap (elemA, elemB){
|
||||
var = elemA
|
||||
elemA = elemB
|
||||
elemB = var
|
||||
}
|
||||
````
|
||||
|
||||
````C
|
||||
Counter = {0} * k
|
||||
|
||||
execution time: k (initialization of all the values from the counter to zero, to begin counting at 0)
|
||||
````
|
||||
|
||||
````C
|
||||
for (i=0; i < array size ; i++){
|
||||
counter ++
|
||||
}
|
||||
|
||||
execution time: n (size of the array)
|
||||
````
|
||||
|
||||
````C
|
||||
for (i=0; i < k; i++){
|
||||
for (j=0; j < number of letter counted; j++){
|
||||
array[index] = i;
|
||||
}
|
||||
}
|
||||
execution time: k + n, the first for repeat k time, for each assume value. And there is only n number how’s been counted.
|
||||
````
|
||||
|
||||
````C
|
||||
T(n) = k + n + n + k
|
||||
O(n) = n + k
|
||||
````
|
||||
|
||||
[[TP1 Exercice 1.canvas|TP1 Exercice 1]]
|
||||
[[MergeSort.png]]
|
||||
[[MergeSort.canvas|MergeSort]]
|
||||
`````C
|
||||
mergeSort(array, left, right){ (left = left index of the array, right = right index of the array)
|
||||
if left > right{
|
||||
return
|
||||
}
|
||||
middle = (left+right) / 2
|
||||
mergeSort(array, left, mid) T(n/2)
|
||||
mergeSort(array, mid+1, right) T(n/2)
|
||||
merge(array, left, mid, right) M(n)
|
||||
}
|
||||
``````
|
||||
|
||||
|
||||
`````C
|
||||
merge(array, left, mid, right){
|
||||
n1 = mid - left + 1
|
||||
n2 = right - mid
|
||||
leftArray[n1]
|
||||
rightArray[n2]
|
||||
for i = 0 to n1 - 1{
|
||||
leftArray[i] = array[left + i]
|
||||
}
|
||||
for j = 0 to n2 - 1{
|
||||
rightArray[j] = array[mid + 1 + j]
|
||||
}
|
||||
i = 0
|
||||
j = 0
|
||||
k = left
|
||||
|
||||
while i < n1 and j < n2{
|
||||
if leftArray[i] <= rightArray[j]{
|
||||
array[k] = leftArray[i]
|
||||
i = i + 1
|
||||
}
|
||||
else{
|
||||
array[k] = rightArray[j]
|
||||
j = j + 1
|
||||
}
|
||||
k = k + 1
|
||||
}
|
||||
|
||||
while i < n1{
|
||||
array[k] = leftArray[i]
|
||||
i = i + 1
|
||||
k = k + 1
|
||||
}
|
||||
|
||||
while j < n2{
|
||||
array[k] = rightArray[j]
|
||||
j = j + 1
|
||||
k = k + 1
|
||||
}
|
||||
}
|
||||
`````
|
||||
|
||||
````C
|
||||
T(N) = 2 * T(N/2) + M(N) = 2 * T(N/2) + constant * N
|
||||
|
||||
……
|
||||
|
||||
= 2^k * T(N/2^k) + k * N * constant with k = number of sub array
|
||||
|
||||
= N * T(1) + N * log(N) * constant
|
||||
|
||||
= N + N * log(N)
|
||||
|
||||
= N * log(N)
|
||||
|
||||
````
|
||||
|
||||
````C
|
||||
BubbleSort (array, size){SS
|
||||
O(n)for int = 1 to size{
|
||||
O(n)for j = 0 to size -1{
|
||||
if array[j] > array[j+1]{
|
||||
swap(array[j], array[j+1])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
````C
|
||||
swap (elemA, elemB){
|
||||
var = elemA
|
||||
elemA = elemB
|
||||
elemB = var
|
||||
}
|
||||
````
|
||||
|
||||
````C
|
||||
Counter = {0} * k
|
||||
|
||||
execution time: k (initialization of all the values from the counter to zero, to begin counting at 0)
|
||||
````
|
||||
|
||||
````C
|
||||
for (i=0; i < array size ; i++){
|
||||
counter ++
|
||||
}
|
||||
|
||||
execution time: n (size of the array)
|
||||
````
|
||||
|
||||
````C
|
||||
for (i=0; i < k; i++){
|
||||
for (j=0; j < number of letter counted; j++){
|
||||
array[index] = i;
|
||||
}
|
||||
}
|
||||
execution time: k + n, the first for repeat k time, for each assume value. And there is only n number how’s been counted.
|
||||
````
|
||||
|
||||
````C
|
||||
T(n) = k + n + n + k
|
||||
O(n) = n + k
|
||||
````
|
||||
|
||||
[[TP1 Exercice 1.canvas|TP1 Exercice 1]]
|
||||
[[MergeSort.png]]
|
||||
[[MergeSort.canvas|MergeSort]]
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
{
|
||||
"nodes":[
|
||||
{"id":"b5ecbf33e954f875","type":"text","text":"6","x":-320,"y":-300,"width":50,"height":60},
|
||||
{"id":"a7489c9702ace3cf","type":"text","text":"5","x":-270,"y":-300,"width":50,"height":60},
|
||||
{"id":"2f0ee0913bf89e0a","type":"text","text":"12","x":-220,"y":-300,"width":100,"height":60},
|
||||
{"id":"d6be9ee5420668f5","type":"text","text":"10","x":-170,"y":-300,"width":90,"height":60},
|
||||
{"id":"c62924c74ff6bd9c","type":"text","text":"9","x":-105,"y":-300,"width":50,"height":60},
|
||||
{"id":"53421aad21e85a95","type":"text","text":"1","x":-55,"y":-300,"width":50,"height":60},
|
||||
{"id":"10ba9122739f5ddd","type":"text","text":"6","x":-445,"y":-190,"width":50,"height":60},
|
||||
{"id":"41bc693b0d422b93","type":"text","text":"5","x":-395,"y":-190,"width":50,"height":60},
|
||||
{"id":"a17b159e1b68f8b9","type":"text","text":"12","x":-345,"y":-190,"width":100,"height":60},
|
||||
{"id":"bd69b058611e3e4e","type":"text","text":"10","x":-55,"y":-190,"width":90,"height":60},
|
||||
{"id":"94952cb4752a756b","type":"text","text":"9","x":10,"y":-190,"width":50,"height":60},
|
||||
{"id":"a3315273c9c3ab28","type":"text","text":"1","x":60,"y":-190,"width":50,"height":60},
|
||||
{"id":"fe8bded59a48af6d","type":"text","text":"6","x":-495,"y":-60,"width":50,"height":60},
|
||||
{"id":"3ef5e98f314be6a0","type":"text","text":"5","x":-370,"y":-60,"width":50,"height":60},
|
||||
{"id":"5e02e52ef3991413","type":"text","text":"12","x":-320,"y":-60,"width":100,"height":60},
|
||||
{"id":"5b4fb077c56f069c","type":"text","text":"5","x":-395,"y":80,"width":50,"height":60},
|
||||
{"id":"67ac9af31942e246","type":"text","text":"12","x":-245,"y":80,"width":100,"height":60},
|
||||
{"id":"2c8438f0869ddff3","type":"text","text":"6","x":-495,"y":80,"width":50,"height":60},
|
||||
{"id":"f64cfa141ef3ea2c","type":"text","text":"5","x":-370,"y":220,"width":50,"height":60},
|
||||
{"id":"481c876791968810","type":"text","text":"12","x":-320,"y":220,"width":100,"height":60},
|
||||
{"id":"442301a2fc475728","type":"text","text":"6","x":-495,"y":220,"width":50,"height":60},
|
||||
{"id":"a5ec4eb6277c027e","type":"text","text":"5","x":-445,"y":380,"width":50,"height":60},
|
||||
{"id":"3264819363da9d39","type":"text","text":"6","x":-395,"y":380,"width":50,"height":60},
|
||||
{"id":"c735d7f652b9411f","type":"text","text":"12","x":-345,"y":380,"width":100,"height":60},
|
||||
{"id":"31150198b70d8c1f","type":"text","text":"10","x":-55,"y":-60,"width":90,"height":60},
|
||||
{"id":"88cc7342c10feeb0","type":"text","text":"10","x":-55,"y":80,"width":90,"height":60},
|
||||
{"id":"c289b0627efbceb6","type":"text","text":"10","x":-55,"y":220,"width":90,"height":60},
|
||||
{"id":"4b4451abb50ed86b","type":"text","text":"9","x":140,"y":-60,"width":50,"height":60},
|
||||
{"id":"10c0264177e8f975","type":"text","text":"1","x":190,"y":-60,"width":50,"height":60},
|
||||
{"id":"5bf01a505a245357","type":"text","text":"9","x":115,"y":80,"width":50,"height":60},
|
||||
{"id":"92e75ec2709bfad3","type":"text","text":"1","x":240,"y":80,"width":50,"height":60},
|
||||
{"id":"1fbde60416c0bafa","type":"text","text":"9","x":190,"y":220,"width":50,"height":60},
|
||||
{"id":"2c5beeeced9ff053","type":"text","text":"1","x":140,"y":220,"width":50,"height":60},
|
||||
{"id":"b4d443cf3670a80e","type":"text","text":"9","x":-5,"y":380,"width":50,"height":60},
|
||||
{"id":"aa0699a44cd00658","type":"text","text":"1","x":-55,"y":380,"width":50,"height":60},
|
||||
{"id":"6c14861f60092bd7","type":"text","text":"10","x":45,"y":380,"width":90,"height":60},
|
||||
{"id":"d7e22b6a659a0b74","type":"text","text":"1","x":-320,"y":540,"width":50,"height":60},
|
||||
{"id":"899146e54236296a","type":"text","text":"5","x":-270,"y":540,"width":50,"height":60},
|
||||
{"id":"7d5d0ac080ee7290","type":"text","text":"6","x":-220,"y":540,"width":50,"height":60},
|
||||
{"id":"9fe17f4ffac0c8ab","type":"text","text":"9","x":-170,"y":540,"width":50,"height":60},
|
||||
{"id":"6ba04fc4ed856eaa","type":"text","text":"10","x":-120,"y":540,"width":90,"height":60},
|
||||
{"id":"dd916430cd46a533","type":"text","text":"12","x":-60,"y":540,"width":100,"height":60}
|
||||
],
|
||||
"edges":[
|
||||
{"id":"e58fe25dd4af461e","fromNode":"a7489c9702ace3cf","fromSide":"bottom","toNode":"41bc693b0d422b93","toSide":"top"},
|
||||
{"id":"164e866c5e5d1e1a","fromNode":"c62924c74ff6bd9c","fromSide":"bottom","toNode":"94952cb4752a756b","toSide":"top"},
|
||||
{"id":"a6d35695fb6d404f","fromNode":"41bc693b0d422b93","fromSide":"bottom","toNode":"fe8bded59a48af6d","toSide":"top"},
|
||||
{"id":"e9977eec70e0918f","fromNode":"41bc693b0d422b93","fromSide":"bottom","toNode":"5e02e52ef3991413","toSide":"top"},
|
||||
{"id":"5d24d471b4600241","fromNode":"fe8bded59a48af6d","fromSide":"bottom","toNode":"2c8438f0869ddff3","toSide":"top"},
|
||||
{"id":"f03cec5fa8787ec9","fromNode":"2c8438f0869ddff3","fromSide":"bottom","toNode":"442301a2fc475728","toSide":"top"},
|
||||
{"id":"e2c8cd6338ddff14","fromNode":"442301a2fc475728","fromSide":"bottom","toNode":"3264819363da9d39","toSide":"top"},
|
||||
{"id":"d8da625cb4bce70c","fromNode":"3ef5e98f314be6a0","fromSide":"bottom","toNode":"5b4fb077c56f069c","toSide":"top"},
|
||||
{"id":"fdf5fa6aaf155731","fromNode":"5e02e52ef3991413","fromSide":"bottom","toNode":"67ac9af31942e246","toSide":"top"},
|
||||
{"id":"a852b01d9da4aebb","fromNode":"5b4fb077c56f069c","fromSide":"bottom","toNode":"f64cfa141ef3ea2c","toSide":"top"},
|
||||
{"id":"052fe7ccd7f8bfed","fromNode":"67ac9af31942e246","fromSide":"bottom","toNode":"f64cfa141ef3ea2c","toSide":"top"},
|
||||
{"id":"4c40bf09c364772b","fromNode":"481c876791968810","fromSide":"bottom","toNode":"3264819363da9d39","toSide":"top"},
|
||||
{"id":"8ece6dcdbb62253a","fromNode":"3264819363da9d39","fromSide":"bottom","toNode":"9fe17f4ffac0c8ab","toSide":"top"},
|
||||
{"id":"08d9dce62754acc2","fromNode":"94952cb4752a756b","fromSide":"bottom","toNode":"31150198b70d8c1f","toSide":"top"},
|
||||
{"id":"619d04deb7ba485f","fromNode":"94952cb4752a756b","fromSide":"bottom","toNode":"4b4451abb50ed86b","toSide":"top"},
|
||||
{"id":"85b807df1c63da4a","fromNode":"31150198b70d8c1f","fromSide":"bottom","toNode":"88cc7342c10feeb0","toSide":"top"},
|
||||
{"id":"6dd422de767f2810","fromNode":"c289b0627efbceb6","fromSide":"bottom","toNode":"b4d443cf3670a80e","toSide":"top"},
|
||||
{"id":"d7d53546e8dffbc1","fromNode":"4b4451abb50ed86b","fromSide":"bottom","toNode":"5bf01a505a245357","toSide":"top"},
|
||||
{"id":"990eae9f88be03c2","fromNode":"4b4451abb50ed86b","fromSide":"bottom","toNode":"92e75ec2709bfad3","toSide":"top"},
|
||||
{"id":"b56e4df4db1d2b4a","fromNode":"5bf01a505a245357","fromSide":"bottom","toNode":"2c5beeeced9ff053","toSide":"top"},
|
||||
{"id":"507cde8b3ac55c26","fromNode":"92e75ec2709bfad3","fromSide":"bottom","toNode":"2c5beeeced9ff053","toSide":"top"},
|
||||
{"id":"3d94792d94dbc02c","fromNode":"2c5beeeced9ff053","fromSide":"bottom","toNode":"b4d443cf3670a80e","toSide":"top"},
|
||||
{"id":"a592ae78e7de07ab","fromNode":"b4d443cf3670a80e","fromSide":"bottom","toNode":"9fe17f4ffac0c8ab","toSide":"top"},
|
||||
{"id":"41a32aa08b689eb8","fromNode":"88cc7342c10feeb0","fromSide":"bottom","toNode":"c289b0627efbceb6","toSide":"top"}
|
||||
]
|
||||
{
|
||||
"nodes":[
|
||||
{"id":"b5ecbf33e954f875","type":"text","text":"6","x":-320,"y":-300,"width":50,"height":60},
|
||||
{"id":"a7489c9702ace3cf","type":"text","text":"5","x":-270,"y":-300,"width":50,"height":60},
|
||||
{"id":"2f0ee0913bf89e0a","type":"text","text":"12","x":-220,"y":-300,"width":100,"height":60},
|
||||
{"id":"d6be9ee5420668f5","type":"text","text":"10","x":-170,"y":-300,"width":90,"height":60},
|
||||
{"id":"c62924c74ff6bd9c","type":"text","text":"9","x":-105,"y":-300,"width":50,"height":60},
|
||||
{"id":"53421aad21e85a95","type":"text","text":"1","x":-55,"y":-300,"width":50,"height":60},
|
||||
{"id":"10ba9122739f5ddd","type":"text","text":"6","x":-445,"y":-190,"width":50,"height":60},
|
||||
{"id":"41bc693b0d422b93","type":"text","text":"5","x":-395,"y":-190,"width":50,"height":60},
|
||||
{"id":"a17b159e1b68f8b9","type":"text","text":"12","x":-345,"y":-190,"width":100,"height":60},
|
||||
{"id":"bd69b058611e3e4e","type":"text","text":"10","x":-55,"y":-190,"width":90,"height":60},
|
||||
{"id":"94952cb4752a756b","type":"text","text":"9","x":10,"y":-190,"width":50,"height":60},
|
||||
{"id":"a3315273c9c3ab28","type":"text","text":"1","x":60,"y":-190,"width":50,"height":60},
|
||||
{"id":"fe8bded59a48af6d","type":"text","text":"6","x":-495,"y":-60,"width":50,"height":60},
|
||||
{"id":"3ef5e98f314be6a0","type":"text","text":"5","x":-370,"y":-60,"width":50,"height":60},
|
||||
{"id":"5e02e52ef3991413","type":"text","text":"12","x":-320,"y":-60,"width":100,"height":60},
|
||||
{"id":"5b4fb077c56f069c","type":"text","text":"5","x":-395,"y":80,"width":50,"height":60},
|
||||
{"id":"67ac9af31942e246","type":"text","text":"12","x":-245,"y":80,"width":100,"height":60},
|
||||
{"id":"2c8438f0869ddff3","type":"text","text":"6","x":-495,"y":80,"width":50,"height":60},
|
||||
{"id":"f64cfa141ef3ea2c","type":"text","text":"5","x":-370,"y":220,"width":50,"height":60},
|
||||
{"id":"481c876791968810","type":"text","text":"12","x":-320,"y":220,"width":100,"height":60},
|
||||
{"id":"442301a2fc475728","type":"text","text":"6","x":-495,"y":220,"width":50,"height":60},
|
||||
{"id":"a5ec4eb6277c027e","type":"text","text":"5","x":-445,"y":380,"width":50,"height":60},
|
||||
{"id":"3264819363da9d39","type":"text","text":"6","x":-395,"y":380,"width":50,"height":60},
|
||||
{"id":"c735d7f652b9411f","type":"text","text":"12","x":-345,"y":380,"width":100,"height":60},
|
||||
{"id":"31150198b70d8c1f","type":"text","text":"10","x":-55,"y":-60,"width":90,"height":60},
|
||||
{"id":"88cc7342c10feeb0","type":"text","text":"10","x":-55,"y":80,"width":90,"height":60},
|
||||
{"id":"c289b0627efbceb6","type":"text","text":"10","x":-55,"y":220,"width":90,"height":60},
|
||||
{"id":"4b4451abb50ed86b","type":"text","text":"9","x":140,"y":-60,"width":50,"height":60},
|
||||
{"id":"10c0264177e8f975","type":"text","text":"1","x":190,"y":-60,"width":50,"height":60},
|
||||
{"id":"5bf01a505a245357","type":"text","text":"9","x":115,"y":80,"width":50,"height":60},
|
||||
{"id":"92e75ec2709bfad3","type":"text","text":"1","x":240,"y":80,"width":50,"height":60},
|
||||
{"id":"1fbde60416c0bafa","type":"text","text":"9","x":190,"y":220,"width":50,"height":60},
|
||||
{"id":"2c5beeeced9ff053","type":"text","text":"1","x":140,"y":220,"width":50,"height":60},
|
||||
{"id":"b4d443cf3670a80e","type":"text","text":"9","x":-5,"y":380,"width":50,"height":60},
|
||||
{"id":"aa0699a44cd00658","type":"text","text":"1","x":-55,"y":380,"width":50,"height":60},
|
||||
{"id":"6c14861f60092bd7","type":"text","text":"10","x":45,"y":380,"width":90,"height":60},
|
||||
{"id":"d7e22b6a659a0b74","type":"text","text":"1","x":-320,"y":540,"width":50,"height":60},
|
||||
{"id":"899146e54236296a","type":"text","text":"5","x":-270,"y":540,"width":50,"height":60},
|
||||
{"id":"7d5d0ac080ee7290","type":"text","text":"6","x":-220,"y":540,"width":50,"height":60},
|
||||
{"id":"9fe17f4ffac0c8ab","type":"text","text":"9","x":-170,"y":540,"width":50,"height":60},
|
||||
{"id":"6ba04fc4ed856eaa","type":"text","text":"10","x":-120,"y":540,"width":90,"height":60},
|
||||
{"id":"dd916430cd46a533","type":"text","text":"12","x":-60,"y":540,"width":100,"height":60}
|
||||
],
|
||||
"edges":[
|
||||
{"id":"e58fe25dd4af461e","fromNode":"a7489c9702ace3cf","fromSide":"bottom","toNode":"41bc693b0d422b93","toSide":"top"},
|
||||
{"id":"164e866c5e5d1e1a","fromNode":"c62924c74ff6bd9c","fromSide":"bottom","toNode":"94952cb4752a756b","toSide":"top"},
|
||||
{"id":"a6d35695fb6d404f","fromNode":"41bc693b0d422b93","fromSide":"bottom","toNode":"fe8bded59a48af6d","toSide":"top"},
|
||||
{"id":"e9977eec70e0918f","fromNode":"41bc693b0d422b93","fromSide":"bottom","toNode":"5e02e52ef3991413","toSide":"top"},
|
||||
{"id":"5d24d471b4600241","fromNode":"fe8bded59a48af6d","fromSide":"bottom","toNode":"2c8438f0869ddff3","toSide":"top"},
|
||||
{"id":"f03cec5fa8787ec9","fromNode":"2c8438f0869ddff3","fromSide":"bottom","toNode":"442301a2fc475728","toSide":"top"},
|
||||
{"id":"e2c8cd6338ddff14","fromNode":"442301a2fc475728","fromSide":"bottom","toNode":"3264819363da9d39","toSide":"top"},
|
||||
{"id":"d8da625cb4bce70c","fromNode":"3ef5e98f314be6a0","fromSide":"bottom","toNode":"5b4fb077c56f069c","toSide":"top"},
|
||||
{"id":"fdf5fa6aaf155731","fromNode":"5e02e52ef3991413","fromSide":"bottom","toNode":"67ac9af31942e246","toSide":"top"},
|
||||
{"id":"a852b01d9da4aebb","fromNode":"5b4fb077c56f069c","fromSide":"bottom","toNode":"f64cfa141ef3ea2c","toSide":"top"},
|
||||
{"id":"052fe7ccd7f8bfed","fromNode":"67ac9af31942e246","fromSide":"bottom","toNode":"f64cfa141ef3ea2c","toSide":"top"},
|
||||
{"id":"4c40bf09c364772b","fromNode":"481c876791968810","fromSide":"bottom","toNode":"3264819363da9d39","toSide":"top"},
|
||||
{"id":"8ece6dcdbb62253a","fromNode":"3264819363da9d39","fromSide":"bottom","toNode":"9fe17f4ffac0c8ab","toSide":"top"},
|
||||
{"id":"08d9dce62754acc2","fromNode":"94952cb4752a756b","fromSide":"bottom","toNode":"31150198b70d8c1f","toSide":"top"},
|
||||
{"id":"619d04deb7ba485f","fromNode":"94952cb4752a756b","fromSide":"bottom","toNode":"4b4451abb50ed86b","toSide":"top"},
|
||||
{"id":"85b807df1c63da4a","fromNode":"31150198b70d8c1f","fromSide":"bottom","toNode":"88cc7342c10feeb0","toSide":"top"},
|
||||
{"id":"6dd422de767f2810","fromNode":"c289b0627efbceb6","fromSide":"bottom","toNode":"b4d443cf3670a80e","toSide":"top"},
|
||||
{"id":"d7d53546e8dffbc1","fromNode":"4b4451abb50ed86b","fromSide":"bottom","toNode":"5bf01a505a245357","toSide":"top"},
|
||||
{"id":"990eae9f88be03c2","fromNode":"4b4451abb50ed86b","fromSide":"bottom","toNode":"92e75ec2709bfad3","toSide":"top"},
|
||||
{"id":"b56e4df4db1d2b4a","fromNode":"5bf01a505a245357","fromSide":"bottom","toNode":"2c5beeeced9ff053","toSide":"top"},
|
||||
{"id":"507cde8b3ac55c26","fromNode":"92e75ec2709bfad3","fromSide":"bottom","toNode":"2c5beeeced9ff053","toSide":"top"},
|
||||
{"id":"3d94792d94dbc02c","fromNode":"2c5beeeced9ff053","fromSide":"bottom","toNode":"b4d443cf3670a80e","toSide":"top"},
|
||||
{"id":"a592ae78e7de07ab","fromNode":"b4d443cf3670a80e","fromSide":"bottom","toNode":"9fe17f4ffac0c8ab","toSide":"top"},
|
||||
{"id":"41a32aa08b689eb8","fromNode":"88cc7342c10feeb0","fromSide":"bottom","toNode":"c289b0627efbceb6","toSide":"top"}
|
||||
]
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
{
|
||||
"nodes":[
|
||||
{"id":"f86006360714173b","x":-500,"y":-300,"width":50,"height":60,"type":"text","text":"1"},
|
||||
{"id":"4da2384132b824d4","type":"text","text":"2","x":-400,"y":-300,"width":50,"height":60},
|
||||
{"id":"2331089e91ad4105","type":"text","text":"3","x":-300,"y":-300,"width":50,"height":60},
|
||||
{"id":"16ee97b45dd5e630","type":"text","text":"4","x":-200,"y":-300,"width":50,"height":60},
|
||||
{"id":"20d4d19575ff1b92","type":"text","text":"5","x":-100,"y":-300,"width":50,"height":60},
|
||||
{"id":"836e46e7fb6189c3","type":"text","text":"1","x":-500,"y":-60,"width":50,"height":60},
|
||||
{"id":"e1a8cf4de6d325aa","type":"text","text":"2","x":-400,"y":-60,"width":50,"height":60},
|
||||
{"id":"7135bfc6a5a7cebd","type":"text","text":"3","x":-300,"y":-60,"width":50,"height":60},
|
||||
{"id":"c109066e3d5a3216","type":"text","text":"4","x":-200,"y":-60,"width":50,"height":60},
|
||||
{"id":"de13631c290d68f6","type":"text","text":"5","x":-100,"y":-60,"width":50,"height":60},
|
||||
{"id":"4acfac1d1d1581ad","type":"text","text":"1","x":-500,"y":160,"width":50,"height":60},
|
||||
{"id":"194274de3a83728f","type":"text","text":"2","x":-400,"y":160,"width":50,"height":60},
|
||||
{"id":"722870a59dc4222f","type":"text","text":"3","x":-300,"y":160,"width":50,"height":60},
|
||||
{"id":"a4547ac5a40de628","type":"text","text":"4","x":-200,"y":160,"width":50,"height":60},
|
||||
{"id":"2d187bd644588d23","type":"text","text":"5","x":-100,"y":160,"width":50,"height":60},
|
||||
{"id":"6a37a402fc5dd7a0","x":-350,"y":-420,"width":150,"height":60,"type":"text","text":"Selection"}
|
||||
],
|
||||
"edges":[]
|
||||
{
|
||||
"nodes":[
|
||||
{"id":"f86006360714173b","x":-500,"y":-300,"width":50,"height":60,"type":"text","text":"1"},
|
||||
{"id":"4da2384132b824d4","type":"text","text":"2","x":-400,"y":-300,"width":50,"height":60},
|
||||
{"id":"2331089e91ad4105","type":"text","text":"3","x":-300,"y":-300,"width":50,"height":60},
|
||||
{"id":"16ee97b45dd5e630","type":"text","text":"4","x":-200,"y":-300,"width":50,"height":60},
|
||||
{"id":"20d4d19575ff1b92","type":"text","text":"5","x":-100,"y":-300,"width":50,"height":60},
|
||||
{"id":"836e46e7fb6189c3","type":"text","text":"1","x":-500,"y":-60,"width":50,"height":60},
|
||||
{"id":"e1a8cf4de6d325aa","type":"text","text":"2","x":-400,"y":-60,"width":50,"height":60},
|
||||
{"id":"7135bfc6a5a7cebd","type":"text","text":"3","x":-300,"y":-60,"width":50,"height":60},
|
||||
{"id":"c109066e3d5a3216","type":"text","text":"4","x":-200,"y":-60,"width":50,"height":60},
|
||||
{"id":"de13631c290d68f6","type":"text","text":"5","x":-100,"y":-60,"width":50,"height":60},
|
||||
{"id":"4acfac1d1d1581ad","type":"text","text":"1","x":-500,"y":160,"width":50,"height":60},
|
||||
{"id":"194274de3a83728f","type":"text","text":"2","x":-400,"y":160,"width":50,"height":60},
|
||||
{"id":"722870a59dc4222f","type":"text","text":"3","x":-300,"y":160,"width":50,"height":60},
|
||||
{"id":"a4547ac5a40de628","type":"text","text":"4","x":-200,"y":160,"width":50,"height":60},
|
||||
{"id":"2d187bd644588d23","type":"text","text":"5","x":-100,"y":160,"width":50,"height":60},
|
||||
{"id":"6a37a402fc5dd7a0","x":-350,"y":-420,"width":150,"height":60,"type":"text","text":"Selection"}
|
||||
],
|
||||
"edges":[]
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
# Set separator of data lines
|
||||
set datafile separator ";"
|
||||
set grid
|
||||
|
||||
# Set names of stuff
|
||||
set title "Execution Time vs Complexity"
|
||||
set xlabel "number of elements"
|
||||
set ylabel "time in milliseconds"
|
||||
|
||||
# Set line style, color, width, blabla
|
||||
set style line 1 linecolor rgb '#ff0000' linetype 1 linewidth 2
|
||||
set style line 2 linecolor rgb '#00ff00' linetype 1 linewidth 2
|
||||
|
||||
#### Prepare the function
|
||||
c = 0.000004 # to fit with the data !
|
||||
f(x) = c * x**2
|
||||
|
||||
title_f(c) = sprintf("f(x) = c*n^2, c = %f", c)
|
||||
|
||||
# Automatic scaling of axes
|
||||
set autoscale xy
|
||||
|
||||
#### Plot data only
|
||||
# plot 'd:\Desktop\Cours\tuto_graficos\data.csv' title 'data'
|
||||
|
||||
#### Plot both data and function (data with continuous line)
|
||||
# plot 'd:\Desktop\Cours\tuto_graficos\data.csv' title 'data' with lines linestyle 1, f(x) title title_f(c) with lines linestyle 2
|
||||
|
||||
#### Plot both data and function (data with points)
|
||||
plot 'd:\Desktop\Cours\tuto_graficos\data.csv' title 'data', f(x) title title_f(c) with lines linestyle 2
|
||||
# Set separator of data lines
|
||||
set datafile separator ";"
|
||||
set grid
|
||||
|
||||
# Set names of stuff
|
||||
set title "Execution Time vs Complexity"
|
||||
set xlabel "number of elements"
|
||||
set ylabel "time in milliseconds"
|
||||
|
||||
# Set line style, color, width, blabla
|
||||
set style line 1 linecolor rgb '#ff0000' linetype 1 linewidth 2
|
||||
set style line 2 linecolor rgb '#00ff00' linetype 1 linewidth 2
|
||||
|
||||
#### Prepare the function
|
||||
c = 0.000004 # to fit with the data !
|
||||
f(x) = c * x**2
|
||||
|
||||
title_f(c) = sprintf("f(x) = c*n^2, c = %f", c)
|
||||
|
||||
# Automatic scaling of axes
|
||||
set autoscale xy
|
||||
|
||||
#### Plot data only
|
||||
# plot 'd:\Desktop\Cours\tuto_graficos\data.csv' title 'data'
|
||||
|
||||
#### Plot both data and function (data with continuous line)
|
||||
# plot 'd:\Desktop\Cours\tuto_graficos\data.csv' title 'data' with lines linestyle 1, f(x) title title_f(c) with lines linestyle 2
|
||||
|
||||
#### Plot both data and function (data with points)
|
||||
plot 'd:\Desktop\Cours\tuto_graficos\data.csv' title 'data', f(x) title title_f(c) with lines linestyle 2
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
# Set separator of data lines and grid to plot
|
||||
set datafile separator ";"
|
||||
set grid
|
||||
|
||||
# Set names of stuff
|
||||
set title "Execution Time vs Complexity"
|
||||
set xlabel "number of elements"
|
||||
set ylabel "time in milliseconds"
|
||||
|
||||
# Set line style, color, width, blabla
|
||||
set style line 1 linecolor rgb '#ff0000' linetype 1 linewidth 2
|
||||
set style line 2 linecolor rgb '#00ff00' linetype 1 linewidth 2
|
||||
|
||||
#### Prepare the function
|
||||
f(x) = c * x ** 2
|
||||
|
||||
#### Fit the function to data
|
||||
fit f(x) 'd:\Desktop\Cours\tuto_graficos\data.csv' via c
|
||||
|
||||
# Save value of c to show in the function
|
||||
|
||||
title_f(c) = sprintf("f(x) = c*n^2, c = %f", c)
|
||||
|
||||
# Automatic scaling of axes
|
||||
set autoscale xy
|
||||
|
||||
#### Plot both data and function (data with continuous line)
|
||||
# plot 'd:\Desktop\Cours\tuto_graficos\data.csv' title 'data' with lines linestyle 1, f(x) title title_f(c) with lines linestyle 2
|
||||
|
||||
#### Plot both data and function (data with points)
|
||||
plot 'd:\Desktop\Cours\tuto_graficos\data.csv' title 'data', f(x) title title_f(c) with lines linestyle 2
|
||||
|
||||
|
||||
# Set separator of data lines and grid to plot
|
||||
set datafile separator ";"
|
||||
set grid
|
||||
|
||||
# Set names of stuff
|
||||
set title "Execution Time vs Complexity"
|
||||
set xlabel "number of elements"
|
||||
set ylabel "time in milliseconds"
|
||||
|
||||
# Set line style, color, width, blabla
|
||||
set style line 1 linecolor rgb '#ff0000' linetype 1 linewidth 2
|
||||
set style line 2 linecolor rgb '#00ff00' linetype 1 linewidth 2
|
||||
|
||||
#### Prepare the function
|
||||
f(x) = c * x ** 2
|
||||
|
||||
#### Fit the function to data
|
||||
fit f(x) 'd:\Desktop\Cours\tuto_graficos\data.csv' via c
|
||||
|
||||
# Save value of c to show in the function
|
||||
|
||||
title_f(c) = sprintf("f(x) = c*n^2, c = %f", c)
|
||||
|
||||
# Automatic scaling of axes
|
||||
set autoscale xy
|
||||
|
||||
#### Plot both data and function (data with continuous line)
|
||||
# plot 'd:\Desktop\Cours\tuto_graficos\data.csv' title 'data' with lines linestyle 1, f(x) title title_f(c) with lines linestyle 2
|
||||
|
||||
#### Plot both data and function (data with points)
|
||||
plot 'd:\Desktop\Cours\tuto_graficos\data.csv' title 'data', f(x) title title_f(c) with lines linestyle 2
|
||||
|
||||
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
int taille;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
// Lecture de la taille du carre.
|
||||
printf ("Donnez la taille du carre ? ");
|
||||
scanf ("%d", &taille);
|
||||
printf ("\n");
|
||||
|
||||
// Dessin de la bande du haut.
|
||||
for (i = 0; i < taille; i++)
|
||||
printf ("*");
|
||||
printf ("\n");
|
||||
|
||||
// Dessin des cotés.
|
||||
for (i = 1; i < taille - 1; i++)
|
||||
{
|
||||
printf ("*");
|
||||
for (j = 1; j < taille - 1; j++)
|
||||
printf (" ");
|
||||
printf ("*\n");
|
||||
}
|
||||
|
||||
// Dessin de la bande du bas.
|
||||
for (i = 0; i < taille; i++)
|
||||
printf ("*");
|
||||
printf ("\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
int taille;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
// Lecture de la taille du carre.
|
||||
printf ("Donnez la taille du carre ? ");
|
||||
scanf ("%d", &taille);
|
||||
printf ("\n");
|
||||
|
||||
// Dessin de la bande du haut.
|
||||
for (i = 0; i < taille; i++)
|
||||
printf ("*");
|
||||
printf ("\n");
|
||||
|
||||
// Dessin des cotés.
|
||||
for (i = 1; i < taille - 1; i++)
|
||||
{
|
||||
printf ("*");
|
||||
for (j = 1; j < taille - 1; j++)
|
||||
printf (" ");
|
||||
printf ("*\n");
|
||||
}
|
||||
|
||||
// Dessin de la bande du bas.
|
||||
for (i = 0; i < taille; i++)
|
||||
printf ("*");
|
||||
printf ("\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
all: program
|
||||
|
||||
program: main.o util.o
|
||||
gcc -o program main.o util.o
|
||||
|
||||
main.o: main.c
|
||||
gcc -c main.c
|
||||
|
||||
util.o: util.c
|
||||
all: program
|
||||
|
||||
program: main.o util.o
|
||||
gcc -o program main.o util.o
|
||||
|
||||
main.o: main.c
|
||||
gcc -c main.c
|
||||
|
||||
util.o: util.c
|
||||
gcc -c util.c
|
||||
Reference in New Issue
Block a user