Anniesnannies-seattle - Tổng hợp số 1 nhiều tin hay nhất thị trường
  • Home
  • Du Lịch
  • Công Nghệ
  • Học Tiếng Anh
No Result
View All Result
  • Home
  • Du Lịch
  • Công Nghệ
  • Học Tiếng Anh
No Result
View All Result
Anniesnannies-seattle - Tổng hợp số 1 nhiều tin hay nhất thị trường
No Result
View All Result
Home Công Nghệ

Queue Data Structure in C++ Programming (using arrays) | All Queue Operations | Part – 2

admin by admin
June 30, 2020
in Công Nghệ
37
Queue Data Structure in C++ Programming (using arrays) | All Queue Operations | Part – 2
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter



We will be implementing queue data structure and all its standard operations. We will implement queue using arrays in c++ programming language.
Following are the stack operations –
1) enqueue() –
Elements are added from one end (Rear / Back).
2) dequeue() –
Elements are removed from one end (Head / Front).
3) isEmpty() –
Tells if the queue is empty or not
4) isfull() –
Tells if the queue is full or not.
5) count() –
Get the number of items in the queue.
6) display() –
Display all items in the queue

If you want the full C++ Program code for Queue & Queue operations follow me on Instagram or Facebook (links given below) & send me your email address & I will mail the full code to you ✌

Full DSA playlist –
Full Article & Code on our official website –

C++ Programming Tutorials for Beginners Course –

Simple Snippets Official Website –

Simple Snippets on Facebook –

Simple Snippets on Instagram –

Simple Snippets on Twitter –

Simple Snippets Google Plus Page –

Simple Snippets email ID –
simplesnippetsinfo@gmail.com

For More Technology News, Latest Updates and Blog articles visit our Official Website –

#queue #queueprogram #queuecpp #queuedatastructure #datastructures #queueds #queueoperations

Nguồn: https://anniesnannies-seattle.com/

Xem thêm bài viết khác: https://anniesnannies-seattle.com/cong-nghe/

Xem thêm Bài Viết:

  • Tips&Tricks for a Faster Startup in Windows 10
  • CTDL&GT: Tạo Queue bằng danh sách liên kết đơn
  • std::queue In C++ | STL C++
  • Cách Diệt Virus USB Không Cần Phần Mềm
  • 5 ứng dụng phải xóa nếu muốn máy Android giảm giật lag
Previous Post

Cách tăng view youtube nhanh nhất | 2020 | Các bước cụ thể

Next Post

Game Theory: Fallout Bottle Caps are Worth HOW MUCH?!?

admin

admin

Next Post
Game Theory: Fallout Bottle Caps are Worth HOW MUCH?!?

Game Theory: Fallout Bottle Caps are Worth HOW MUCH?!?

Comments 37

  1. shubham baranwal says:
    1 year ago

    int count()
    {
    if(rear==-1 && front==-1)
    return 0;
    else
    return rear-front+1;
    }
    count should be like this otherwise without element also count will be 1.
    Well thank you sir

    Reply
  2. Tejas Kakad says:
    1 year ago

    What if you want to make a queue of size value entered by the user?

    Reply
  3. Akhilesh Dhindsa says:
    1 year ago

    Nice code but if someone insert 0 in the queue and display it then the output will be just zeros and it may become confusing at that index whether element is inserted or is it empty position. While displaying 0 should be converted to null.

    Reply
  4. Dhonddev Ameya says:
    1 year ago

    When we carry dequeue operation, should the elements shieft by one index towards the element which was dequeued?
    Like we have five elements
    10 20 30 40 50.
    And we carried dequeue
    Then 10 gets dequeued
    And the new sequence should be
    20 30 40 50 0
    Right?

    Reply
  5. Pranav Patki says:
    1 year ago

    can you pls explain how to enter size of array dynamically instead of already keeping it as 5??

    Reply
  6. Kaushik Juttiga says:
    1 year ago

    Is there an option to replace 0 with null because if someone enqueue 0 then it will be confusing right. When he uses display function then it will show the empty ones which is 0 and his 0. So how to solve that issue.

    Reply
  7. Epicks Form says:
    1 year ago

    So, I had a quick question. When is a queue full? I understood all the concepts and your video was AWESOME (as always haha)… but not being able to define if the queue was full or not made me think what a queue being full meant? I'd appreciate if you could let me know. Thanks and like you always say… Peace <3

    Reply
  8. Rishabh Sharma says:
    1 year ago

    Simply a perfect channel for perfect programming!!! 👊 thanks alot brother❤️

    Reply
  9. Gopesh Singhal says:
    1 year ago

    There is mistake in count function also…if we does not enqueue any value….count must be 0 but this will show 1 because in that case rear and front both are -1 and -1-1+1 is 1…..so put this case also in count function when front and rear are -1

    Reply
  10. Sulab Dhungana says:
    1 year ago

    Great Explanation!!
    Minor bug fixes:
    bool isFull()

    {

    if (r-f == size-1)

    {

    return true;

    }

    else

    {

    return false;

    }

    }
    int count()

    {

    if (r == -1 && f == -1)

    {

    return 0;

    }

    else

    {

    return (r – f) + 1;

    }

    }

    Reply
  11. deepesh sharma says:
    1 year ago

    #include<iostream>
    using namespace std;
    class queue{
    int i,arr[5],rear,front;
    public:
    queue(){
    rear=0;
    front=-1;
    for(i=0;i<5;i++)
    arr[i]=0;
    }
    bool isempty(){
    if(rear=-1&&front==-1)
    return true;
    else
    return false;
    }
    bool isfull(){
    if(rear==4)
    return true;
    else
    return false;
    }
    void enque(int value){
    if(isfull()){
    cout<<"queue is full ,element can't be enque"<<endl;
    }
    else if(isempty()){
    front=0;
    rear=0;
    arr[rear]=value;
    }
    else{rear++;
    arr[rear]=value;
    }}
    void deque(){
    if(isempty())
    {cout<<"queue is empty ,element can't be deque"<<endl;}
    else if(rear==front){
    arr[front]=0;
    front=rear=-1;
    }
    else
    {
    arr[front]=0;
    front++;
    }}
    void display(){
    for(i=0;i<=4;i++)
    cout<<arr[i]<<" ";
    }
    void peek(int position){
    if(rear-front+1>=position)
    cout<<arr[position];
    else
    cout<<"invalid position"<<endl;
    }
    void change(int position,int value){
    if(rear-front+1>=position)
    arr[position]=value;
    else
    cout<<"invalid position";
    }
    int count(){
    return rear-front+1;
    }
    void ree(){
    cout<<rear<<endl;
    }
    };
    int main(){
    queue q1;
    int value,option,position;
    do{
    cout<<endl<<"SELECT THE OPERATION,press '0' for stop"<<endl;
    cout<<"'1'isEmpty"<<endl;
    cout<<"'2'isfull"<<endl;
    cout<<"'3'Enque"<<endl;
    cout<<"'4'Deque"<<endl;
    cout<<"'5'Display"<<endl;
    cout<<"'6'peek"<<endl;
    cout<<"'7'change"<<endl;
    cout<<"'8'Count"<<endl;
    cout<<"'9'ClearScreen"<<endl;
    cin>>option;
    cout<<endl;
    switch(option){
    case 0: exit(0);
    break;
    case 1:{if(q1.isempty())
    cout<<"queue is empty"<<endl;
    else
    cout<<"queue is not empty"<<endl;
    }
    break;
    case 2:{if(q1.isfull())
    cout<<"queue is full"<<endl;
    else
    cout<<"queue is not full"<<endl;
    }
    break;
    case 3:{cout<<"enque is called,value:";
    cin>>value;
    q1.enque(value);
    }
    break;
    case 4: q1.deque();
    break;
    case 5:q1.display();
    break;
    case 6:{cout<<"peek option is called, position:";
    cin>>position;
    q1.peek(position);
    }
    break;
    case 7:{cout<<"change option is callednposition:";
    cin>>position;
    cout<<"value:";
    cin>>value;
    q1.change(position,value);
    }
    break;
    case 8:{cout<<"the total no. of elements isn array:"<<q1.count()<<endl;
    }
    break;
    case 9:{system("cls");
    }
    case 11:{
    cout<<"rear=";
    q1.ree();}
    break;
    default:cout<<"enter the proper option"<<endl;
    }
    }while(option!=0);
    }//bro please help me to correct this code ,it is not storing more then two elements, if you enter third element for enque then it will replace third element with second element,

    Reply
  12. Sudhanshu Singh says:
    1 year ago

    Why we cannot have peek operation in queue data structure?

    Reply
  13. shubh gupta says:
    1 year ago

    Best explanation but in the count function it is (rear – front +1 ) but if both the rear and count are at -1 and -1 the count should be zero but it is 1..

    Reply
  14. Vikas Bisht says:
    1 year ago

    in dequeue why we have written return x, i mean we dont need that x right. could the return type of dequeue be void??

    Reply
  15. Muhammad Atif says:
    1 year ago

    You are awesome😇

    Reply
  16. Narinder Sarao says:
    1 year ago

    Awesome

    Reply
  17. Samarth says:
    1 year ago

    bhai, apke is channel ko to 1Milllion subcribers hona chaiye, itne acche aur satik tareeke se koi DS padha v skta h, vishwas nhi ho rha h!!!!!!!!…m apka bhot bhot abhari hu, jo apne itne jatil vishayon ko v itne saral aur graphics se zariye itna accha banaya ki hm ubte tk nhi!!!!!please ap CS k baaki subjects ko v graphics k zariye padhaeyega (but free m, bhai :)), taki humara bhala ho….apko ishwar sada sukhi rakhe……
    -Apka ek subscriber….

    Reply
  18. Manan Jagani says:
    1 year ago

    Your explanation is mind blowing. Through your videos i get to learn things in a single shot!
    I have one request – can you please make a video on linked list implementation of stacks and queues.

    Reply
  19. sharvari Jahagirdar says:
    1 year ago

    Your channel is like finding an oasis in Sahara Desert….. Thanks for the great explanation and endless effort !!!

    Reply
  20. Classim says:
    1 year ago

    If you add 3 element in the quee and then dénuée the first element you will have something like 0 56 34 0 0 and if you call the count function it will execute rear-front +1 which is =-1-(-1)+1=1 ;which is wrong because you still have 2 element not one so to fix this you can initialize int itemsnumber. to 0 and do for (int i=0;I<5;I++){if(arr[i]!=0) itemsnumber ++;}. It will loop through all arrays numbers and if the number is not null it will increment the item number to 1

    Reply
  21. Birender Singh says:
    1 year ago

    count shows 1, when queue is empty
    how can I solve that??

    Reply
  22. UMAR FAROOQ says:
    1 year ago

    send me code on
    umarfarooq7607@gmail.com

    Reply
  23. sandeep nayak says:
    1 year ago

    Bro your way of speaking and fluency in English is wonderful…👍👌👏👏

    Reply
  24. Ahmed Rizwan says:
    1 year ago

    I think you should check your dequeue "else" block
    it should be
    [x=arr[rear];

    arr[rear]=0;

    rear–;] in order to established FIFO or LILO
    in your code it is currently performing FILO or LIFO(stack)
    Am I right or not bro??

    Reply
  25. Himanshu Maurya says:
    1 year ago

    Sir ,
    according to my your function to check whether queue is full or not is wrong
    it should be
    bool isFull()
    {
    if(rear- front == 4)
    return true;
    else
    return false;
    }

    please tell me if i am wrong…….

    Reply
  26. Praveena says:
    1 year ago

    Bro kindly can you please make a vedio on queue by dynamic data structures

    Reply
  27. uzair niazi mix videos says:
    1 year ago

    how download this

    Reply
  28. Anisha Mundra says:
    1 year ago

    Amazing explanation

    Reply
  29. Aizaz Ali Khan says:
    1 year ago

    When we dequeue all the elements how the rear and front go to -1 as there is no change in rear in the else part of the dequeue function. Whenever i dequeue all the elements i can not enter new elements in the queue so the queue becomes useless. Can you help me?

    Reply
  30. Laxmi Gupta says:
    1 year ago

    Wow…now I know what is queue… 😌
    Thankyou sir…🙏🙏🙏

    Reply
  31. Yashwardhan Chavan says:
    1 year ago

    Awesome!!!! Understood everything..
    Thanks.

    Reply
  32. mahesh says:
    1 year ago

    Sir please 🙏🙏 🙏 do the video on queue abstract Data type

    Reply
  33. Anoop Kumar says:
    1 year ago

    Today my search ends here about QUEUE…
    best explanation…
    !!! thanks !!!

    Reply
  34. Satish Kanakappanavar says:
    1 year ago

    Good explanation

    Reply
  35. Akshit Sharma says:
    1 year ago

    Man; this is the best explanation I have ever heard in a YouTube video

    Reply
  36. Simple Snippets says:
    1 year ago

    Hey Guys, if you want more such tech educational videos on this channel then please support me by subscribing to this channel & also share it with your friends as it helps me create more content just for you ✌

    Reply
  37. Kuntal Gupta says:
    1 year ago

    even if the queue is empty, the COUNT shows 1.
    Please correct that exception.
    .
    .
    Good work man!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tin Hot

Tips&Tricks for a Faster Startup in Windows 10

Tips&Tricks for a Faster Startup in Windows 10

July 2, 2020
CTDL&GT: Tạo Queue bằng danh sách liên kết đơn

CTDL&GT: Tạo Queue bằng danh sách liên kết đơn

July 2, 2020
std::queue In C++ | STL C++

std::queue In C++ | STL C++

July 2, 2020
Cách Diệt Virus USB Không Cần Phần Mềm

Cách Diệt Virus USB Không Cần Phần Mềm

July 2, 2020
5 ứng dụng phải xóa nếu muốn máy Android giảm giật lag

5 ứng dụng phải xóa nếu muốn máy Android giảm giật lag

July 2, 2020
Quét UID Facebook Khách Hàng Tiềm Năng

Quét UID Facebook Khách Hàng Tiềm Năng

July 2, 2020

anniesnannies-seattle-logo

Anniesnannies-seattle.com – Tin hay đa dạng cập nhật 24h mỗi ngày về game, âm nhạc, du lịch trải nghiệm, chia sẻ về tình yêu. Cùng với đó là tin công nghệ giáo dục hợp xu thế mới

 

  • Chính Sách Bảo Mật
  • home
  • Liên Hệ

© 2021 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Du Lịch
  • Công Nghệ
  • Học Tiếng Anh

© 2021 JNews - Premium WordPress news & magazine theme by Jegtheme.