Skip to content
Snippets Groups Projects
Commit 517fde7b authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Vorbereitung 9.1.2023: Übungsaufgaben und Musterlösungen

parent f5168616
No related branches found
No related tags found
No related merge requests found
Showing
with 569 additions and 0 deletions
File moved
File moved
#include <stdio.h>
typedef struct
{
int content;
node *next;
} node;
int main (void)
{
return 0;
}
#include <stdio.h>
typedef struct node
{
int content;
struct node *next;
} node;
int main (void)
{
return 0;
}
#include <stdio.h>
typedef struct node
{
int content;
struct node *next;
} node;
int main (void)
{
node node3 = { 3, NULL };
node node7 = { 7, NULL };
node node137 = { 137, NULL };
node *first = &node3;
for (node *p = first; p; p = p->next)
printf ("%d\n", p->content);
return 0;
}
#include <stdio.h>
typedef struct node
{
int content;
struct node *next;
} node;
int main (void)
{
node node3 = { 3, NULL };
node node7 = { 7, NULL };
node node137 = { 137, NULL };
node3.next = &node7;
node7.next = &node137;
node137.next = NULL;
node *first = &node3;
for (node *p = first; p; p = p->next)
printf ("%d\n", p->content);
return 0;
}
#include <stdio.h>
typedef struct node
{
int content;
struct node *next;
} node;
int main (void)
{
node node3 = { 3, NULL };
node node7 = { 7, NULL };
node node137 = { 137, NULL };
node3.next = &node7;
node7.next = &node137;
node137.next = NULL;
node node5 = { 5, NULL };
node5.next = node3.next;
node3.next = &node5;
node *first = &node3;
for (node *p = first; p; p = p->next)
printf ("%d\n", p->content);
return 0;
}
../common/logo-hochschule-bochum-cvh-text-v2.pdf
\ No newline at end of file
../common/logo-hochschule-bochum.pdf
\ No newline at end of file
File moved
#include <stdio.h>
typedef struct
{
int content;
node *left, *right;
} node;
int main (void)
{
node *root = NULL;
return 0;
}
#include <stdio.h>
typedef struct node
{
int content;
struct node *left, *right;
} node;
int main (void)
{
node *root = NULL;
return 0;
}
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int content;
struct node *left, *right;
} node;
void insert (node *root, int content)
{
node *p = malloc (sizeof (node));
p->content = content;
p->left = NULL;
p->right = NULL;
root = p;
}
void output (node *root)
{
if (root)
printf ("%d\n", root->content);
}
int main (void)
{
node *root = NULL;
insert (root, 7);
output (root);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int content;
struct node *left, *right;
} node;
node *root = NULL;
void insert (int content)
{
node *p = malloc (sizeof (node));
p->content = content;
p->left = NULL;
p->right = NULL;
if (root == NULL)
root = p;
}
void output (void)
{
if (root)
printf ("%d\n", root->content);
else
printf ("root is NULL\n");
}
int main (void)
{
insert (7);
insert (137);
insert (3);
output ();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int content;
struct node *left, *right;
} node;
node *root = NULL;
void insert (int content)
{
node *p = malloc (sizeof (node));
p->content = content;
p->left = NULL;
p->right = NULL;
if (root == NULL)
root = p;
else
{
if (content > root->content)
root->right = p;
else
root->left = p;
}
}
void output (void)
{
if (root)
printf ("%d\n", root->content);
else
printf ("root is NULL\n");
}
int main (void)
{
insert (7);
insert (137);
insert (3);
output ();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int content;
struct node *left, *right;
} node;
node *root = NULL;
void insert (int content)
{
node *p = malloc (sizeof (node));
p->content = content;
p->left = NULL;
p->right = NULL;
if (root == NULL)
root = p;
else
{
if (content > root->content)
root->right = p;
else
root->left = p;
}
}
void output (void)
{
if (root)
{
if (root->left)
printf ("%d\n", root->left->content);
printf ("%d\n", root->content);
if (root->right)
printf ("%d\n", root->right->content);
}
else
printf ("root is NULL\n");
}
int main (void)
{
insert (7);
insert (137);
insert (3);
output ();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int content;
struct node *left, *right;
} node;
node *root = NULL;
void insert (int content)
{
node *p = malloc (sizeof (node));
p->content = content;
p->left = NULL;
p->right = NULL;
if (root == NULL)
root = p;
else
{
node *save_root = root;
if (content > root->content)
{
root = root->left;
insert (content);
}
else
{
root = root->right;
insert (content);
}
root = save_root;
}
}
void output (void)
{
if (root)
{
if (root->left)
{
node *save_root = root;
root = root->left;
output ();
root = save_root;
}
printf ("%d\n", root->content);
if (root->right)
{
node *save_root = root;
root = root->right;
output ();
root = save_root;
}
}
else
printf ("root is NULL\n");
}
int main (void)
{
insert (7);
insert (137);
insert (3);
insert (1117);
insert (42);
insert (13);
output ();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int content;
struct node *left, *right;
} node;
node *root = NULL;
void insert (int content)
{
node *p = malloc (sizeof (node));
p->content = content;
p->left = NULL;
p->right = NULL;
if (root == NULL)
root = p;
else
{
node *save_root = root;
if (content > root->content)
{
root = root->left;
insert (content);
save_root->left = root;
}
else
{
root = root->right;
insert (content);
save_root->right = root;
}
root = save_root;
}
}
void output (void)
{
if (root)
{
if (root->left)
{
node *save_root = root;
root = root->left;
output ();
root = save_root;
}
printf ("%d\n", root->content);
if (root->right)
{
node *save_root = root;
root = root->right;
output ();
root = save_root;
}
}
else
printf ("root is NULL\n");
}
int main (void)
{
insert (7);
insert (137);
insert (3);
insert (1117);
insert (42);
insert (13);
output ();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int content;
struct node *left, *right;
} node;
node *root = NULL;
void insert (int content)
{
node *p = malloc (sizeof (node));
p->content = content;
p->left = NULL;
p->right = NULL;
if (root == NULL)
root = p;
else
{
node *save_root = root;
if (content < root->content)
{
root = root->left;
insert (content);
save_root->left = root;
}
else
{
root = root->right;
insert (content);
save_root->right = root;
}
root = save_root;
}
}
void output (void)
{
if (root)
{
if (root->left)
{
node *save_root = root;
root = root->left;
output ();
root = save_root;
}
printf ("%d\n", root->content);
if (root->right)
{
node *save_root = root;
root = root->right;
output ();
root = save_root;
}
}
else
printf ("root is NULL\n");
}
int main (void)
{
insert (7);
insert (137);
insert (3);
insert (1117);
insert (42);
insert (13);
output ();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int content;
struct node *left, *right;
} node;
node *root = NULL;
void insert (int content)
{
node *p = malloc (sizeof (node));
p->content = content;
p->left = NULL;
p->right = NULL;
if (root == NULL)
root = p;
else
{
node *save_root = root;
if (content < root->content)
{
root = root->left;
insert (content);
save_root->left = root;
}
else
{
root = root->right;
insert (content);
save_root->right = root;
}
root = save_root;
}
}
void output (node *root)
{
if (root)
{
if (root->left)
output (root->left);
printf ("%d\n", root->content);
if (root->right)
output (root->right);
}
else
printf ("root is NULL\n");
}
int main (void)
{
insert (7);
insert (137);
insert (3);
insert (1117);
insert (42);
insert (13);
output (root);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment