HTML DS Workbook
HTML DS Workbook
- CERTIFICATE -
University Seat No. : ________________ Date: / /
Marks Teacher
Sr. No Assignment
(out of 5) Sign
1. Assignment 1
2. Assignment 2
3. Assignment 3
4. Assignment 4
Objectives
To learn recursion.
Reading
You should read the following topics before starting this exercise
1. About functions.
2. Different function types and calling methods.
Ready Reference
Assume that you have to paint a few balls. If you do it alone, it will take a lot of time. One thing you
can do is to take help from your friend. Assuming that you have the same work speed, the task will be
done in half of the time. Now, instead of taking help from only one of your friends, you take help from
multiple friends such that each friend have only one ball to paint. The task will be done much faster as
compared to when you were doing it alone. Recursion is a problem-solving technique that works in a
similar way.
Recursion
Recursion in C++ is a technique in which a function calls itself repeatedly until a given condition is
satisfied. In other words, recursion is the process of solving a problem by breaking it down into smaller,
simpler sub-problems.
Syntax Structure of Recursion
return_type recursive_func {
....
// Base Condition
// Recursive Case
....
}
Recursive Function
A function that calls itself is called a recursive function. When a recursive function is called, it
executes a set of instructions and then calls itself to execute the same set of instructions with a smaller
input. This process continues until a base case is reached, which is a condition that stops the recursion
and returns a value.
Base Condition
The base condition is the condition that is used to terminate the recursion. The recursive function will
keep calling itself till the base condition is satisfied.
Recursive Case
Recursive case is the way in which the recursive call is present in the function. Recursive case can
contain multiple recursive calls, or different parameters such that at the end, the base condition is
satisfied and the recursion is terminated.
Example of C++ Recursion
The following C++ program illustrates how to perform recursion.
Step 2: While executing nSum(5), a recursive call is encountered as nSum(4). The compiler will now
create a new stack frame on top of the nSum(5)‟s stack frame and maintain an instruction pointer at the
statement where nSum(4) was encountered.
Tower of Hanoi
Tower of Hanoi, is a mathematical puzzle which consists of three towers (pegs) and more than one
rings is as depicted −
These rings are of different sizes and stacked upon in an ascending order, i.e. the smaller one sits over
the larger one. There are other variations of the puzzle where the number of disks increase, but the
tower count remains the same.
Rules
The mission is to move all the disks to some another tower without violating the sequence of
arrangement. A few rules to be followed for Tower of Hanoi are −
Only one disk can be moved among the towers at any given time.
Only the "top" disk can be removed.
No large disk can sit over a small disk.
Following is an animated representation of solving a Tower of Hanoi puzzle with three disks.
Tower of Hanoi puzzle with n disks can be solved with minimum 2n-1 steps.
Date : / /
Set A
a) Write a program to read a number from user. Write recursive function to find
factorial of that number.
b) Write a program to read number of terms. Write a recursive function to print the
Fibonacci Series upto number of terms.
Set B
a) Write a program to read two numbers from user. Write recursive function to find GCD of
that numbers.
b) Write a program to read a number from user. Write a recursive function to find the sum
of digits of a number.
c) Write a program to read a number from user. Write a recursive function to calculate the
sum of numbers from 1 to n.
Set C
a) Implement a recursive binary search algorithm to find a target value in a sorted array.
b) Implement the N-Queens problem using recursion, where the task is to place N queens on
an NxN chessboard such that no two queens threaten each other.
Assignments Evaluation:
Signature of Instructor
Objectives
To learn queue data structure.
Reading
You should read the following topics before starting this exercise
About queue operations.
Different queue types.
Ready Reference
Queue is an ordered set of elements in which insertions are done from the rear and deletions are done from the
front. It is a First in First Out ( F I F O ) structure.
Types of Queue :
1. Linear Queue : In this queue elements are arranged in a sequential manner such that front position is
always less than or equal to rear position.
2. Circular Queue : In this queue , front and rear increment circularly. The elements are arranged in a
sequential manner but can logically be regarded as arranged circularly.
3. Priority Queue : In this queue , the elements are arranged according to their priority. The queue
operations are performed according to the priority of the elements.
4. Double Ended Queue : In this type of queue , the queue operations namely Add and Remove can be
performed from both the ends. Thus this queue supports four basic operations.
1. Static Implementation
A Queue is implemented statically by using an array of size MAX to hold stack elements and two integers –
front and rear. The „front‟ stores the position of the current front element and „rear‟ stores the position of the
current rear element of the queue. A queue is a single entity that is a class made up of the array, rear and front.
The Queue elements can be integers, characters, strings or user defined types.
init (Q) – Create an empty queue by initializing both front and rear to -1 indicating the queue is empty
add (Q, x) – adding an element x to the rear end of the queue Q
delete (Q) – deletes the element from the front of the queue Q
peek (Q) - returns the front element from the queue without deleting the element from the Queue
isEmpty (Q) – check if the queue is empty, that is, when rear equals front
isFull (Q) – check if the Queue is full which happens when rear equals MAX -1
A Queue is implemented dynamically by using a Linked list where each node in the linked list has two parts,
the data element and the pointer to the next element of the queue. Since Queue should be a single entity, we
need to use only one external pointer while here we need two one for rear and one to the front. To avoid this we
use a circular linked list and Queue pointer is pointing to the rear of the queue. Front can be easily accessed as
it is next to rear. The Queue elements can be integers, characters, strings or user defined types. There is no
restriction on how big the Queue can grow.
init (Q) – Create an empty queue as a circular linked list by initializing S to NULL indicating that the queue is
empty
add (Q, x) – Adding an element x to the queue Q requires creation of node containing x and putting it next
to the rear and rear points to the newly added element. This changes the rear pointer Q and the function should
return the changed value of Q. The function call will be as follows
Q=add(Q, x);
delete (Q) – deletes the front node from the queue Q which is actually next element to the
rear pointer Q. However if queue contains only one element, (Q->next == Q) then deleting this single
element can be achieved by making empty Q (Q =NULL). Since the rear pointer Q is changed in this case,
function should return the changed value of Q. The function call will be as follows
Q=delete(Q);
peek (Q) - returns the data element in the front (Q->next) node of the Queue Q.
isEmpty (Q) – Check if the Queue is empty which is equivalent to checking if Q==NULL
a) Implement a queue of integers using a static implementation of the queue and implementing
the above six operations. Write a menu driven program that calls different queue functions.
b) Implement a queue of integers using a dynamic implementation of the queue and
implementing the above five operations. Write a menu driven program that calls different
queue functions.
Set B
a) A statically implemented queue may become full even if the initial positions in the array are
unoccupied. To avoid this situation, a wrap around can be attempted and initial positions
reused. The array can be treated as if it were circular. This can be implemented making use
of mod function. Implement a queue library (cstqueue.h) of integers using a static
implementation of the circular queue and implementing the above six operations.
b) A doubly ended queue allows additions and deletions from both the ends that is front and
rear. Initially additions from the front will not be possible. To avoid this situation, the array
can be treated as if it were circular. Implement a queue library (dstqueue.h) of integers
using a static implementation of the circular queue and implementing the seven operations
init(Q), isempty(Q), isFull(Q), addFront(Q,x), deleteFront(Q), addRear(Q,x) and
deleteRear(Q) .
Set C
a) Implement a priority queue, where each element has a priority and elements are dequeued in
order of priority rather than arrival time.
b) Implement a queue using two stacks.
c) Implement undo and redo functionality using two queues. One queue will hold the "undo"
history, and another will hold the "redo" history.
Assignment Evaluation :
Objectives
To learn tree as a data structure.
To implement tree techniques.
Reading
You should read the following topics before starting this exercise
About tree concept.
Tree traversal techniques.
Ready Reference
Tree is a recursive data structure. A Binary tree consists of a root and two disjoint binary trees
called left and right trees. In Binary search tree every element is distinct and elements in the
left subtree are smaller than the root and root is smaller than elements in right subtree.
insert (T, x) – inserts the value x in the proper position in the Binary search tree
inOrder (T) – displays the node using inorder traversal of binary search tree
postOrder (T) – displays the node using postorder traversal of binary search tree
preOrder (T) – displays the node using preorder traversal of binary search tree.
Date : / /
Set A
a) Implement a Binary search tree library ( btree.h) with above six operations. Write a menu
driven driver program to call the above functions
Set B
a) Write a program which uses Binary search tree library and implements two more functions.
Create(T, n) – inserts n nodes in the Binary search tree where the values are either
accepted from user or randomly generated (use insert)
Set C
a) How Count(T) function can be modified instead to count leaf nodes in the tree?
b) Write a delete(T, x) which deletes the node containing data element x if and only if it is a
leaf node.
c) What is the strategy to implement delete operation in case of a non leaf node?
e) How to find the minimum element in a Binary search tree? How to find the maximum element in a
Binary search tree?
Assignment Evaluation:
Objectives
Reading
You should read the following topics before starting this exercise
About graph concept.
Ready Reference
A graph consists of a set of vertices and a set of edges. The two main ways of representing graphs are
adjacency matrix representation and adjacency list representation.
In adjacency matrix representation of a Graph with n vertices and e edges, a two dimensional nxn array ,
say a , is used , with the property that a[i,j] equals 1 if there is an edge from i to j and a[i,j] equals 0 if
there is no edge from i to j.
In adjacency list representation of a graph with n vertices and e edges, there are n linked lists, one list for
each vertex in the graph.
Indegree(i) – returns the indegree (the number of edges ending on) of the ith vertex
Outdegree(i) – returns the outdegree(the number of edges moving out) of the ith vertex)
Set A
a) Write a program that accepts the vertices and edges for a graph and stores it as an
adjacency matrix. Implement functions to print indegree, outdegree and to display the
adjacency matrix.
b) Write a program that accepts the vertices and edges for a graph and stores it as an
adjacency list. Implement functions to print outdegree of any vertex i.
Set B
a) Write a program that accepts the graph as an adjacency matrix and converts it to adjacency
list representation. Write a function to display the graph in adjacency list form.
b) Write a program that accepts the graph as an adjacency matrix and checks if the graph is
undirected. The matrix for undirected graph is symmetric
Set C
a) What can be concluded about the directed graph if there is no vertex with indegree zero?
b) In the adjacency list representation the dummy head node of each linked list can be used
to store the indegree of the vertex when the adjacency list is created. Modify the program
so that every time an edge node is added to the list the head node entry is incremented.
Write a function to print indegree of vertex i.
c) A graph may not have an edge from a vertex back to itself(self-edges or self-loops). Given
an adjacency matrix representation of a graph, how to know if there are self-edges?
Date : / /
Assignment Evaluation :
Marks Teacher
Sr. No Assignment
(out of 5) Sign
1. Assignment 1
2. Assignment 2
3. Assignment 3
4. Assignment 4
5. Assignment 5
6. Assignment 6
7. Assignment 7
8. Assignment 8
Date : / /
Set A
1. Create a basic web page of your own videos that will contain any three good video clips.
2. Create a basic webpage which will contain any three audio songs of God to play.
Set B
1. Create a basic webpage which will contain any two YouTube Motivational videos.
2. Create a basic webpage which will contain any two YouTube Movie videos.
Set C
1. Create a custom audio player with play, pause, and volume control functionality.
2. Create a custom video player with controls for play, pause, and adjusting playback speed.
Assignment Evaluation:
Date : / /
Set A
1. Download or Create collage picture of three fruits images. When you click on particular
fruit, it must display information of that particular fruit on web page. (use image mapping)
2. Download and Create collage picture of all Seven Wonders of the World. When you click
on particular wonder image, it must display information of that particular wonder. (use
image mapping)
Set B
1. Create a picture in paint brush consisting of three squares. Insert this picture on webpage.
Create image map such that when you click on first square it should display web page of
Tuljaram Chaturchand college, Baramati. When you click on second square it should
display “Gallery” web page of Tuljaram Chaturchand college, Baramati. When you click
on third square it should display “Activities” web page of Tuljaram Chaturchand college,
Baramati. (use image mapping)
2. Download or Create collage picture of parts of computer images. When you click on
particular computer part, it must display information of that particular part on web page.
(use image mapping)
Set C
1. Download and Display Maharashtra.jpg image on web page consisting of different
Districts. Once click on any district, it should open new web page consisting of
information about the tourist spots in particular district.
2. Download and Display India.jpg image on web page consisting of different states. Once
click on any state, it should open new web page consisting of information about that state.
____________________________________________________________________________
Assignment Evaluation:
Date : / /
Set A
2. Write an HTML5 Canvas program to implement Gradient Fill. Create a rectangle with a
gradient fill.
Set B
Set C
1. Create an animation of a ball bouncing within the canvas.
2. Create a canvas and allow the user to draw rectangles by clicking and dragging on the canvas.
________________________________________________________________________
Assignment Evaluation:
Date : / /
Set A
1. Write an SVG program to draw a simple house using rectangles, triangles, and a circle.
Set B
1. Write an SVG program to create a SVG animation where a circle changes its color
continuously.
2. Write an SVG program to create a SVG animation of a square rotating around its center.
Set C
1. Write an SVG program to draw a flower with a circular center and six petals.
2. Write an SVG program to create an SVG rectangle that changes color when clicked.
Assignment Evaluation:
Date : / /
Set A
1. Write a CSS transition code to create a button that changes its background color when
hovered over.
2. Write a CSS transition code to create a box that grows in size when hovered over.
Set B
1. Write a CSS transition code to create a square that rotates when hovered
over.
2. Write a CSS transition code to create a circle that moves smoothly to the right when hovered
over.
Set C
1. Create a navigation menu where items change color and underline smoothly when hovered
over. ( Use CSS Transitions)
2. Build an image gallery where images smoothly zoom in when hovered over. ( Use CSS
Transitions)
__________________________________________________________________________
Assignment Evaluation:
Lab Assignments
Date : / /
Set A
1. Write a CSS animation code to create a box that moves horizontally across the screen.
2. Write a CSS animation code to create text that changes its color continuously.
Set B
1. Write a CSS animation code to create a circle that grows and shrinks continuously.
Set C
1. Write a CSS animation program to create text that slides from left to right continuously.
2. Write a CSS animation program to create text that fades in and out continuously.
_______________________________________________________________
Assignment Evaluation:
Date : / /
Set A
2. Write a JavaScript program to calculate the factorial of a number using a for loop.
Set B
1. Write a JavaScript program to print the multiplication table of a number using a while
loop.
2. Write a JavaScript program to display the day of the week based on a number input (1 for
Monday, 7 for Sunday).
Set C
1. Write a JavaScript program to accept seat number, total marks scored and number of
subjects from user and display grade for the specified student.
2. Write a JavaScript program which display three buttons for alert, prompt and confirm. If
the alert button is clicked, program should display “This is alert box” message. If the
confirm button is clicked, program should display confirm box and if OK button is clicked
it should display “You pressed OK!” or if Cancel button is clicked it should display “You
pressed Cancel!”. If the prompt button is clicked, it should ask about user input displaying
“Please enter your name”, after clicking the OK button it should display a message
including user specified name.
Assignment Evaluation:
Date : / /
Set A
1. Write a JavaScript program to create a button that changes the text content of a paragraph
when clicked.
2. Write a JavaScript program to change the background color of a box when the mouse
hovers over it and reset it when the mouse leaves.
Set B
1. Write a JavaScript program to display the key pressed by the user in real-time.
2. Write a JavaScript program to validate a form to ensure the input field is not empty before
submission.
Set C
1. Write a JavaScript program to accept username and password from the user. If either the
username or the password is blank, then display "User Name or Password cannot be
empty!". If the length of username is less than 6 or the length of username is greater than
15, display "User Name: between 6 to 15". If the length of password is less than 8 or the
length of password is greater than 20, then display "Password: between 8 to 20" (Use
onsubmit event, alert)
2. Write a JavaScript program which displays content in paragraph in blue colour. When
mouse button is clicked over the paragraph, text color changes to red and when mouse
button is released, text color changes back to blue (Hint: Use onmouseup and
onmousedown events)
Assignment Evaluation:
Total Marks 50
A) Internal : 25 Marks
B) External : 25 Marks