-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew.html
More file actions
198 lines (174 loc) · 6.16 KB
/
new.html
File metadata and controls
198 lines (174 loc) · 6.16 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Search Algorithm Selector</title>
<style>
body {
font-family: 'Roboto', sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(135deg, #1f1c2c, #928dab);
color: #f0f0f0;
}
.container {
width: 90%;
max-width: 800px;
text-align: center;
background: rgba(255, 255, 255, 0.1);
padding: 30px 40px;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
border: 1px solid rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
}
h1 {
font-size: 2rem;
margin-bottom: 20px;
color: #ffffff;
text-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}
label {
display: block;
text-align: left;
margin: 10px auto 5px;
width: 90%;
font-size: 14px;
color: #d1d1e0;
}
input {
width: 90%;
padding: 12px;
font-size: 16px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.1);
color: #ffffff;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
input:focus {
border-color: #4caf50;
box-shadow: 0 0 10px rgba(76, 175, 80, 0.8);
outline: none;
}
button {
display: inline-block;
padding: 12px 30px;
margin: 10px;
font-size: 16px;
font-weight: bold;
color: #ffffff;
background: linear-gradient(45deg, #4caf50, #81c784);
border: none;
border-radius: 8px;
cursor: pointer;
text-transform: uppercase;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
button:hover {
transform: translateY(-3px);
box-shadow: 0 5px 15px rgba(76, 175, 80, 0.6);
}
.result {
background: rgba(0, 0, 0, 0.6);
margin: 20px auto;
padding: 15px;
border-radius: 10px;
color: #f5f5f5;
font-size: 16px;
font-weight: bold;
}
.visualizer-buttons {
margin-top: 20px;
}
.visualizer-buttons button {
background: linear-gradient(45deg, #3f51b5, #5c6bc0);
}
.visualizer-buttons button:hover {
box-shadow: 0 5px 15px rgba(63, 81, 181, 0.6);
}
@keyframes fadeIn {
from {
opacity: 0;
transform: scale(0.9);
}
to {
opacity: 1;
transform: scale(1);
}
}
.container {
animation: fadeIn 0.5s ease-out;
}
</style>
</head>
<body>
<div class="container">
<h1>AI Search Algorithm Selector</h1>
<div>
<label for="inputData">Enter Input Data (comma-separated values):</label>
<input type="text" id="inputData" placeholder="e.g., 1,2,3,4,5">
</div>
<div>
<label for="searchValue">Enter Search Value:</label>
<input type="number" id="searchValue" placeholder="e.g., 4">
</div>
<button onclick="runAlgorithm('BFS')">Run BFS</button>
<button onclick="runAlgorithm('DFS')">Run DFS</button>
<button onclick="runAlgorithm('UCS')">Run UCS</button>
<div id="resultContainer" class="result" style="display: none;">
<h2>Result</h2>
<p id="algorithmResult"></p>
</div>
<div class="visualizer-buttons">
<button onclick="window.location.href='./indexBfs.html'">BFS Visualizer</button>
<button onclick="window.location.href='./indexDfs.html'">DFS Visualizer</button>
<button onclick="window.location.href='./indexUcs.html'">UCS Visualizer</button>
</div>
</div>
<script>
function runAlgorithm(algorithm) {
const inputData = document.getElementById('inputData').value.split(',').map(Number);
const searchValue = Number(document.getElementById('searchValue').value);
let result = '';
if (algorithm === 'BFS') {
result = bfs(inputData, searchValue);
} else if (algorithm === 'DFS') {
result = dfs(inputData, searchValue);
} else if (algorithm === 'UCS') {
result = ucs(inputData, searchValue);
}
document.getElementById('resultContainer').style.display = 'block';
document.getElementById('algorithmResult').textContent = `Algorithm: ${algorithm}, Result: ${result}`;
}
function bfs(data, target) {
const queue = [...data];
while (queue.length > 0) {
const current = queue.shift();
if (current === target) return `Found ${target}`;
}
return `${target} not found`;
}
function dfs(data, target) {
const stack = [...data].reverse();
while (stack.length > 0) {
const current = stack.pop();
if (current === target) return `Found ${target}`;
}
return `${target} not found`;
}
function ucs(data, target) {
const sortedData = [...data].sort((a, b) => a - b);
for (const value of sortedData) {
if (value === target) return `Found ${target}`;
}
return `${target} not found`;
}
</script>
</body>
</html>