[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

C++ help

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 7
Thread images: 1

File: Untitled.jpg (41KB, 1152x648px) Image search: [Google]
Untitled.jpg
41KB, 1152x648px
Anyone here a guru in c++, need help with hw that involves doubly linked lists. Will compensate for help.
>>
>>207458
post a better pic,not clear
>>
#include <iostream>

using namespace std;

class Item
{
public:
int val;
Item *next, *pre;
Item()
{
val = 0;
next = 0;
pre = 0;


}
Item(int val)
{
this->val = val;
next = 0;
pre = 0;
}

};


class DLinkedList
{

int size;
Item *front;
Item *back;

public:

DLinkedList();
DLinkedList(const DLinkedList &list);

void push_back(Item *a);
void push_front(Item *a);

Item * pop_front();
Item * pop_back();

void insert(Item *a, int t); // insert the item a after the t-th element
void insertlist(DLinkedList *list, int t); // insert the whole list a after the t-th element
void display(ostream &out);

int getSize();
Item * getfront();
Item * getback();
void swap(Item *p, Item *q); //swap two items pointed by p and q, you can assume that p and q are something in the list

Item * extractmin(Item * start); // return the pointer of the min element after "start",
// here you can assume user will always input a valid pointer start that points to an item in the list
Item * extractmax(Item * start); // return the pointer of the max element after "start"


};


class myStack
{
DLinkedList list;
public:
myStack();
int getSize();
void in(Item *a);
Item *top();
void out();

};

class myQueue
{
DLinkedList list;
public:
myQueue();
int getSize();
void in(Item *a);
Item *front();
void out();
};
int main() {


system("pause");
return 0;
}
>>
Task 1: Implement the constructors (default and copy) of DLinkedList. You need to make sure
that the copy constructor makes a separate copy of the list.
Task 2: Implement push back, push front, pop back, pop front, get front, get back, display, swap.
The functions are pretty self explanatory from their names.
Task 3: Implement Inserts. You should handle “insert an item” and “insert a list”.
Task 4: Implement extract min, extract max. They return the pointer to the min/max item in
the list. If there is a tie, then choose arbitrarily among the mins/maxes. (Explain your choice in
the writeup).
Task 5: Implement classes myQueue and myStack using DLinkedList. Do not re-write codes.
(This task is pretty easy).
Task 6: Design a test function to test your DLinkedList. You don’t need to test your Stack nor
Queue, as checking them is easy, assuming your DLinkedList is correct.
>>
I have a few questions, if anyone thinks they can help, please reply, will compensate with $$
>>
>>207480
Shoot it.
>>
>>207480
I haven't thoroughly tested this, but this should do what you want:
http://pastebin.com/5TEKXBsa
Thread posts: 7
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.