B
BAN USERThe advantage of continous memory is that the memory is assigned during compile time and hence we do not hold risk of running out of memory during run time coz its already there. where as in case of link list, every node is created on need basis and a chance may come where we run out of memory and no more nodes are created and the program execution halts.
- B April 28, 2007well we can use an array which will contain all positions from start to end e.g. 100. so the game starts on 1 and ends at 100. now every element in the array is the head of a link list with just one "next" element and the head of the node has two flags either ladder or snake.
e.g
struct node
{
bool snake;
bool ladder;
struct node* next;
}
the "next" is pointing to the position which will take you whether its a snake or a ladder. and if hte flag is set to true then its a snake or else if ladder is set to true then its a ladder if both are flase then its nothing.
create the node as follows
struct node
{
bool flag;
struct node* left;
struct node* right;
}
Create a Binary Tree and populate it with all the elements from A. now read B and again try to populate in the same tree, if there is a duplicate then mark the flag as true in that particular node.
at the end traverse the tree inorder and print only those nodes whose flags are set to true.
well when you declare a variable or method as final it is as good as const in C++.
- B April 28, 2007when you declare a method finally, it will be executed for sure before the termination of the program even if a fatal exception is thrown.
don't have any idea about finalize, anybody from Java can throw some light also pls correct me if i am wrong i am a C++ guy.