Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
3Activity
0 of .
Results for:
No results containing your search query
P. 1
Structuri de Date Si Algoritmi

Structuri de Date Si Algoritmi

Ratings: (0)|Views: 52|Likes:
Published by C0colino

More info:

Published by: C0colino on Sep 23, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

07/10/2013

pdf

text

original

 
2011
Universitatea “Politehnica” Bucuresti
 
Facultatea de Electronica, Telecomunicatii si Tehnologia Informatiei
Proiect
“Structuri de Date si Algoritmi”
 
Student: Cococi Alin-GabrielGrupa: 413EProfesor: Nastac Iulian
 
2011
1.Motivatia alegerii temei. Utilitatea aplicatiei
Am ales aceasta tema ca urmare a cerintelor avute la materia structuri de date si algoritmi,problema aleasa fiind baza si ajutand la fiabilizarea unor probleme mai complexe .
2.Structura aplicatiei: Schema logica main()
START
int k,y;
 k!=0Citire radacina;inserarenodrad,kAfisare optiunigetche()Afisare arbore inpreordine,inordine sipostordineCitire nod de inlocuit Citire nod de inlocuit Afisare nr de noduricautare(k,y,prad)Afisare arbore inpreordine,inordine sipostordineCitire nod nouCitire vectorul vcautare(k,0,prad)Afisare arbore inpreordineAfisare nr de niveleAfisare nr de frunzegetch()STOP
 
2011
3.Detalii tehnice de implementare
 
#include<stdio.h>#include<conio.h>#include<malloc.h>
typedef struct nod 
{int nr;nod *st, *dr;};nod *prad=NULL,*a;int v[50],x;
int sumacif(int i)
{int s=0,c;do {c=i%10;i=i/10;s=s+c; } while(i!=0);return s;}
void inserare_nod(nod *&p, int k)
{int n;nod *q;if (!p){n=sizeof(nod);q=(nod *)malloc(n);q->nr=k;q->st=q->dr=NULL; p=q; }else{if(p->nr!=k)if(sumacif(p->nr)>=sumacif(k))inserare_nod(p->st,k);elseinserare_nod(p->dr,k);}}
void preordine(nod *p)
{if (p){printf(" %d ",p->nr);preordine(p->st);preordine(p->dr);} }
void inordine(nod *p)
{if (p){inordine(p->st);printf(" %d ",p->nr);inordine(p->dr); } }
void postordine(nod *p)
{if (p){postordine(p->st);postordine(p->dr);printf(" %d ",p->nr);} }
void cautare(int x,int y,nod *&a)
{ int i;if(!a)printf("\nNodul nu exista! \n");elseif (x<a->nr)cautare(x,y,a->st);elseif (x>a->nr)cautare(x,y,a->dr);elseif(y !=0 )a->nr=y;else{a->nr=v[1];for(i=2;i<=x;i++)inserare_nod(a,v[i]);}}
int noduri(nod *p)
{if (!p)return 0;elsereturn (1+noduri(p->st)+noduri(p->dr));}
int max(int x,int y)
{if (x<y) return y;else return x;}
int nivel(nod *p)
{if (!p)return 0;elsereturn (1+max(nivel(p->st),nivel(p->dr)));}
int nr_frunze(nod *p)
{if(!p)return 0;elseif((!p->st)&&(!p->dr))return 1;elsereturn (nr_frunze(p->st)+nr_frunze(p->dr));}

Activity (3)

You've already reviewed this. Edit your review.
1 hundred reads
Dan liked this
Dan liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->