1 / 5

D ivide et impera S ef de grup : Circu Anamaria Membri : Oancea Elena Chicea Diana

D ivide et impera S ef de grup : Circu Anamaria Membri : Oancea Elena Chicea Diana Apalimaritei Daniela Opariuc Andreea Introducere ; Descriere metoda ; Algoritmul metodei ; Implementare ; Aplicatii ; Bibliografie. Divide et impera.

ina
Download Presentation

D ivide et impera S ef de grup : Circu Anamaria Membri : Oancea Elena Chicea Diana

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Divide et impera Sef de grup:CircuAnamaria Membri: Oancea Elena Chicea Diana Apalimaritei Daniela OpariucAndreea • Introducere; • Descrieremetoda; • Algoritmulmetodei; • Implementare; • Aplicatii; • Bibliografie.

  2. Divide et impera • Divide et imperainseamna”dezbinasidomina”. • Aceastaesteuna din celemaicunoscutemetode din istoriaomenirii. • Este o tehnicaprin care se pot rezolvaproblemesi care consta in descompunereauneiprobleme in douasaumaimultesubprobleme,ele se rezolvaiarsolutiapentruproblemainitiala se obtinecombinandsolutiilesubproblemelor. • Nu toateproblemele se pot rezolva cu ajutorulacesteimetode,numarulacestafiindmic. • Motto :”Tot ceeste fundamental diferitderanjeazaordineastabilita.”

  3. Descriereametodei Metoda divide et imperaadmite o implementarerecursiva , deoarecesubproblemelesuntsimilareproblemeiinitiale , dar de dimensiunimaimici. Etapelesunt: - descompunereaproblemeinitiale in subproblemeindependente; -descompunereatreptata a subproblemelor in altele din ce in cemai simple; -rezolvareaproblemelor simple; -combinareasolutiilorgasitepentruconstruireasolotiilorsubproblemelor de dimensiunimaimari; -combinareaultimelorsolutiipentru a obtinesolutiaproblemeiinitiale.

  4. Algoritmulmetodei Un algoritm divide et imperatrebuiesaevitedescompunerearecursiva a subcazurilorsuficient de mici. Algoritmuldivide et impera algoritmdivide_et_impera (p,u,sol) daca (p<u) atunci imparte(p,u,m);//determinapozitia de mijloc divide_et_impera (p,m,sol1);//se aplicaalgoritmul divide_et_impera(m+1,u,sol2);//pentrufiecaresubproblema sol=combina(sol1,sol2);//formareasolutiei altfel rezolva(sol);//rezolvasubproblemaelementara sfarsitdaca sfarsitalgoritmdivide_et_impera.

  5. Implementare Cautareabinara #include<iostream.h> int v[100],n,nr; void caut (intI,inti) { int m=(i+j)/2; if(nr==v[m]) cout<<“gasit,indice=“<<m; else if (i<j) if(nr<v[m]) cout(i,m-1) else cout(m+1,j); else cout <<“nu a fostgasit.”; } void main() { cout<<“n=“;cin>>n; for( i=1;i<=n;i++) { cout<<“v[“<<i<<“]=“;cin>>v[i]; } cout<<“nr=“;cin>>nr; cout(1,n); }

More Related