about summary refs log tree commit diff
path: root/usth/MATH2.3/3/README.md
blob: fed19eb57492936c810c12963e5b7b3d25fb260a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Trees
## Problem 1
`graph-is-tree.cc` (C++17) take a natural numbers `n` and a `n`-by-`n` adjacent
matrix from stdin and print to stdout either yes or no depending on whether the
given graph is a tree or not, e.g.

### Input
    3
    0 1 0
    1 0 1
    0 1 0

### Output
    yes

## Problem 2
`binary-search-tree.c` takes a natural number `n` and `n` integers from stdin
and print to stdout a horizontal binary search tree formed (naïvely) from the
given input, e.g.

### Input
    7
    34 45 21 65 12 546 23

### Output
            12
        21
            23
    34
        45
            65
                546

## Problem 3
`dc.cc` takes from stdin a list of numbers and operator, each terminated by a
semi-colon and print to stdout the evaluation of the given postfix arithmetic
expression, e.g.

### Input
    6.9;4.20;+;2;^;6.9;4;-;3;/;+;

### Output
    124.177

## Problem 4
`st-dfs.cc` (C++17) takes a natural number `n` and an `n`-by-`n` adjacent
matrix from stdin and print the edges on a spanning tree of the given graph to
stdout, e.g.

### Input
    4
    0 1 1 1
    1 0 1 1
    1 1 0 1
    1 1 1 0

### Output
    2 3
    0 3
    1 2

## Problem 5
`sum-set.cc` takes a natural number `n` and a line of positive integers on one
line from stdin and print numbers whose sum are `n`, separated by a newline, to
stdout, e.g.

### Input
    7
    1 2 3 4 5 6 7 8 9

### Output
    1 2 4
    1 6
    2 5
    3 4
    7