Skip to content

Commit e72fe1e

Browse files
committed
Fixing wrong regexp in makefile / interaction with Action project.
1 parent b2bc06a commit e72fe1e

4 files changed

Lines changed: 57 additions & 6 deletions

File tree

source/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ $(PROJECT_DIR)%.zip: $(PROJECT_DIR)%/*/Program.cs | $(PROJECT_DIR)/%/*/*.cs
557557
# $(notdir $*) # Name of Solution
558558
# $(notdir $(patsubst %/,%,$(dir $<))) # Name of Project
559559
# $@ # Name of target, the zip file
560-
# cat $< | grep -oP '^\s*(public |private )?class \K.*' # name of the class in Program.cs
560+
# cat $< | grep -oP '(((internal)|(public)|(private)|(protected)|(sealed)|(abstract)|(static))?[\s\r\n\t]+){0,2}class[\s]+\K([[:alnum:]]|_)*[\s\S]' # name of the class in Program.cs
561561
#
562562
# We start by creating the required Properties directory:
563563
@mkdir -p $(dir $<)Properties

source/code/projects/Actions/Actions/Program.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ static void Main()
2525
Action<int> display_variable = ExampleActions.Display;
2626
display_variable(10);
2727

28-
// We can even have action
29-
// from class that uses generic
28+
// We can even have actions
29+
// from classes that uses generic
3030
// type parameters.
3131

3232
int[] arrayT = { 20, 30, 40 };
@@ -37,6 +37,5 @@ static void Main()
3737

3838
// Passing an Action as an argument:
3939
CallingAction.Demo(ExampleActions.Test);
40-
}
41-
42-
}
40+
}
41+
}

source/lectures/misc/actions.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
tags:
3+
- datatypes
4+
---
5+
6+
# Actions
7+
8+
## Motivation
9+
10+
[Wikipedia](https://en.wikipedia.org/wiki/Sorting_algorithm) explains it very nicely: sorting is ubiquitous in Computer Sciences.
11+
It is a simple problem ("*How can I sort the following values the most efficiently?*") that has many solutions, but still offers open problems.
12+
13+
We only consider **correct** algorithms, i.e., one where their output is such that
14+
15+
- each element is larger than or equal to the previous one, according to the order picked,
16+
- all the elements that were in the input are present in the output (with the same cardinality, if repetition is allowed).
17+
18+
There are many ways of "comparing" sorting algorithms.
19+
A sorting algorithm…
20+
21+
- has a best, worst and average case time complexity (measured in general in number of comparisons required),
22+
- has a best, worst and average case space complexity (i.e., "how much additional memory is required?"),
23+
- can be "stable" (i.e., equal values are not permutted),
24+
- uses *insertion*, *exchange*, *selection*, *merging* method,
25+
- is serial or parallel,
26+
27+
among other properties.
28+
29+
# Insertion Sort Algorithm
30+
31+
This algorithm is [nicely explained and illustrated on wikipedia](https://en.wikipedia.org/wiki/Insertion_sort), and can be implemented as follows:
32+
33+
```
34+
!include`snippetStart="// Insertion Algorithm", snippetEnd="// Done with insertion Algorithm"` code/projects/Sorting/Sorting/Sorting.cs
35+
```
36+
37+
# Heapsort Algorithm
38+
39+
We first define some helper methods:
40+
41+
```
42+
!include`snippetStart="// Helper methods for Heapsort", snippetEnd="// Done with helper methods for Heapsort"` code/projects/Sorting/Sorting/Sorting.cs
43+
```
44+
45+
and then leverage the heap structure to sort:
46+
47+
```
48+
!include`snippetStart="// Heapsort Algorithm", snippetEnd="// Done with heapsort Algorithm"` code/projects/Sorting/Sorting/Sorting.cs
49+
```
50+
51+
Note that `PercDown` builds a *max heap*: once the values are "pre-sorted **greater value first**", removing the first one to move it to the *end* of the list makes the list sorted from smallest to greatest value once we are done.

source/order

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
./lectures/misc/exceptions.md
7575
./lectures/misc/references.md
7676
./lectures/misc/files.md
77+
./lectures/misc/actions.md
7778
./lectures/misc/sorting.md
7879
./lecture/slides.md
7980
./labs/

0 commit comments

Comments
 (0)