Question

(C++)Create a class node with private member data of int id (0 to 10) and char ctype (A to Z), generate random nodes and place them into a list. Sort the list according to id and display them, then mo...

(C++)Create a class node with private member data of int id (0 to 10) and char ctype (A to Z), generate random nodes and place them into a list. Sort the list according to id and display them, then move them from the list to a priority queue (basing on the ctype) and then display the contents of the queue.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You may only answer 3 questions out of the following options. Please zip all files together for submission.

1. Create a class Node that has three private member data; int val, int freq, int dest. Create a map of nodes, randomly create nodes with random val and dest (between 1 and 20) and freq 1. Add these random nodes to the map, if a node is generated that is already in the map, increase the freq by one. Allow the user to input N, the number of nodes to be created, after all have been created display the contents of the map and their frequencies.

2. Create a class Leaf, each leaf has private data of an int id. Create a list of queues of Leaf objects.

Ask the user how many Leaf objects they want, generate the Leaf objects randomly with id being from a normal distribution with a mean of 50, standard deviation of 10. All objects with 0<=id<10 should be in their own queue, 10<=id<<20 in their queue, 20<=id<30 etc. After all Leaf objects have been generated, sort the queues, make sure they have unique entries (no id appears more than once) then display the contents of the list of queues.

3. Create a class node with private member data of int id (0 to 10) and char ctype (A to Z), generate random nodes and place them into a list. Sort the list according to id and display them, then move them from the list to a priority queue (basing on the ctype) and then display the contents of the queue.

4. Create a stl list (of integers). Provide a menu to access the basic functions of a list,

a. push_front,

b. push_back,

c. insert(iterator),

d. pop_front,

e. pop_back,

f. erase(iterator),

g. display contents.

All list functions should work and will be tested.

HOWEVER, provide in the menu the option to mimic the behavior of a stack.

h. Convert to stack behavior

If that option is selected you must implement all stack functionality, and prohibit functions that are not supposed to work, you are NOT to use a stack, you are to still you a list but when an illegal option is selected, an error message should appear. Once again, all data will be still in the list, but your interface will make it behave as a stack.

5. Create a Node class that has two integer PMD, int id and int wt, Ask the user how many nodes are desired then generate random Nodes and load them into a binary tree of these nodes based on their id values. ids are random (1 to 100) and wts are random (1 to 10). Beginning at the root, perform a dijkstra’s algorithm analysis to determine the cost to reach each and every node in the tree if you begin at the root of the binary tree.

Add a comment
Know the answer?
Add Answer to:
(C++)Create a class node with private member data of int id (0 to 10) and char ctype (A to Z), generate random nodes and place them into a list. Sort the list according to id and display them, then mo...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in C++ creat a DynamicQueue class, add a new data member called count to trace the...

    in C++ creat a DynamicQueue class, add a new data member called count to trace the total number of node you have in current queue (you need to modify some member functions for adding count). Add a member function called displayQueue() to display values stored in each node in the current queue, also the total number of nodes in the queue. You also need to have a driver program (refer to Tester) to test your modified new class and new...

  • // ArrayIns.java // demonstrates insertion sort 11--- class ArrayIns private long[] a; private int nElems; //...

    // ArrayIns.java // demonstrates insertion sort 11--- class ArrayIns private long[] a; private int nElems; // ref to array a // number of data items public ArrayIns(int max) // constructor a = new long[max]; nElems - © // create the array // no items yet --- public void insert(long value) // put element into array a[nElems] = value; nElems++; // insert it // increment size public void display() // displays array contents for(int j=0; j<ntlems; 1++) 1/ for each element,...

  • Using C++ in Visual Studios Rewrite the code to use a Stack instead of a Queue....

    Using C++ in Visual Studios Rewrite the code to use a Stack instead of a Queue. You will need to think about the differences in the Stack and Queue. Think about how they operate and how the nodes may differ.   Modify the code as necessary. You will need to push to the Stack, pop from the Stack, peek at the Stack. You will need a member functions like in the example code. Your program will need to show that everything...

  • Hi I need a fix in my program. The program needs to finish after serving the...

    Hi I need a fix in my program. The program needs to finish after serving the customers from the queue list. Requeriments: Headers: DynamicArray.h #ifndef DynamicArray_h #define DynamicArray_h #include using namespace std; template class DynamicArray { V* values; int cap; V dummy; public: DynamicArray(int = 2); DynamicArray(const DynamicArray&); ~DynamicArray() { delete[] values; } int capacity() const { return cap; } void capacity(int); V operator[](int) const; V& operator[](int); DynamicArray& operator=(const DynamicArray&); }; template DynamicArray::DynamicArray(int cap) { this->cap = cap; values =...

  • I've posted 3 classes after the instruction that were given at start You will implement and...

    I've posted 3 classes after the instruction that were given at start You will implement and test a PriorityQueue class, where the items of the priority queue are stored on a linked list. The material from Ch1 ~ 8 of the textbook can help you tremendously. You can get a lot of good information about implementing this assignment from chapter 8. There are couple notes about this assignment. 1. Using structure Node with a pointer point to Node structure to...

  • Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an...

    Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...

  • Objective: GUI Layout manager Download one of the sample GUI layout program. Use any GUI layout...

    Objective: GUI Layout manager Download one of the sample GUI layout program. Use any GUI layout to add buttons to start each sort and display the System.nanoTime in common TextArea panel. The question is a bit confusing so i will try to simplify it. Using the GUI ( I made a unclick able one so you have to make it clickable), allow a user to sort the text file based on what they click on. example: if i click merge...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT