-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqueue.php
266 lines (240 loc) · 10.3 KB
/
queue.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?php
if(session_status()==PHP_SESSION_NONE)
{
session_start();
if(!isset($_SESSION['username']))
{
header("Location: index.php");
exit;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/Semantic/semantic.min.css">
<script src="js/jquery-3.4.1.min.js"></script>
<script src="css/Semantic/semantic.min.js"></script>
<script src="js/script.js"></script>
<script src="js/questions.js"></script>
<link rel="stylesheet" href="css/home.css">
<link rel="icon" href="images\dscelogo.png">
<title>Queue Operations</title>
</head>
<body>
<h1 class="ui header" style="text-align:center" id = "head">
<a class="ui circular image" href="http://dsce.edu.in"><img src="images/dscelogo.jpg"></a>
<a href="titles.php">Virtual Labs</a>
</h1>
<div id="toTop"><i class="chevron up icon"></i></div>
<div>
<div class="ui light grey inverted secondary huge menu">
<a class="header item" href="index.php">
Home
</a>
<a class="item" href="datastructures.php">
Data Structures
</a>
<a class="item">
About Us
</a>
<?php
if(!isset($_SESSION["username"])) echo "<a class=\"item\" href=\"login.php\">Login</a><a class=\"item\" href=\"register.php\">Register</a>";
else
{
echo "<a class=\"item\">";
echo $_SESSION['username'];
echo "</a><a class=\"item\" href=\"logoutprocess.php\">Logout</a>";
}
?>
</div>
</div>
<div class="ui container" id="cont">
<h2 class="ui header" style="font-size:35px; margin-left:10px;">
Operations on Stack
</h2>
<div class="ui stackable grid">
<div class="four wide column">
<div class="ui secondary vertical pointing menu" id="Menus">
<a class="active item" id="intro">
Introduction
</a>
<a class="item" id="prereq">
Theory
</a>
<a class="item" target="_blank" id="list">
Compiler
</a>
<a class="item" id="faq">
Quiz
</a>
</div>
</div>
<div class="twelve wide stretched column">
<div class="ui segment">
<div id="int">
Queue is an abstract data structure, somewhat similar to Stacks. ... One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first.
<br><br>
<iframe height="400px" width="100%" allowfullscreen="allowfullscreen" src="https://www.youtube.com/embed/gnYM_G1ILm0" frameborder="0"></iframe>
<br><br>
<p> A queue is a useful data structure in programming. It is similar to the ticket queue outside a cinema hall, where the first person entering the queue is the first person who gets the ticket.
<br>
Queue follows the First In First Out(FIFO) rule - the item that goes in first is the item that comes out first too.</p>
</div>
<div id="pre" style="display: none;">
<div class="ui bulleted list">
<div class="item">
A Queue is a linear structure which follows a particular order in which the operations are performed. The order is First In First Out (FIFO). A good example of a queue is any queue of consumers for a resource where the consumer that came first is served first. The difference between stacks and queues is in removing. In a stack we remove the item the most recently added; in a queue, we remove the item the least recently added.Mainly the following three basic operations are performed in the Queue:
:<br><br>
<div class="GrayBlock">
<div class="item"><strong>Enqueue:</strong>Adds an item to the queue. If the queue is full, then it is said to be an Overflow condition.</div>
<div class="item"><strong>Dequeue:</strong>Removes an item from the queue. The items are popped in the same order in which they are pushed. If the queue is empty, then it is said to be an Underflow condition</div>
<div class="item"><strong>Display:</strong> Displays the content of the queue.</div>
</div></div>
<br>
<img id="theoryImage" src="images/Queue.png">
<br>
<div class="item">
Time complexity of all operations like enqueue(), dequeue(), isFull() is O(1). There is no loop in any of the operations.Linked list implementation is easier.
</div>
</div>
<br>
</div>
<div id="lis" style="display: none;">
<div class="ui form">
<div id="compilerData">
Write a program in C to simulate the working of a queue of integers using an array. Provide the following operations:<br>
a. Insert<br> b. Delete<br> c. Display.<br><br>
<strong>Input Format:</strong><br>
Every line consists of one argument, a character. If the character is 'a', the next argument is an integer.<br>
The Character denotes the operation. 'a' is to Insert, 'b' is to Delete, and 'c' is to Display.<br>
The Integer denotes the value to Insert into the queue.<br>
Note: The program ends only when a character which is not any of the above options is entered.<br><br>
<strong>Output Format:</strong><br>
Prints one/multiple array of integers, denoting the composition of the stack.<br>
</div><br>
<div class="ui segment">
<div class="ui two column very relaxed grid">
<div class="column">
<strong>Sample Input</strong><br>
a 5<br>a 8<br>c<br>b<br>a 7<br>c<br>q
</div>
<div class="column">
<strong>Sample Output</strong><br>
5 8<br>8 7<br>
</div>
</div>
<div class="ui vertical divider">and</div>
</div>
</div><br>
<form action="compile.php" id="form" name="f2" method="POST" ><br>
<label class="writeCode">Write Your Code</label><br><br>
<!-- <div class="ui large segment" id="editor" style="height:500px;"> -->
<!-- <textarea class="field codeBlock" id="editor" name="code" rows="10" cols="50">
#include<stdio.h>
void main()
{
}</textarea><br><br> -->
<div class="ui large segment" style="height:500px;">
<div id="editor">/*Type your code here: */
#include<stdio.h>
void main()
{
}
</div>
</div>
<div>
<textarea name="editor" style="display: none;" >
</div>
<textarea style="display: none;"></textarea>
<button class="ui left floated button" onclick="myFunction()">Custom Input</button>
<div id="inputs" style="display:None;">
<br><br>
<label for="in" class="writeCode"><br>Enter Your Input</label><br><br>
<textarea class="field codeBlock" name="input" rows="10" cols="50"></textarea><br><br><br>
</div>
<input type="hidden" name="extra" value="Content of the extra variable" >
<input type="hidden" name="lang" value="c" >
<input type="hidden" name="prog" value="queue" >
<input type="submit" id="st" class="ui left floated button" value="Run Code" onclick="myFunction2()">
<input type="submit" id="subb" class="ui left floated button" value="Submit" onclick="myFunction2()"><br><br><br>
</form><br>
<div id="outputBox" style="display:None;">Output:<br><br>
<div name="output"></div><br>
</div>
</div>
</div>
<div id="faqs" style="display: none;">
<form name="quiz" id="quiz" action="quizProcess.php" method="POST">
<?php
$servername = "localhost:3306";
$db_username = "root";
$password = "1234";
$dbname = "virtuallabsdsce";
// Create connection
$conn = new mysqli($servername, $db_username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$usn=$_SESSION["usn"];
$query = "select * from user_scores where usn='$usn' and topic_name='que'";
$res=$conn->query($query);
if ($res->num_rows == 1)
{
$row = $res->fetch_assoc();
echo "Quiz already attemped!<br><br>Your score: ".$row["quiz_score"];
}
else{
$a= [1,2,3,4,5,6,7,8];
$opt = ['a','b','c','d'];
$questionno = 1;
shuffle($a);
foreach($a as $i)
{
$query = "select question from questions_ds where question_no like \"que$i\"";
$question_name = $conn->query($query);
$row = $question_name->fetch_assoc();
echo "<p>".$questionno.". ".$row['question']."<br>";
shuffle($opt);
foreach($opt as $j)
{
$option_name = $conn->query("select options_name from answer_ds where option_no like \"que$i$j\"");
$row =$option_name->fetch_assoc();
echo "<label><input type=\"radio\" name=\"que".$i."\" value=\"que".$i.$j."\">".$row['options_name']."</label><br>";
}
echo "<span id=\"que".$i."\"></span></p><br>";
$questionno += 1;
}
echo "<input type=\"hidden\" name=\"quizID\" value=\"ds.que.8\">";
echo "<div id=\"result\"><input type=\"submit\" id=\"quizSub\" class=\"ui left floated button\" value=\"Submit\"></div>";
}
$conn->close();
?>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.3/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/c_cpp");
var textarea = $('textarea[name="editor"]');
editor.getSession().on("change", function () {
textarea.val(editor.getSession().getValue());
});
// function getcodeVal(){
// var code = editor.getValue();
// console.log(code);
// }
</script>
</body>
</html>