You are on page 1of 31

2019

Look forward,
learn modern
knowledge, and
do not waste
time in studies
of old subjects of
no values.

Lab Manual
B.Sc. (CA)
SEMESTER - II

CCB-2P2: LABORATORY COURSE - II

DEPARTMENT OF COMPUTER SCIENCE

ALIGARH MUSLIM UNIVERSITY ALIGARH


CREDITS
Lab Manual Design Committee:
 Prof. Mohammad Ubaidullah Bokhari
 Dr. Arman Rasool Faridi
 Dr. Faisal Anwar
 Dr. Aasim Zafar (Convener)

Editor:
 Dr. Aasim Zafar

Design & Compilation:


 Mr. Sunil Kumar Sharma

First Edition: July 2017


Approved by BoS, Dated– 31/07/2017

Department of Computer Science, A.M.U., Aligarh, (U.P.), India


COURSE TITLE: Laboratory Course-II COURSE CODE: CCB – 2P2
CREDIT: 02 PERIODS PER WEEK: 03
CONTINUOUS ASSESSMENT: 40 EXAMS: 60

COURSE DESCRIPTION
This manual is intended for the Second year students in the
subject of Programming with Python. This manual typically contains
practical/Lab Sessions related to Programming with Python covering
various aspects in order to enhance subject understanding.

Python is a general purpose, high-level programming language;


other high-level languages you might have heard of C++, PHP, and
Java. Virtually all modern programming languages make us of an
Integrated Development Environment (IDE), which allows the
creation, editing, testing, and saving of programs and modules. In
Python, the IDE is called IDLE (like many items in the language, this is a
reference to the British comedy group Monty Python, and in this case,
one of its members, Eric Idle).

Many modern languages use both processes. They are first


compiled into a lower level language, called byte code, and then
interpreted by a program called a virtual machine. Python uses both
processes, but because of the way programmers interact with it, it is
usually considered an interpreted language.

There are two ways to use the Python interpreter: shell mode and
script mode. In shell mode, you type Python statements into the Python
shell and the interpreter immediately prints the result. In script mode,
you type statements into the editor and save it in a file known as script.
The interpreter executes the code of the script.
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 2


Students are advised to thoroughly go through this manual rather
than only topic mentioned in the syllabus as practical aspects are
the key to understanding and conceptual visualization of theoretical
aspects covered in the books.

Also, this course is designed to review the concepts of Data


Structure using C, studied in previous semester and implement the
various algorithms related to different data structures. Good Luck for
your Enjoyable Laboratory Sessions.

CONTENT
This course is designed to provide the students the opportunity of
learning both – concepts of C, implementing algorithms of data
structures and programming with Python. This course is indented to
develop a deep understanding of various operations on data structure
such as searching, sorting, insertion, deletion and traversing and
provides students the idea of new programming language. Apart from
basic concepts, it helps to understand the concept of lists, tuples,
dictionaries and file handling.

OBJECTIVES
This course is designed to help students in:

 Learning the concepts of different data structures using C.

 Learning different sorting (Bubble Sort, Insertion Sort, Merge


Sort, Heap Sort, Quick Sort) and searching (Linear and Binary)
techniques using C.

 Learning Linked List, Queue, Stack and their operations using C.


AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 3


 Learning non-linear data structures such as Binary Tree, Binary
Search Tree etc. and their operations using C.

 Learning Graphs and their operations using C.

 Learning Python programming

OUTCOMES
After completing this course, the students would be able to:

 Understand and implement the different data structure using C.

 Understand and implement different sorting (Bubble Sort,


Insertion Sort, Merge Sort, Heap Sort, Quick Sort) and
searching (Linear and Binary) techniques using C.

 Understand and implement Linked List, Queue, Stack and their


operations using C.

 Understand and implement non-linear data structures such as


Binary Tree, Binary Search Tree etc. and their operations using
C.

 Understand and implement Graphs and their operations using C.

 Write, debug and execute Python programs to solve various


problems.

RULES AND REGULATIONS

Students are required to strictly adhere to the following rules.


AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 4


 The students must complete the weekly activities/assignments
well in time (i.e., within the same week).
 The students must maintain the Lab File of their completed
activities/assignments in the prescribed format (Appendix-1).
 The students must get the completed weekly
activities/assignments checked and signed by the concerned
teachers in the Lab in the immediate succeeding week. Failing
which the activities/assignments for that week will be treated as
incomplete.
 At least TEN (10) such timely completed and duly signed weekly
activities/assignments are compulsory, failing which students will
not be allowed to appear in the final Lab Examination.
 The students need to submit the following three deliverables for
each exercise duly signed by the Teacher:
 Algorithm
 Flow Chart
 Coding
 Input /Output
 Each question will be evaluated on a scale of 10 points, 4 for
Algorithm, 3 for Flow Chart and 3 for Coding part.
 The students need to ensure that each question is assessed and
signed by the Teacher in the week/time.
 Late submission would not be accepted after the due date.
Cooperate, collaborate and explore for the best individual
learning outcomes but copying is strictly prohibited.
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 5


APPENDIX-1
Template for the Index of Lab File
WEEK NO.

SIGNATURE

PAGE NO.
OF THE
PROBLEMS WITH DESCRIPTION TEACHER
WITH DATE

1#

1 2#

3#

1#

2 2#

3#

1#

3 2#

3#

1#

4 2#

3#

Note: The students should use Header and Footer mentioning their roll no. & name in footer and page no in header.
WEEK #1
 To understand concept of control construct, arrays,

recursion, string functions and pointers in C.


OBJECTIVES

 To learn the following in Shell and Script mode:-

 The basic printing command is print.

 Different operators (+, -, *, /, %).

 Integer and floating number arithmetic.

 PEDMAS Law.

After completing this, the students would be able:


OUTCOMES

 to understand the concepts of control construct arrays,


recursion, string functions and pointers in C.
 to write and run a simple Python statement/ programs
in Shell and Script mode.

Note: When naming a Python program, a .py extension must be used. Failing
to do so will result in code that will not be recognized by the system as a Python
program.

PROBLEMS
S
1# Scenario: A courier company has number of items to be delivered to its
intended customers through its salesman. The salesman visits following cities
to deliver the respective items:

S. NO. CITIES NO. OF ITEMS

1. Aligarh 18
2. Agra 25
3. Baroda 13
4. Banaras 43
5. Chennai 8
6. New Delhi 67
7. New Jalpaiguri 29
8. Howrah 11
9. Kolkata 56
10. Mumbai 33

Solve the following problems based on the above mentioned scenario


using C:
a) Write a program to store and display the above mentioned cities and
corresponding items using arrays.
b) Write a program to display name of cities where salesman has delivered
maximum and minimum number of items.
c) Write a program to search the number of items to be delivered of a user
supplied city.
2# Use interactive Shell to print the Hello
Example: print „Hello, World‟
3# Start the Python interpreter and use it as a calculator i.e. Use interactive shell
to perform the following operations
2 + 3, 5*3, 7-2, 6/2, 6/4, 6%4, 6%2, 2*4-3, 4-2*6-4
4# Write a program in Python programming and save it firstProgram.py to
perform the following operations:
2 + 3, 5*3, 7-2, 6/2, 6/4, 6%4, 6%2
5# Write a program in Python programming and save it second Program.py to
display the following messages
“Hello World, Python is High level, General-purpose Programming
language”
“ Guido Van Rossum invented the Python programming language in 1990s”
.
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 8


WEEK #2
 To understand concept of control construct, arrays,
recursion, string functions and pointers using C
(continues...).
 To learn different data types (int, float and string) in
OBJECTIVES

Python.
 To learn the rules to define variables in Python.
 To learn the use of Assignment (=) and comparison (==)
operators in Python.
 To learn the special use of + for string concatenation in
Python.
 To learn the basic input receiving command is raw_input
in Python.

After completing this, the students would be able:


OUTCOMES

 to understand the concepts of control construct arrays,


recursion, string functions and pointers using C
(continues...).
 to learn how to input character, variables/keywords,
evaluate expressions.

Note: To Learn three basic types of simple variables in Python: integers (whole
numbers, commonly used as an index), floats (that is, numbers with a decimal
point, AKA real numbers), and strings (collections of alphanumeric characters
such as names, sentences, or numbers that are not manipulated
mathematically such as a part number or zip code).
The first assignment to a variable creates it. The variable types don’t need to be
declared. Python figures out the variable types on its own.
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 9


PROBLEMS
S
1# Based on the previous scenario, do the followings using C:

a) Write a program to find total number of items delivered using recursive


function additem().

b) Write a program to display name of the cities along with their length, and
identity cities composed of two words.
c) The number of items of „Agra‟ and „Kolkata‟ are accidently interchanged.
Correct them by writing a swap function using pointers.

2# Write a program to find SUM and MULTIPLY of any three numbers.


3# Write a program to find the average of any five numbers.
4# Write a program to find simple interest.
5# Write a program to convert Celsius into Fahrenheit temperature.
6# Write a program to find perimeter of Rectangle.
7# Write a program to find circumference of Circle.
8# The volume of a sphere with radius r is 43 πr3. Write a Python program
which accepts the radius of a sphere and computes the volume. What is the
volume of a sphere with radius 5?
9# Suppose the cover price of a book is Rs 240.95, but bookstores get a 40%
discount. Shipping costs Rs 30 for the first copy and 75 cents for each
additional copy. What is the total wholesale cost for 60 copies?
10# Write a Python program which accepts the radius of a circle from the user
and compute the area.
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 10


WEEK #3
 To understand concept of class, inheritance, operator
overloading and file handling using C.
OBJECTIVES

 To learn the concept of function in Python.


 To learn Built-in functions: Type conversion and Math
functions in Python.
 To learn the user-defined functions: Definitions and use
in Python.
 To learn the Function: Flow of execution, parameters and
arguments and fruitful and void functions in Python.

After completing this, the students would be able:


OUTCOMES

 to understand the concepts of class, inheritance,


operator overloading and file handling using C .
 to write, debug and run a simple Python functions.
 to learn how to define user-defined functions and pass
arguments to functions in Python.

PROBLEMS
S
1# Scenario: A university has different entities such as Department, Programs
and Student whose data members and member functions are given below:
 Teacher- { Data Members: Name, department, hours, programsTaught;
Member Function: setDetails(), getDetails()}
 Program- {Data Members: Name, department, duration;
Member Functions: setDetails(), getDetails()}
 Student- {Data Members: Name, RollNo, Program, Department}
Member Function: setDetails(), getDetails()}
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 11


Solve the following problems based on the above mentioned scenario
using C:
a) Write a program to create Teacher, Program and Student Classes with above
mentioned data members and member functions.
b) Add following functionalities in the above program; the default
department of Teacher, Program and Student should be „Computer Science‟;
however a different department could be assigned at run time.
c) Write a program to overload „+‟ operator to add the hours of two teachers.
d) Write a program to create two subclasses „Residential Student‟ and „Non-
Residential Student‟ inherited from Student class. „Residential Student‟ would
have a data member „Hall of Residence‟ and „Non-Residential Student‟ would
have „Address‟ as its data member.

2# Write a Python program which accepts the inputs from the user and do
the following using functions.
a) To find largest of 3 numbers.(Function)
b) To generate first 4th Fibonacci term.(function)
c) To compute factorial of an integer n recursively.(function)
d) To find volume of cylinder or cube or rectangular box.
e) To find area of rectangle.
f) To find circumference of circle.(Using constructor)
g) To exchange the values of two variables
h) To find the distance between two points.

AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 12


WEEK #4
OBJECTIVES  To understand concept of class, inheritance, operator
overloading and file handling using C (continues…).
 To learn Boolean Expression in Python.
 To learn the logical operators, relational operators.
 To learn the Conditional (if), Alternative (if-else).
 To learn the Chained conditional (if-elif-else), Nested
Conditional.

After completing this, the students would be able:


OUTCOMES

 to understand the concepts of class, inheritance, operator

overloading and file handling using C(continues…).

 to write, debug and run a simple Python programs based on

conditions.

PROBLEMS
S
1# Based on the previous scenario, do the followings:
a) Write a friend function to determine number of hours taught by a particular
teacher.
b) Write a program to store details of Teacher, Program and Student, each in a
separate file.
c) Write a program to read details of Student from file whose Roll No is given by
the user?
2# Write a program to find the greatest of three numbers.(use only if Statement)
3# Write a program to find smallest of three number.(use if and else statement)
4# Write a program to check the given no that is even or odd.(use if and else)
5# Write a program to check a year for leap year.( use if and else)
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 13


6# Write a program to print number of days in a month.(Chained Conditional)
7# Write a program to find the area of triangle and show its type.( use if and
else)
8# Write a program which takes a character as input from the keyboard and
convert it into capital letter if it is a small letter and Vice-Versa.(if –else)
9# Write a Python program to find those numbers which are divisible by 7 and
multiple of 5, between 1500 and 2700 (both included).
10# Write a program that ask the user for a number. Depending on whether the
number is even or odd, print out an appropriate message to the user.

AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 14


WEEK #5
 To understand concept of function template and class
template using C.
OBJECTIVES
 To learn definite iteration (For loop) and conditional iteration
(While loop) in Python.
 To learn the Conditional (if), Alternative (if-else), break and
pass statements in Python.
 To learn the recursion, flow of execution, infinite recursion in
Python.
OUTCOMES

After completing this, the students would be able to:

 to understand the concepts of function template and class


template using C.
 to write, debug and run a simple Python functions based
on iteration and recursion.

PROBLEMS
S
1# Write a function in C to swap two numbers using function template. The
numbers could be Integer or float that depends on the user inputs.
2# Create a class Matrix that has matric data members and getvalue(), setvalue()
as member functions. Write a program in C to perform Matrix operations (2-D
array implementation), Add and Multiplication using class template.
3# Write a program in Python to check a number for Armstrong. (while)
4# Write a program in Python to print factorial of a number.(for)
5# Write a program in Python to generate first n Fibonacci terms
recursively.(function)
6# Write a program in Python to compute factorial of an integer n
recursively.(function)
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 15


7# Write a program in Python that asks the user how many Fibonnaci numbers to
generate and then generates them. Take this opportunity to think about how
you can use functions. (Without recursion)
8# Write a program in Python to print the following Pattern.(for)
*
* *
* * *
* * * *
9# Write a program to print the following Pattern.(for)
A
A B C
A B C D E
……...
N-lines
10# Write a program to print the following Pattern.(for)
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
11# Write a Python program to construct the following pattern, using a nested for
loop.
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 16


WEEK #6
OBJECTIVES  To learn linear and binary search techniques using C.
 To learn the concept of string in Python.
 To learn the different String functions and methods.

After completing this, the students would be able to:


OUTCOMES

 to understand and implement linear and binary search


methods in a given list.
 To access individual characters in a string.
 To retrieve a substring from a string.
 Top search for a substring in a string.
 To use string methods to manipulate strings.

PROBLEMS
S
1# Write a C program to search an element in a given 2D array of integers.

2# Write a C program to implement Binary search on 1D array of Employee


structure (contains employee_name, emp_no, emp_salary), with key as
emp_no. And count the number of comparison happened.
3# Assume that the variable data refers to the string “Python rules!”. Use a string
methods to perform the following tasks:
a. Obtain a list of the words in the string.
b. Convert the string to uppercase.
c. Locate the position of the string “rules”.
d. Search a given character
e. Replace the exclamation point with a question mark.
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 17


4# Write a Python program to determine the length of the given string.
5# Write a Python program to count the number of characters (character
frequency) in a string.
6# Write a Python program to reverse the order of the characters in the given
string.
7# Write a Python program to get a string made of the first 2 and the last 2 chars
from a given a string. If the string length is less than 2, return instead of the
empty string.
8# Write a Python program which accepts the user's first and last name and print
them in reverse order with a space between them.
9# Write a Python program to calculate the length of a string.
10# Write a program (using functions!) that asks the user for a long string
containing multiple words. Print back to the user the same string, except with
the words in backwards order. For example, say I type the string:
My name is Michele
Then the output will be: Michele is name My.
11# Ask the user for a string and print out whether this string is a palindrome or
not. (A palindrome is a string that reads the same forwards and backwards.)

AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 18


WEEK #7
OBJECTIVES  To learn Bubble and Selection sorting techniques using C.
 To learn about list and its associated operations in
Python.
 To learn the various list operations (Map, filter and
reduce)in Python.

.
After completing this, the students would be able to:

 to understand and implement Bubble and Selection sort


OUTCOMES

using C.
 to construct lists and access items in those lists.
 to use methods to manipulate lists.
 to perform traversals of lists to process items in the lists
 to define simple functions that expect parameters and return
values.

PROBLEMS
S
1# Write a C Program to sort a given list of Integers using Bubble sort technique.

2# Write a C Program to sort a given list of Integers using Selection sort


technique.

3# Write a Python program to create an array of 5 integers and display the List
items. Access individual element through indexes.

4# Write a Python program to reverse the order of the items in the array.

5# Write a Python function to sum all the numbers in a list.

6# Write a Python function to multiply all the numbers in a list.

7# Take a list, say for example this one


AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 19


a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 85 ]

a) Write a program that prints out all the elements of the list that are less
than 5.

b) Instead of printing the elements one by one, make a new list that has all
the elements less than 5 from this list in it and print out this new list.

c) Ask the user for a number and return a list that contains only elements
from the original list a that are smaller than that number given by the user.

8# Let‟s say I give you a list saved in a variable: a = [1, 4, 9, 16, 25, 36, 49, 64,
81, 100]. Write one line of Python that takes this list a and makes a new list
that has only the even elements of this list in it.

9# Write a program to find the sum of n numbers. (List)

10# Write a program to find the average of n numbers.(List)

11# Write a program to find maximum/minimum value of n numbers.(List)

12# Write a program to search a given element in the list.

13# Write a program to sort the given list of elements.

14# Write a program to perform binary search.

15# Write a function called most_frequent that takes a string and prints the letters
in decreasing order of frequency. Find text samples from several different
languages and see how letter frequency varies between languages.

AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 20


WEEK #8
OBJECTIVES  To learn Insertion and Quick sorting techniques using C.
 To learn about dictionary, how to create a dictionary.
 To learn the various dictionary operations and methods.
 To learn the reverse search method.

.
OUTCOMES

After completing this, the students would be able:


 to understand and implement Insertion and Quick sort.
 to construct dictionaries and access entries in those
dictionaries
 to use methods to manipulate dictionaries
 to decide whether a list or a dictionary is an appropriate
data structure for a given application.

PROBLEMS
S
1# Write a C Program to sort a given list of Integers using Insertion sort technique.

2# Write a C Program to sort a given list of Integers using Quick sort technique.
3# Assume that the variable data refers to the dictionary {“b”:20, “a”:35}.

Write the values of the following expressions:

 data[“a”]

 data.get(“c”, None)

 len(data)

 data.keys()

 data.values()

 data.pop(“b”)
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 21


4# Assume that the variable data refers to the dictionary {“b”:20, “a”:35}.

Write the expressions that perform the following tasks:

a) Replace the value at the key “b” in data with that value‟s negation.

b) Add the key/value pair “c”:40 to data.

c) Remove the value at key “b” in data, safely.

d) Print the keys in data in alphabetical order.

5# Write a python program to read a string and count how many times each letter
appears. (Histogram)

6# Write a python program to create a dictionary, read a value from the user and
search the key element (Reverse lookup).

7# Write a python program to create two dictionaries and merge them.

AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 22


WEEK #9
OBJECTIVES  To learn how to create a linked list and perform different
operations on it using pointer concepts.
 To learn the concept of file and its associated operations
in Python.
 To learn File handling methods.
 To learn Format operator.
 To learn Handling exceptions.

After completing this, the students would be able:


OUTCOMES

 to understand and implement linked list and perform its


different operations using pointer concepts.
 to write, debug and run program that handles file.

PROBLEMS
S
1# Write a C program to create a Linked List and perform the following
operations:

a. Function called InsertAtMiddle to add node in the middle of list.

b. Function called InsertBefore to add node before Nth node.

c. Function called InsertEnd to add node at the tail of linked list.

d. Function called DeleteAfter to delete node after Nth node.

e. Function called DeleteNode to delete a node having specific value.

2# Write a C program to append a Linked List L2 into a given Linked List L1. L1
contains N1 nodes with header H1 and L2 contains N2 nodes with header
H2.
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 23


3# Write a code segment that opens a file named myfile.txt for input and prints
the number of lines in the file.
4# Write a code segment that opens a file for input and prints the number of
four-letter words in the file.
5# Write a python program which reads itself and prints the number of lines in
the file.
6# Write a python program which reads an integer/floating point number and
stores it in a file (Format operator).
7# Receive the filename from the user, open the file (say firstFile) and perform
the following:
a) Count the sentences in the text.
b) Count the words in the text.
c) Count the syllables in the text.
d) Create a new file (secondFile) and copy the text from first file.

AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 24


WEEK #10
OBJECTIVE  To learn how to create a linked list and perform different
S operations on it using pointer concepts (continues…).

After completing this, the students would be able to


OUTCOME

understand and implement linked list and perform its


S

different operations using pointer concepts (continues...).

PROBLEMS
S
1# Write a C program that reverses a given list L with header H while traversing it
only once. Each node should point to the node that was previously its
predecessor; the head should point to the node that was previously at the end
and the node that was previously at beginning should be last node.

2# Write a C program to implement circular doubly linked list and perform the
following operations:

a. Adding node to the linked list

b. Traversing the whole list

c. Deleting nodes from the list


AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 25


WEEK #11
OBJECTIVE  To learn how to create Stack and perform its different
S operations.

.
OUTCOMES

After completing this, the students would be able to


understand and implement Stack and perform its different
operations.
.

PROBLEMS
S
1# Write a C program to create a Stack and perform the following operations:

a. push an Element to the stack

b. pop an element from stack

2# Write a C program to implement a 4-stacks of size „m‟ in an array of size „n‟


with all the basic operations such as IsEmpty(i), Push(i), Pop(i), IsFull(i) where
„i‟ denotes the stack number (1,2,3,4), m n/4. Stacks are not overlapping each
other. Leftmost stack facing the left direction and other three stacks are facing
in the right direction.
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 26


WEEK #12
OBJECTIVE  To learn some of the applications of Stack.
S
OUTCOME

After completing this, the students would be able to


understand the practical usage of Stack with the help of
S

implementing its some applications.

PROBLEMS
S
1# Write a C program to check whether an expression has balanced parentheses
using array implementation of a stack.

2# Write a C program to evaluate a postfix expression using array implementation


of a stack.

AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 27


WEEK #13
OBJECTIVE  To learn how to create Queue and perform its
S different operations.

After completing this, the students would be able to


OUTCOMES

understand and implement Queue and perform its different


operations.

PROBLEMS
S
1# Write a C program to create a Queue and perform the following operations:

a. Insert an Element from Queue

b. Delete an element from Queue

2# Write a C program to move all the items from a queue onto stack.
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 28


WEEK #14 – 15
OBJECTIVE  To learn the concept of Binary tree, Binary Search Tree
S and their different functions.
OUTCOME

After completing this, the students would be able to


understand and implement Binary tree, Binary Search Tree
S

and their different functions.

PROBLEMS
S
1# Write a C program to implement Binary tree insertion.

2# Write a C program to implement Post-order, pre-order and In-order traversal of


the Binary tree.

3# Write a C program for Binary Search Tree to implement following operations:


a. Insertion
b. Finding an element
c. Finding Min element
d. Finding Max element.
AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 29


WEEK #16
OBJECTIVE  To learn the concepts of Graph and their different
S functions.
OUTCOME

After completing this, the students would be able to


understand and implement Graph and their different
S

functions.

PROBLEMS
S
1# Write a C program to implement graph using array and linked-list.
2# Write a C program to implement Breadth-First and Depth-First Traversal of
Graphs.
3# Write a C program to implement Dijkstra‟s Single Source Shortest Path
Algorithm.

AMU
AMU

CSD

LAB MANUAL/B.Sc. (CA)/CCB–2P2/CSD-AMU 30

You might also like