I was asked the following question: How would you save the data below (which data structure will be selected):
A-1-2-3-4-5-6
|
B-7-8-9-10-11
|
C-12-14-15-16-17
My annas: Since it looks like a bunch of lists with nodes connected to each other. Use two node types, one identifier for the regular node type, with the following definition:
Struct node1
{
int val;
struct node*next;
};
struct node2
{
int val;
struct node *down;
struct node* next;
};
Interviewer Response: This is the best data structure you can think of. How abt in terms of crawl and memory needed for each node?
My answer to this: We can intersect better if we create some kind of hash table.
My question to you, comrades: Can we work better? Is there a better way to store this data type?
we assume that the data is all numbers (even those of each node head) and non-serial with repetitions. What would be the correct answer? Finding Answers in C / C ++