Categories
Reviews

H2G2 on Zee Studio today!!!

Zee Studio is showing one of the bestest movies EVER today – The Hitchhiker’s Guide to the Galaxy at 10.30 PM. Oh boy, I’m so damn excited spamming everyone to watch it!


Watch the official trailer of the h2g2 movie

Zee Studio also has been showing Satyajit Ray‘s films every Sunday at 3 PM and will do so till the end of December. I tried watching last week, but Devi was too boring. This week’s Porosh Pather would’ve been more interested (his take on Midas), but I had an IIT JEE mock test today at Career Launcher (which, BTW, sucked).

In other stuff, General Pervez Musharraf has lifted the state of Emergency in the country of Pakistan, of which he happens to be the CEO (no kidding!). Even the kind General likes h2g2!

“The emergency remained in the country for 42 days.”

Ah, sweet freedom…

Categories
Uncategorised

(Circular) Queues : Implementation Using Array

/* Copyright (C) 2007 Ankur Banerjee. This program is free software: you can redistribute it and / or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For a copy of the GNU General Public License see http://www.gnu.org/licenses/gpl.html /

/ Array implementation of a Circular Queue /

#include <iostream.h>
#include <conio.h>
#include <process.h>

void main()
{
clrscr();
const int max = 5;
int ch, n, front = -1, rear = -1, q[max], i;
char choice;
do
{
clrscr();
cout<<endl<<“Program Menu”
<<endl<<“1. Insert new element”
<<endl<<“2. Delete an element”
<<endl<<“3. Show list”
<<endl<<“4. Exit”
<<endl<<“Enter your choice: “;
cin>>ch;
switch(ch)
{
case 1 : clrscr();
if (front == (rear + 1) % max)
cout<<endl<<“Queue overflow! Insertion not possible!”;
else if (front == -1 && rear == -1)
{
front = 0;
rear = 0;
cout<<endl<<“Enter number to be inserted: “;
cin>>n;
q[front] = n;
}
else
{
rear = (rear + 1) % max;
cout<<endl<<“Enter number to be inserted: “;
cin>>n;
q[rear] = n;
}
break;
case 2 : clrscr();
if (front == -1 && rear == -1)
cout<<endl<<“Queue does not exist!”;
else if (rear == 0 && front == 0)
{
n = q[front];
rear = -1;
front = -1;
cout<<endl<<“Deleted data item: “
<<n<<endl;
}
else
{
n = q[front];
front = (front + 1) % max;
cout<<endl<<“Deleted data item: “
<<n<<endl;
}
break;
case 3 : clrscr();
if (front == -1 && rear == -1)
cout<<endl<<“Queue does not exist!”;
else if(front == 0 && rear == max – 1)
{
cout<<“\nDisplaying items:\n”;
for (i = front; i <= rear; i++)
cout<<q[i]<<” “;
cout<<endl;
}
else
{
cout<<“\nDisplaying items:\n”;
for(i=front; i!=rear; i=(i+1)%max)
cout<<q[i]<<” “;
cout<<q[rear]<<endl;
}
break;
case 4 : cout<<endl<<“Exiting program”<<endl;
exit(0);
default : cout<<endl<<“You entered an invalid choice!”;
}
cout<<endl<<“Do you wish to continue? (y/n): “;
cin>>choice;
} while (choice == ‘Y’ || choice == ‘y’);
}

/ Output */

Program Menu
1. Insert new element
2. Delete an element
3. Show list
4. Exit
Enter your choice: 1

Enter number to be inserted: 41

Do you wish to continue? (y/n): y

Program Menu
1. Insert new element
2. Delete an element
3. Show list
4. Exit
Enter your choice: 1

Enter number to be inserted: 42

Do you wish to continue? (y/n): y

Program Menu
1. Insert new element
2. Delete an element
3. Show list
4. Exit
Enter your choice: 1

Enter number to be inserted: 43

Do you wish to continue? (y/n): y

Program Menu
1. Insert new element
2. Delete an element
3. Show list
4. Exit
Enter your choice: 3

Displaying items:
41 42 43

Do you wish to continue? (y/n): y

Program Menu
1. Insert new element
2. Delete an element
3. Show list
4. Exit
Enter your choice: 2

Deleted data item: 41

Do you wish to continue? (y/n): y

Program Menu
1. Insert new element
2. Delete an element
3. Show list
4. Exit
Enter your choice: 3

Displaying items:
42 43

Do you wish to continue? (y/n): y

Program Menu
1. Insert new element
2. Delete an element
3. Show list
4. Exit
Enter your choice: 4

Exiting program