Lab Assignment 2 - 3

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Lab Assignment 2 & 3

UCS 406 Data Structures and Algorithms


Note: Use C/C++/JAVA/Python programming language.

Q1. Write a function to perform following operations on the string:

(Note: You can make single function for all operations/independent function for each
problem)

i. Finding length of a string


ii. Converting a string in lowercase
iii. Counting number of words and vowels in a string
iv. Validating a string (Note: Valid string does contain only alphabets)
v. Reversing a string (Eg. Code  edoC)
vi. Checking if a string is palindrome.
vii. Finding duplicate characters in a string (Note: print the duplicate characters only once,
irrespective of the number of times it occurred)

Q2 Write a program for finding the factorial of a number recursively.


Q3 Implement the following stack operations using arrays:

 Push
 Pop
 IsFull
 isEmpty
 Peek
 stackTop

Create a stack structure and stack class for the above said implementation.

Q4 Implement linear queue by writing a class and also implement the following functions:

 Insert or enqueue
 Remove or dequeue
 Isfull
 Isempty

Write main function to exemplify the results. Also write a main function to make the implementation
a “Menu-Driven”.

Q5 Implement priority queue by writing a class and also implement the following functions:

 Insert or enqueue
 Remove or dequeue
 Isfull
 Isempty

Write main function to exemplify the results. Also write a main function to make the implementation
a “Menu-Driven”.

Q6 Write a program to perform sorting of a given array using the following algorithms:

 Bubble sort
 Insertion Sort using arrays and linked list
 Selection Sort
 Quick Sort
 MergeSort
 Shell Sort
 Count Sort
 Radix Sort

You might also like