summaryrefslogtreecommitdiff
path: root/3/9_data_structures/44_gaps.c
diff options
context:
space:
mode:
authorMike Vink <mike@pionative.com>2024-06-14 09:23:32 +0200
committerMike Vink <mike@pionative.com>2024-06-14 09:23:32 +0200
commit8092f4c334db547ced59d6f439b558dad35e1ab2 (patch)
treefa462fa885efea1ec6095d015286998d632c2c3d /3/9_data_structures/44_gaps.c
parentb424517a33bf61aedff29eed74a665402ab496ba (diff)
commit for once
Diffstat (limited to '3/9_data_structures/44_gaps.c')
-rw-r--r--3/9_data_structures/44_gaps.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/3/9_data_structures/44_gaps.c b/3/9_data_structures/44_gaps.c
new file mode 100644
index 0000000..1162895
--- /dev/null
+++ b/3/9_data_structures/44_gaps.c
@@ -0,0 +1,86 @@
+// A.
+struct P1 {
+ int i;
+ char c;
+ int j;
+ char d;
+};
+// Largest primitive is 4, so the local alignment value must be 4
+// |int 4| char 1|gap 3 |int 4 |char 1|gap 3|
+// |-----|--------------|------|------------|
+// 4 4 4 4
+// i 0
+// c 4
+// j 8
+// d 12
+//
+// total 16
+//
+// B.
+struct P2 {
+ int i;
+ char c;
+ char d;
+ long j;
+};
+// Largest primitive is 8, so the local alignment value must be 8
+// |int 4|char 1| char 1|gap 2|long 8|
+// |--------------------------|------|
+// 8 8
+// i 0
+// c 4
+// d 5
+// j 8
+//
+// total 16
+//
+// C.
+struct P3 {
+ short w[3];
+ char c[3];
+};
+// Largest primitive is 2, so the local alignment value must be 2
+// |short 2|short 2|short 2|char 1|char 1|char 1|gap 1|
+// |-------|-------|-------|-------------|------------|
+// 2 2 2 2 2
+//
+// w[0] 0
+// w[1] 2
+// w[2] 4
+// c[0] 6
+// c[1] 7
+// c[2] 8
+//
+// total 10
+//
+// D.
+struct P4 {
+ short w[5];
+ char *c[3];
+};
+// Largest primitive is 8, so the local alignment value must be 8
+// |short 2|short 2|short 2|short 2|short 2|gap 6|char* 8|char* 8|char* 8|
+// |-------------------------------|-------------|-------|-------|-------|
+// 8 8 8 8 8
+//
+// w[0] 0
+// w[1] 2
+// w[2] 4
+// w[3] 6
+// w[4] 8
+// c[0] 16
+// c[1] 24
+// c[2] 32
+//
+// total 40
+// E.
+struct P5 {
+ struct P3 a[2];
+ struct P2 t;
+};
+// Largest primitive is 8, so the local alignment value must be 8
+// |P3 10|P3 10|gap 4|P2 16|
+//
+// a[0] 0
+// a[1] 10
+// t 24