Visvesvaraya Technological University: Computer Graphics & Visualization Laboratory With Miniproject 18Csl67
Visvesvaraya Technological University: Computer Graphics & Visualization Laboratory With Miniproject 18Csl67
Visvesvaraya Technological University: Computer Graphics & Visualization Laboratory With Miniproject 18Csl67
Submitted By:
KISHAN S (4VV18CS067)
K YASHAWANTH (4VV18CS061)
CERTIFICATE
This is to certify that the mini-project report entitled “Operations on Double-Ended Queue
using OpenGL” is a bona fide work carried out by K Yashawanth(4VV18CS061) and
Kishan S(4VV18CS067) students of 6th semester Computer Science and Engineering,
Vidyavardhaka College of Engineering, Mysuru in partial fulfillment for the award of the
degree of Bachelor of Engineering in Computer Science & Engineering of the
Visvesvaraya Technological University, Belagavi, during the academic year 2020-2021. It
is certified that all the suggestions and corrections indicated for the internal assessment have
been incorporated in the report deposited in the department library. The report has been
approved as it satisfies the requirements in respect of mini-project work prescribed for the
said degree.
(Prof. Pavan Kumar S P) (Prof. Gururaj H L) (Dr. Ravikumar V)
1)
2)
ABSTRACT
Dequeue is sometimes written dequeue, but this use is generally deprecated in technical
literature or technical writing because dequeue is also a verb meaning "to remove from a
queue". Nevertheless, several libraries and some writers, such as Aho, Hopcroft, and
Ullmanin their textbook Data Structures and Algorithms, spell it dequeue. John Mitchell,
author of Concepts in Programming Languages, also uses this terminology.
This differs from the queue abstract data type or first in first out list (FIFO),
where elements can only be added to one end and removed from the other. This general data
class has some possible sub-types: An input-restricted deque is one where deletion can be
made from both ends, but insertion can be made at one end only. An output-restricted deque
is one where insertion can be made at both ends, but deletion can be made from one end only.
Both the basic and most common list types in computing, queues and stacks can be
considered specializations of deques, and can be implemented using deques. The dynamic
array approach uses a variant of a dynamic array that can grow from both ends, sometimes
called array deques. These array deques have all the properties of a dynamic array, such as
constant-time random access, good locality of reference, and inefficient insertion/removal in
the middle, with the addition of amortized constant-time insertion/removal at both ends,
instead of just one end. Three common implementations include:
Allocating deque contents from the center of the underlying array, and resizing the
underlying array when either end is reached. This approach may require more frequent
resizing and waste more space, particularly when elements are only inserted at one end.
ACKNOWLEDGEMENT
The Mini-project would not have been possible without the guidance,
assistance and suggestions of many individuals. I would like to express our deep sense
of gratitude and indebtedness to each and every one who has helped me to make this
project a success.
We heartily thank our beloved Principal, Dr. B Sadashive Gowda for his
whole hearted support and for his kind permission to undergo the mini-project.
We also offer our sincere thanks to our family members and friends for their
valuable suggestions and encouragement.
1. INTRODUCTION 01
1.1 Overview
1.2
Operations On Double-Ended Queue 18CSL67
Chapter 1
INTRODUCTION
1.1 Introduction to Project
In computer science, a double-ended queue (abbreviated to dequeue) is an abstract data type
that generalizes a queue, for which elements can be added to or removed from either the
front (head) or back (tail). It is also often called a head-tail linked list, though properly this
refers to a specific data structure implementation of a de-queue. Our project takes uses input
and the element where ever required by user i.e. backend Or frontend and also lets us delete
from frontend or backend.
Chapter 2
INTODUCTION TO TECHNOLOGY USED
2.1 Visual Studio - 2019
GPL). GCC has played an important role in the growth of free software, as both a tool and an
example.
Figure:2.3- OpenGL
information visualization, flight simulation, and video games. Since 2006 OpenGL has been
managed by the non-profit technology consortium Khronos Group.
The OpenGL Utility Toolkit (GLUT) is a library of utilities for OpenGL programs, which
primarily perform system-level I/O with the host operating system. Functions performed
include window definition, window control, and monitoring of keyboard and mouse input.
Routines for drawing a number of geometric primitives (both in solid and wireframe mode)
are also provided, including cubes, spheres and the Utah teapot. GLUT also has some limited
support for creating pop-up menus.
Chapter 3
REQUIREMENT SPECIFICATION
3.1 Software Requirement
• OS : Windows 7 or above
Mac High Sierra or above
Linux
• Front end : Visual Studio - 2019
• Back end : gcc complier
• Coding language : c++
Chapter 4
FUNCTIONS USED
Chapter 5
ALGORITHM
voidadd_item_rear()
{
intnum;
printf("\n Enter Item to insert : ");
scanf("%d",&num);
if(rear==MAX)
{
printf("\n Queue is Overflow");
return;
}
Else
{
rear++;
q[rear]=num;
if(rear==0)
rear=1;
if(front==0)
front=1;
}
}
Dept of CSE,VVCE 9
Operations On Double-Ended Queue 18CSL67
Dept of CSE,VVCE 10
Operations On Double-Ended Queue 18CSL67
if(front = rear)
front=0;
rear=0;
else
rear=rear-1;
print(“Deleted element is”,no);
Step-3 : Return
voiddelete_item_rear()
{
intnum;
if(rear==0)
{
printf("\n Cannot delete item at rear end\n");
return;
}
else{
num=q[rear];
if(front==rear){
front=0;
rear=0;
} else {
rear--;
printf("\n Deleted item is %d\n",num);
}
}
}
Dept of CSE,VVCE 11
Operations On Double-Ended Queue 18CSL67
Chapter 6
SOURCE CODE
6.1 main.cpp
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <GLUT/glut.h>
#include <ctype.h>
#include <time.h>
#include "myheader.h"
//1st function
/ initialize the values requried
voidmyinit() {
/ background
Dept of CSE,VVCE 12
Operations On Double-Ended Queue 18CSL67
//2nd function
//function to draw a square
void square(int x1, int y1, int x2, int y2) {
glBegin(GL_POLYGON);
glVertex2f(x1, y1);
glVertex2f(x1, y2);
glVertex2f(x2, y2);
glVertex2f(x2, y1);
glEnd();
}
Dept of CSE,VVCE 13
Operations On Double-Ended Queue 18CSL67
//3rd function
//function to draw the outline the square
voiddrawOutline(int x1, int y1, int x2, int y2) {
int temp;
if(x1 < x2) {
temp = x1;
x1 = x2;
x2 = temp;
}
if(y1 < y2) {
temp = y1;
y1 = y2;
y2 = temp;
}
glBegin(GL_LINES);
glVertex2f(x1, y1);
glVertex2f(x1, y2);
glVertex2f(x2, y2);
glVertex2f(x2, y1);
glEnd();
}
//4th function
//function to draw a string to the output screen
voiddrawString(const char *str, double x=0, double y=0, double size=5.0)
{ glPushMatrix();
glTranslatef(x,y,0);
glScalef(size,size,4.0);
glColor3f(1, 0, 0);
intitemCt = 0;
intlen = strlen(str);
}
glPopMatrix();
}
//13th function
//main funtion where all the action takes place
int main(intargc,char **argv) {
char number[1000];
int i, j, len;
char c;
strcpy(enter_str, "Enter Element to Queue: ");
start_of_num = strlen("Enter Element to Queue:
"); jump:
printf("\n\n\n");
printf("------------------------------------\n");
printf("Simulation of dequeueue in OpenGL\n");
printf("------------------------------------\n\n");
printf("Enter the number of elements in the dequeueue\n(Not greater than 15
and not lesser than 3):\n");
scanf("%d", &MAX);
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(SCREEN_X,SCREEN_Y);
glutInitWindowPosition(10,10);
glutKeyboardFunc(mykey);
myinit();
glutMainLoop();
return 0;
}
6.2 myHeader.h
#ifndef QUEUE_SIMULA_H
#define QUEUE_SIMULA_H
#define SCREEN_X 1000
#define BACKGROUND_R 1.0
#define BACKGROUND_G 1.0
#define BACKGROUND_B 1.0
#define BACKGROUND_A 1.0
#define SCREEN_Y 500
#define OFFSET_X 50
#define differenc 180.000000
#define fnot 20
#define ARROW_LENGTH 50
#define ENQUEUE 19
#define DEQUEUEUE1 38
#define DEQUEUEUE2 39
#define NO_OP 45
#define OPERATION_POSITION_X SCREEN_X/4+SCREEN_X/20
#define OPERATION_POSITION_Y SCREEN_Y/5
Chapter 7
SCREENSHOTS
CONCLUSION
The project is well suited for 2d and 3d objects as well as for carrying out basic
graphical functionality. However if implemented on large scale insufficient resources
as the potential to become a standard stand alone. GUI based application for
Macintosh operating system. Out of many features available the project demonstrates
some popular and commonly used features of openGL such as scalene, reshaping,
etc. these graphical function will also work in tandem with various rules involved in
Double-Ended Queue. Since this project works on dynamic values it can be used for
real time computation. OpenGL complexity and the project demonstration the scope
of OpenGL platform as a premiere developing launch pad. Hence it has indeed been
usefull in developing many algorithms. It serves as important stepping stone for
venturing into other fields of computer graphic design and application.
BIBLIOGRAPHY
Text Book :
https://www.geeksforgeeks.org/dequeue-set-1-introduction-applications/
http://scanftree.com/Data_Structure/duble-ended-queue-dequeue/