Professional Documents
Culture Documents
2 40
3 40
100
Page | 1
Question #1
Implement a recursive C++ function which takes an array of integers (arr) and the starting
(start) and ending (end) indices of a portion (part) of this array, and returns the index of the
second smallest element present in that portion of array arr. The prototype of your function
should be:
int findSecondSmallest (int* arr, int start, int end)
For example, the function call findSecondSmallest(arr,3,8) should determine and return the
index of the second smallest element present in the array arr between the indices 3 and 8
(both inclusive).
Question #2
Implement a class for Circular Doubly Linked List (with a dummy header node) which
stores integers in unsorted order. Your class definitions should look like as shown below:
class CDLinkedList;
class DNode {
friend class CDLinkedList;
private int data;
private DNode next;
private DNode prev;
};
class CDLinkedList {
private:
DNode head; // Dummy header node
public void findMiddleValue(); // find middle value of the linklist and delete it.
public void display(); // Displays the contents of linked list on screen …
};
Question #3
In this lab you are going to start implementing a class for creating and storing Binary Search
Trees (BST). Each node of this BST will store the roll number, name and CGPA of a
student. The class definitions will look like:
class StudentBST;
class StudentNode {
friend class StudentBST;
private int rollNo; // Student’s roll number (must be unique)
private string name; // Student’s name
Page | 2
private double cgpa; // Student’s CGPA
private StudentNode left; // Pointer to the left subtree of a node
private StudentNode right; // Pointer to the right subtree of a node
};
class StudentBST {
Page | 3