Explain in your own words the Analysis of each Array list operation (add, remove and find)?
Consider a Dynamic Array declared inside the code using int* z = new int[10]; . How we will free the memory after we are done with the z array?
Consider a Dynamic Array declared inside the code using int* z = new int[10]; . How we will free the memory after we are done with the z array?
Explain in your own words the Analysis of each Array list operation (add, remove and find)?
Q: Explain the given code in your own words.
find(X): traverse the array until X is located.
int find(int X)
{
int j;
for(j=1; j < size+1; j++ )
if( A[j] == X ) break;
if( j < size+1 ) { // found X
current = j; // current points to where X found
return 1; // 1 for true
}
return 0; // 0 (false) indicates not foundCreate a base class called shape. Use this class to store two double type values that could be used to compute the area of figures. Derive two specific classes called triangle and rectangle from the base shape. Add to the base class, a member function setData(int, int) to initialize base class data members and another member function displayArea( ) to compute and display the area of figures.
A. The Fibonacci numbers are the numbers in the following integer sequence.
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation.
Fn = F n-1 + F n-2
B. Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example, factorial of 6 is 6*5*4*3*2*1 which is 720.
n! = n * (n - 1) * …….. 1
Write the algorithms to display the Fibonacci series and the factorial value for a given number using Pseudo code.
For the given code you task is to to implement the following:
1)destructor LList::~LList ()
struct Node {
int data;
Node *next;
class LList {
public:
LList(); ~LList();
private:
Node *head;
int size;
};
LList::LList ()
{
head = NULL;
size = 0; }