Veri yapılarının önemli konularından biriside kuyruk veri yapısıdır.Kuyruk veri yapısı adındanda anlaşılacağı üzere ilk giren ilk çıkar yani FIFO mantığıyla çalışır.Burda herbir eleman için bir Node (düğüm) oluşturarak Class yapısının içinde kullandım ve her elemanı önce ittim kuyruğa (ENQUEUE) sonra da çektim kuyruktan DEQUEUE.Şimdi Bunun gerçeklemesini görelim..
Burda Kuyruğa önce 19 tane eleman ittik sonra 10 tane eleman çektik dolayısıyla ilk eklediğimiz 10 tane ilk çıktı.
#include<iostream>
using namespace std;
class Node {
public:
Node();
int data;
Node *NEXT;
};
Node::Node()
{
this->data=0;
this->NEXT=NULL;
}
class queue {
public:
queue();
void enqueue(int);
void dequeue(int);
void print()const;
private:
Node *front;
Node *rear;
int counter;
};
queue::queue()
{
this->front=NULL;
this->rear=NULL;
this->counter=0;
}
void queue::enqueue(int A)
{
Node *p=new Node;
p->data=A;
if(front==NULL)
{
front=p;
rear=p;
front->NEXT=NULL;
}
else
{
rear->NEXT=p;
rear=p;
rear->NEXT=NULL;
}
counter++;
}
void queue::dequeue(int A)
{
Node *p1;
p1=front;
front=front->NEXT;
cout<<“silinen eleman”<<p1->data<<” “<<endl;
delete p1;
counter–;
}
void queue::print()const
{
Node *p1;
p1=front;
while(p1->NEXT!=NULL)
{
cout<<p1->data<<” “;
p1=p1->NEXT;
}
cout<<endl;
}
main()
{
queue T;
for(int i=0;i<20;i++)
T.enqueue(i);
T.print();
for(int j=0;j<10;j++)
T.dequeue(j);
T.print();
system (“pause”);
}
MEHMET SALİH DEVECİ
BİLGİSAYAR MÜHENDİSİ YAZILIM UZMANI
Hello there! I could have sworn I’ve been to this blog before but after looking at many of
the posts I realized it’s new to me. Nonetheless, I’m certainly happy I came across it and I’ll be bookmarking it and checking back regularly! https://918.network/downloads/86-play8oy
F*ckin’ remarkable issues here. I’m very glad to look your article. Thanks so much and i am taking a look forward to touch you. Will you please drop me a mail?
Throughout the awesome scheme of things you get a B+ just for hard work. Where you actually misplaced us was first on your facts. As it is said, details make or break the argument.. And that couldn’t be much more accurate at this point. Having said that, let me inform you what did deliver the results. The text can be extremely powerful and this is most likely the reason why I am making the effort to comment. I do not make it a regular habit of doing that. Next, whilst I can certainly see a jumps in logic you come up with, I am not sure of just how you seem to connect your points which produce the actual conclusion. For now I shall subscribe to your point but trust in the foreseeable future you actually connect the dots better.
Wonderful beat ! I would like to apprentice whilst you amend your site, how could i subscribe for a weblog site? The account aided me a appropriate deal. I had been a little bit familiar of this your broadcast provided vibrant clear idea
Glad I discovered this on google .