Lab Assignment 2
UCS 406 Data Structures and Algorithms
Note: Use C/C++ or JAVA programming language.
Q1. If a one dimensional integer type array with its size and length given, write the code in C++
language to create functions to perform the following operations (Please assume whatever
is necessary to examplify the results) :
i. Display()
ii. Add/Append(x)
iii. Insert(index,x)
iv. Delete(x)
v. LinearSearch(s)
vi. BinarySearch(x)
vii. Get(index)
viii. Set(index,x)
ix. Max()
x. Min()
xi. Reverse()
xii. Shift()
xiii. Rotate()
Q2. For a given array, write functions to perform the following:
i. Check if an array is sorted
ii. Merge arrays
iii. Set operations on array: Union, Intersection
Q3. For a given array, write functions to perform the following:
i. Finding single element in an array
ii. Finding multiple elements in an array
iii. Finding duplicates in a sorted array
iv. Finding duplicates in an unsorted array
v. Finding a pair of elements with sum k
vi. Finding a pair of elements with sum k in sorted array
vii. Finding max and min in a single scan
Q4. For a given Linked List (LL), write programs to perform the following functions
i. Display the elements of a LL
ii. Count and sum the nodes of a LL
iii. Search for a key element in a LL
iv. Delete an element from a LL
v. Check if a LL is sorted
vi. Merge 2 LLs
vii. Concatenate 2 LLs
viii. Reverse the elements of a LL
ix. Create and Display a circular Ll
x. Create a doubly LL, insert in a doubly LL and reverse a doubly LL.