473,769 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

doubly link list formation

Consider the following Class definitions:

class AClass
{
int ai1;
int ai2;

public:
CClass* c;
AClass(){}

insertValues(in t parm1, int parm2){
ai1 = parm1;
ai2 = parm2;
}
};

class BClass:public AClass
{
int bi1;
int bi2;

public:
AClass* a;
BClass* b;
BClass(){}
insertValues(in t parm1, int parm2){
bi1 = parm1;
bi2 = parm2;
}

};

class CClass:public BClass
{
int ci1;
int ci2;

public:
BClass* b;
CClass(){}
insertValues(in t parm1, int parm2){
ci1 = parm1;
ci2 = parm2;
}

};

Consider a HEAD pointer BClass* BHead and create a doubly linked list
where the forward and backward chain is maintained using BClass
pointers. Each of the nodes in the chain should maintain 10 integer
values. You are free to choose how you distribute 10 integers among
the objects of a node. Plan a distribution and stick to it. You can
choose whether you want to insert new nodes at the beginning of the
list or at the end of the list. Stick to any one.

Write the following functions for the link list:

void insert(int* int10parm);

and

void delete(int* int10parm);

where <int* int10parmcontai ns 10 integers. Expect the parameter for
delete function to have integers in the same order as for the insert
function.

May 18 '07 #1
3 2669
ma************@ gmail.com wrote:
Consider the following Class definitions:

[..homework assignment snipped..]
FAQ 5.2.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 18 '07 #2
On 2007-05-18 06:15:47 -0700, ma************@ gmail.com said:
Consider the following Class definitions:
[snip]

OK, I've considered them. Now, show us what you've done so far, and
maybe someone will help you. However, nobody is going to do your
homework for you.
--
Clark S. Cox III
cl*******@gmail .com

May 18 '07 #3
<ma************ @gmail.comwrote :
Consider the following Class definitions:

class AClass
{
int ai1;
int ai2;

public:
CClass* c;
AClass(){}

insertValues(in t parm1, int parm2){
ai1 = parm1;
ai2 = parm2;
}
};

class BClass:public AClass
{
int bi1;
int bi2;

public:
AClass* a;
BClass* b;
BClass(){}
insertValues(in t parm1, int parm2){
bi1 = parm1;
bi2 = parm2;
}

};

class CClass:public BClass
{
int ci1;
int ci2;

public:
BClass* b;
CClass(){}
insertValues(in t parm1, int parm2){
ci1 = parm1;
ci2 = parm2;
}

};

Consider a HEAD pointer BClass* BHead and create a doubly linked list
where the forward and backward chain is maintained using BClass
pointers. Each of the nodes in the chain should maintain 10 integer
values. You are free to choose how you distribute 10 integers among
the objects of a node. Plan a distribution and stick to it. You can
choose whether you want to insert new nodes at the beginning of the
list or at the end of the list. Stick to any one.

Write the following functions for the link list:

void insert(int* int10parm);

and

void delete(int* int10parm);

where <int* int10parmcontai ns 10 integers. Expect the parameter for
delete function to have integers in the same order as for the insert
function.
What a nasty problem!

The first thing to do is understand the problem statement. I have no idea
what real world situation this is supposed to represent so I can't even make
reasonable - or unreasonable for that matter - guesses to supplement the
written assignment..

I always separate the container from the objects being contained. Somehow
we must store 10 ints in a programmer directed fashion, the customer doesn't
care how, just do it. And don't break any of the other rules in the
process. The linked list seems to be of objects of type B (My temporary
notation for an object of that class). A B has two ints of its own and it
is derived from an A and that object can contain 2 ints, so we are up to 4.
Now it starts to get nasty, we have 6 ints left and no place to put them.
Note that each class has one or more pointers and note that the pointers are
public!! This (public)contras ts with the usual rules WRT data in C++. So
fabricate a linked list of B's from a "parent" object of type B. The parent
is in the doubly linked list, the siblings are not. They are in an ordinary
liked list and "belong" in a way, to the parent. Don't even use the A or C
classes. There is no rule expressed that data in an A has to be valid. Or
that an object ot type C needs to even exist. Think of the variable
B::BClass* b being renamed as "base" or "head", it is where the (simple)
linked list starts.

When he mentions a doubly linked list using BClass pointers, I take that to
*not* be the variable shown in the BClass definition. You can not, point
two directions with one pointer and maintain good design practices. So I
take it he is talking about two separate chains of pointers, one forwards
and one backwards.

Each node in the doubly linked list consists, by definition, of five objects
of type B. I don't like it but I think it complies with the assignment.
Strange questions yield strange answers.

This is the wrong newsgroup for this type of question, post any follow-ups
to comp.programmin g, which is where it belongs, follow-ups have been set..

May 18 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2217
by: D. Beckham | last post by:
I wrote the following code to create a short doubly-link list of three strings: "one", "two", and "three". I would like to know if I set them up correctly, so that they point to one another. DLLNode class has already been created. Basically, "one" is the head node, "two" is the mid node, and "three" is the tail or the last node. I would like to know if my algorithm for setting up doubly-linked node are correct before I proceed to...
270
3990
by: Jatinder | last post by:
I found these questions on a web site and wish to share with all of u out there,Can SomeOne Solve these Porgramming puzzles. Programming Puzzles Some companies certainly ask for these things. Specially Microsoft. Here are my favorite puzzles. Don't send me emails asking for the solutions.
3
2211
by: surrealtrauma | last post by:
I want to ask what's the differences between doubly liked list and linear liked list, and also the circular doubly liked list in terms of implementation. THX
4
2932
by: dssuresh6 | last post by:
Whether browsing forward or backward can be done using a singly linked list. Is there any specific case where a doubly linked list is needed? For people who say that singly linked list allows traversal only in one direction, I would say that using appropriate loops/recursion, traversal in opposite direction is also possible. Then why the need for doubly linked list? --
8
4170
by: sudhirlko2001 | last post by:
How to swap two nodes of doubly Linklist
5
3231
by: free2cric | last post by:
Hi, how to detect head and tail in cyclic doubly link list ? Thanks, Cric
0
1823
by: drewy2k12 | last post by:
Heres the story, I have to create a doubly linked list for class, and i have no clue on how to do it, i can barely create a single linked list. It has to have both a head and a tail pointer, and each node in the list must contain two pointers, one pointing forward and one pointing backwards. Each node in the list will contain 3 data values: an item ID (string), a quantity (integer) and a price (float). The ID will contain only letters and...
4
1948
by: srad | last post by:
Hi..Im writting a doubly link list in c++,compiled with Turbo c++, but my Add_at_first method seems not working,i couldnt find any problem in the code... here is the code : #include <iostream.h> class node { friend class linklist; public : int num; node *next; node *prev; };
5
9716
by: adam.kleinbaum | last post by:
Hi there, I'm a novice C programmer working with a series of large (30,000 x 30,000) sparse matrices on a Linux system using the GCC compiler. To represent and store these matrices, I'd like to implement the sparse matrices as a doubly-linked list, in which each non-zero cell is stored roughly as follows: int rownum int colnum
0
10205
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9851
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.