Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

All in c++! please! Assume there is a stock class which has symbol (string), and

ID: 3767937 • Letter: A

Question

All in c++! please!

Assume there is a stock class which has symbol (string), and price (int) as private members. The stock class supports streaming operator <<, equal operator ==, and less than operator <

Further assume there are classes for storing collection of stocks as follows:

DBarray.. stores stocks in a dynamic array

DBdlink.. stores stocks in a doubly-linked list

(1 pt) Write the minimum stock.h

class stock {


(1 pt) Write the minimum DBarray.h (no functions) where size of array is specified in constructor

class DBarray {


(1 pt) Write the copy constructor implementation function (i.e. cpp) for DBarray.


One way to keep DBarray sorted is to insert every element in-order. Write the implement code for the insert-in-order function void DBarray::insert-in-order(stock s).   Note that stock class supports various operators as mentioned above. You can use the data members in DBarray.h you have created in problem #2. (No need to write .h, just the cpp code.)

void DBarray::insert-in-order(stock s) {

Assume DBarray is already sorted, implement (cpp) the find function with binary search method. bool DBarray::find(stock s) which returns true if found, false if not.

bool DBarray::find(stock s) {


Write 3 different ways of creating a stockNode class that can be used in doubly-linked list DBlink.



Assume DBlink has only two stockNode pointers : first and last as data members. Write the routine to check if DBlink has a loop.

bool DBlink::hasLoop() {



Assume DBlink has only two stockNode pointers : first and last as data members.   Write the implement code for the insert-in-order function void DBlink::insert-in-order(stock s)   

void DBlink::insert-in-order(stock s) {



What is the postfix notation for a + b * ( c - (d + f )) - g



Assume the following list of keys: 7, 28, 31, 40, 8, 20, 17 and we use hash with quadratic probing. If hash table size is 10 and hash function is modulo 10, show the resulting hash table.



(1 pt) What is a heap?


Assume the following list of keys: 7, 28, 31, 5, 40, 20, 88 with large key has higher priority.
Show the resulting heap structure and list after it is heapified.


Continue previous heap problem, show the resulting structure and list after the largest key is deleted.


(1pt) Assume the following list of keys: 7, 28, 31, 5, 40, 20, 88 with large key has higher priority. Illustrate the merge sort process in a diagram.

7

28

31

5

40

20

88



Write pseudo code for merge sort.

Explanation / Answer

1.

class Stock

{

private:

     string symbol;

     int price;

public:

     Stock(string symbol,int price)

     {

          this->symbol=symbol;

          this->price=price;

     }

     int getPrice()

     {

          return this->price;

     }

     string getSymbol()

     {

          return this->symbol;

     }

     Stock operator<<(int );

     Stock operator==(int );

     Stock operator<(int );

};


2.

class DBArray:Stock

{

public:

     int size;

Stock *Stockarray;

     DBArray(int s)

     {

          size=s;

     }

};

3.

class DBArray:Stock

{

public:

     int size;

     Stock *Stockarray;

     DBArray(int s)

     {

          size=s;

     }

     ~DBArray()

     {

          delete[] Stockarray;

     }

};

Postfix notation:

The postfix notation for given expression a+b*(c-(d+f))-g is (a b c d f + - * + g -). The postfix notation first traverse the left operand, then right operand and finaly the operator.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote