X Assignment 7 CPP.pdf Student Name: Student ID Mark Assignment 7: Pointers and Dynamic Memory Allocation You are to write a program to manipulate a list of integers as explained below This list is implemented to be expandable means it is expanded to a bigger size once it is full and more items are required to be stored in. Develop your program as follows: Define a ma in ) function that repeatedly shows the following menu to the user and proceeds accordingly Press 1 to create an expandable 1ist Press 2 to add more items to an existing 1ist Press 3 to remove an item from the 11st Press 4 to search an item in the 11st Press s to quit .In case user enters 1, program asks user to enter the initial size of the list, dynamically allocaters memory, reads a number of integers equal to the entered size, and stores them in the allocated memory. If a list already exists (ie. during the previous iterations) program releases memory of the old one and creates a new list from scratch .If user enters 2, program asks user toenter the number of integers that are to be added to the list, reads those integers, and adds them to the end of the current list. Incase there is not enough space available in the existing list, a new block of memory of enough size is allocated, all the items of the previous list are copied into the newly-created one, the new items are added. and the previous list is released If user enters 3, program asks user to enter an integer that is supposed to be removed from the list, searches the entered integer, and removes its first occurrence from the list. The removal is achieved by shifting all the items stored after the item back so the order of the items in the list doesn't change. In case the request item does not exist in the list, program displays an appropriate message on the screen. . If use enters 4, program asks user to enter an integer to search, looks for the entered integer and displays the index of its first occurrence on the screen. If the entered item does not exist in the list an appropriate message is displayed on the screen .Pressing 5 only terminates this program Requirements: To implement both the functionalities of 3 and 4, you need to search an item in the list Define a function that searches a key in a list of integers and returns the index ofthe first occurrence of the key in the list ifthe key exists in the list and returns an invalid indes otherwise. This function first sorts the input list and then applies an iterative binary search on the sorted list. Define this function so that the original list is not modifed by the function. Could you analyze the efficiency of this function? Student Name: Student Ib: Assignment 7: Pointers and Dynamic Memory Allocation You are to write a program to manipulate a list of integers as explained below This list is implemented to be expandable means it is expanded to a bigger size once it is full and more items are required to be stored in. Develop your program as follows Define a main() function that repeatedly shows the following menu to the user and proceeds accordingly Press 1 to create an expandable 1ist. Press 2 to add more items to an existing list. Press 3 to remove an item from the list. Press 4 to search an item in the list. Press 5 to quit In case user enters 1, program asks user to enter the initial size of the list, dynamically allocates memory, reads a number of integers equal to the entered size, and stores them in the allocated memory. If a list already exists (i.e. during the previous iterations) program releases memory of the old one and creates a new list from scratch. If user enters 2, program asks user to enter the number of integers that are to be added to the list, reads those integers, and adds them to the end of the current list. In case there is not enough space available in the existing list, a new block of memory of enough size is allocated, all the items of the previous list are copied into the newly-created one, the new items are added, and the previous list is released. Ifuser enters 3, program asks user to enter an integer that is supposed to be removed from the list, searches the entered integer, and removes its first occurrence from the list. The removal is achieved by shifting all the items stored after the item back so the order of the items in the list doesn't change. In case the request item does not exist in the list, program displays an appropriate message on the screen. If use enters 4, program asks user to enter an integer to search, looks for the entered integer and displays the index of its first occurrence on the screen. If the entered item does not exist in the list an appropriate message is displayed on the screen. Pressing 5 only terminates this program equirements: To implement both the functionalities of 3 and 4, you need to search an item in the list. Define a function that searches a key in a list of integers and returns the index of the first occurrence of the key in the list if the key exists in the list and returns an invalid index otherwise. This function first.sorts the input list and then applies an iterative binary search on the sorted list. Define this function so that the original list is not modified by th nction. Could you analyze the efficiency of this function