Čavte. Nemáte niekto zdrojové kódy k nasledujúcim programom? Ak áno, prosím hoďte ich prosím sem. Vďaka.
PROGRAMY:
Nedestruktivní průnik setříděných spojáků
Dva binarni vyhledavaci stromy, udelat jejich destruktivni prunik
prespojovani jednosmerneho spojaku aby byl pozpatku
destruktivni prunik dvou spojaku
vyhodit cisla z intervalu <a,b> z BVS:
(ne)destruktivny prienik/zjednotenie dvoch spojakov
zliatie dvoch utriedenych spojakov do jedneho (utriedeneho)
vyhodit cisla z intervalu <-oo,a>U<b,oo> z BVS
previest postfixovu notaciu do binarneho vyrazoveho stromu
Destruktivní sjednocení dvou uspořádaných množin
nedestruktivni sjednoceni dvou BVS
vlozit prvok do BVS
setřídit spoják čísel podle počtu jejich různých prvočíselných dělitelů...
destruktivní sjednocení uspořádaných množin
destruktivny prienik dvoch spojakov
destruktivni sjednoceni dvou BST (nedelat otrhanim jednoho z nich)
Malé príklady
- xstyler
- Matfyz(ák|ačka) level II
- Příspěvky: 66
- Registrován: 29. 1. 2005 12:27
- Typ studia: Informatika Bc.
- Bydliště: EU
odpoved
prespojovani jednosmerneho spojaku aby byl pozpatku
struct node {
int data;
struct node* next;
};
void RecursiveReverse(struct node** headRef) {
struct node* first;
struct node* rest;
// empty list base case if (*headRef == NULL) return;
first = *headRef; // suppose first = {1, 2, 3}
rest = first->next; // rest = {2, 3}
// empty rest base case if (rest == NULL) return;
RecursiveReverse(&rest); // Recursively reverse the smaller {2, 3} case
// after: rest = {3, 2}
first->next->next = first; // put the first elem on the end of the list
first->next = NULL; // (tricky step -- make a drawing)
// fix the head pointer *headRef = rest;
}
struct node {
int data;
struct node* next;
};
void RecursiveReverse(struct node** headRef) {
struct node* first;
struct node* rest;
// empty list base case if (*headRef == NULL) return;
first = *headRef; // suppose first = {1, 2, 3}
rest = first->next; // rest = {2, 3}
// empty rest base case if (rest == NULL) return;
RecursiveReverse(&rest); // Recursively reverse the smaller {2, 3} case
// after: rest = {3, 2}
first->next->next = first; // put the first elem on the end of the list
first->next = NULL; // (tricky step -- make a drawing)
// fix the head pointer *headRef = rest;
}
- xstyler
- Matfyz(ák|ačka) level II
- Příspěvky: 66
- Registrován: 29. 1. 2005 12:27
- Typ studia: Informatika Bc.
- Bydliště: EU
previest pre/post-fixovu notaciu do binarneho vyrazoveho stromu
-=( prevody mezi jednotlivymi *fixy )=-
nejjednodussi cesta je postavit strom:
// z prefixu (na stromecek)
function Strom:PPrvek;
var
c:char;
p:PPrvek;
begin
new(p);
read(c);
p^.c:=c;
if c in ['+','-','*','/'] then
begin
p^.L:=Strom;
p^.P:=Strom;
end
else
begin
p^.L:=nil;
p^.P:=nil;
end;
Strom:=p;
end;
// z postfixu (na stromecek)
var
Z:array[1..MAX] of PPrvek; // zasobnik
xZ:integer; // pocet prvku v zasobniku
P:PPrvek;
begin
xZ:=0;
while not eof(soubor) do
begin
read(c);
new(P);
if c in ['+','-','*','/'] then // je operace
begin
P^.L:=Z[xZ-1];
P^.P:=Z[xZ];
Dec(xZ,2);
end;
else // neni operace
begin
P^.L:=nil;
P^.P:=nil;
end;
Inc(xZ); // vlozeni do zasobniku
Z[xZ]:=p;
end;
end;
-=( prevody mezi jednotlivymi *fixy )=-
nejjednodussi cesta je postavit strom:
// z prefixu (na stromecek)
function Strom:PPrvek;
var
c:char;
p:PPrvek;
begin
new(p);
read(c);
p^.c:=c;
if c in ['+','-','*','/'] then
begin
p^.L:=Strom;
p^.P:=Strom;
end
else
begin
p^.L:=nil;
p^.P:=nil;
end;
Strom:=p;
end;
// z postfixu (na stromecek)
var
Z:array[1..MAX] of PPrvek; // zasobnik
xZ:integer; // pocet prvku v zasobniku
P:PPrvek;
begin
xZ:=0;
while not eof(soubor) do
begin
read(c);
new(P);
if c in ['+','-','*','/'] then // je operace
begin
P^.L:=Z[xZ-1];
P^.P:=Z[xZ];
Dec(xZ,2);
end;
else // neni operace
begin
P^.L:=nil;
P^.P:=nil;
end;
Inc(xZ); // vlozeni do zasobniku
Z[xZ]:=p;
end;
end;