You are on page 1of 59

http://worldatyou.blogspot.

com/

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Coding Skills (Advanced)


Question Number 1
Given the following code snippet:
void InsertNode(tNode** node, int i){ if(*node == NULL){ *node = new tNode; (*node)->pLeft = NULL; (*node)->data = i; (*node)->pRight = NULL; SetRootNode(node); return; } else{ if(i < (*node)->data) InsertNode(&((*node)->pLeft), i); if(i > (*node)->data) InsertNode(&((*node)->pRight), i); return; } } void Func(tNode **node){ if(*node!=NULL){ Func(&(*node)->pLeft); tNode *temp; temp = (*node)->pLeft; (*node)->pLeft= (*node)->pRight; (*node)->pRight = temp; Func(&(*node)->pRight); } } void traverse(tNode** nd){ if(*nd!=NULL){ traverse(&((*nd)->pLeft)); traverse(&((*nd)->pRight)); std::cout<<(*nd)->data<<std::endl; } }

Let the input given be 98,15,100,10,78,120,5,12,96,110 What would be the output of the following code snippet?
int main(void) { tree *bT = new tree; int i = 10; int data; while(i--){

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
std::cout<<"Enter the node"<<std::endl; std::cin>>data; bT->InsertNode(bT->GetRootNode(), data);

} bT->InsertNode(bT->GetRootNode(), 99); bT->traverse(bT->GetRootNode()); }

110,5,12,96,78,15,99,110,120, 100,98 5,10,12,15,78,96,98,99,100,11 0,120 120,110,100,99,98,96,78,15,1 2,10,5 98,100,120,110,99,15,78,96,1 2,5,110

Question Number 2
Given the following code snippet:
void InsertNode(tNode** node, int i){ if(*node == NULL){ *node = new tNode; (*node)->pLeft = NULL; (*node)->data = i; (*node)->pRight = NULL; SetRootNode(node); return; } else{ if(i < (*node)->data) InsertNode(&((*node)->pLeft), i); if(i > (*node)->data) InsertNode(&((*node)->pRight), i); return; } } void Func(tNode **node){ if(*node!=NULL){ Func(&(*node)->pLeft); tNode *temp; temp = (*node)->pLeft; (*node)->pLeft= (*node)->pRight; (*node)->pRight = temp; Func(&(*node)->pRight); }

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
} void traverse(tNode** nd){ if(*nd!=NULL){ traverse(&((*nd)->pLeft)); traverse(&((*nd)->pRight)); std::cout<<(*nd)->data<<std::endl; } }

Let the input given be 98,15,100,10,78,120,5,12,96,110 What would be the output of the following code snippet?
int main(void) { tree *bT = new tree; int i = 10; int data; while(i--){ std::cout<<"Enter the node"<<std::endl; std::cin>>data; bT->InsertNode(bT->GetRootNode(), data);

bT->Func(bT->GetRootNode()); bT->InsertNode(bT->GetRootNode(), 99); bT->Func(bT->GetRootNode()); bT->traverse(bT->GetRootNode()); }

5,10,12,15,78,96,98,99,100,1 10,120 5,12,10,99,96,78,15,110,120, 100,98 5,10,12,15,78,96,99,98,100,1 10,120 98,100,120,110,15,78,96,99,1 0,12,5

Question Number 3
Given the following code snippet:
void InsertNode(tNode** node, int i){

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
if(*node == NULL){ *node = new tNode; (*node)->pLeft = NULL; (*node)->data = i; (*node)->pRight = NULL; SetRootNode(node); return; } else{ if(i < (*node)>data) InsertNode(&((*n ode)->pLeft), i); if(i > (*node)>data) InsertNode(&((*n ode)->pRight), i); return; } } void Func(tNode **node){ if(*node!=NULL){ Func(&(*node)>pLeft); tNode *temp; temp = (*node)>pLeft; (*node)->pLeft= (*node)->pRight; (*node)->pRight = temp; Func(&(*node)>pRight); } } void traverse(tNode** nd){ if(*nd!=NULL){ traverse(&((*nd)>pLeft)); traverse(&((*nd)>pRight)); std::cout<<(*nd)>data<<std::endl; } }

Let the input given be 98,15,100,10,78,120,5,12,96,110 What would be the output of the following code snippet?

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
int main(void) { tree *bT = new tree; int i = 10; int data; while(i--){ std::cout<<"Enter the node"<<std::endl; std::cin>>data; bT->InsertNode(bT>GetRootNode(), data); } bT->Func(bT>GetRootNode()); bT->InsertNode(bT>GetRootNode(), 99); bT->traverse(bT>GetRootNode()); }

100,110,120,98,5,10,12,15,78 ,96,99 99,96,78,15,12,10,5,98,120,1 10,100 110,120,100,5,12,10,99,96,78 ,15,98 98,15,78,96,99,10,12,5,100,1 20,110

Question Number 4
Given the following code snippet:
void InsertNode(tNode** node, int i){ if(*node == NULL){ *node = new tNode; (*node)->pLeft = NULL; (*node)->data = i; (*node)->pRight = NULL; SetRootNode(node); return; } else{ if(i < (*node)->data) InsertNode(&((*node)->pLeft), i); if(i > (*node)->data) InsertNode(&((*node)->pRight), i); return;

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
}

void Func(tNode **node){ if(*node!=NULL){ Func(&(*node)->pLeft); tNode *temp; temp = (*node)->pLeft; (*node)->pLeft= (*node)->pRight; (*node)->pRight = temp; Func(&(*node)->pRight); } } void traverse(tNode** nd){ if(*nd!=NULL){ traverse(&((*nd)->pLeft)); traverse(&((*nd)->pRight)); std::cout<<(*nd)->data<<std::endl; } }

Let the input given be 98,15,100,10,78,120,5,12,96,110 What would be the output of the following code snippet?
int main(void) { tree *bT = new tree; int i = 10; int data; while(i--){ std::cout<<"Enter the node"<<std::endl; std::cin>>data; bT->InsertNode(bT->GetRootNode(), data); } bT->InsertNode(bT->GetRootNode(), 97); bT->Func(bT->GetRootNode()); bT->InsertNode(bT->GetRootNode(), 99); bT->traverse(bT->GetRootNode()); }

98,15,78,96,97,99,10,12,5,100,120,110 110,120,100,5,12,10,99,97,96,78,15,98 100,110,120,98,5,10,12,15,78,96,97,99 None of these

Question Number 5
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants. A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \

/ + / / "A" / / "B" / /

\ \ / + / \

\ \ "D"

/ \ \ "C"

/ \

Suppose we want the classes to implement getLeft and getRight to allow external code to navigate the tree. What should their return type be?
Object Node InternalNode TerminalNode

Question Number 6
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants.
http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \

/ + / / "A" / / "B" / /

\ \ / + / \

\ \ "D"

/ \ \ "C"

/ \

Should InternalNode have simple setters, as follows?


void setLeft(Node nd) { left = nd; } void setRight(Node nd) { right = nd; }

Yes Optionalthe specifications dont imply either yes or no Nothe specifications directly forbid it Nothe specifications dont say one way or another but these implementations are inadequate

Question Number 7
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \

/ + / / "A" / / "B" / /

\ \ / + / \

\ \ "D"

/ \ \ "C"

/ \

Consider this implementation of toString():


abstract class Node { String toString(); } class TerminalNode extends Node { String toString() { return value; } } class InternalNode extends Node { String toString() { if (null == left) return "[" + right + "]"; else if (null == right) return "[" + left + "]"; else return "[" + left + " " + right + "]"; } }

Under what conditions will this implementation distinguish (i.e. produce different strings for) two trees that have the same strings in the same sequence in their terminal nodes but different internal structures? Never Only for full trees (ones in which every internal node has two children, except possibly the parent of the rightmost terminal node) Always

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Question Number 8
Given the following code snippet answer the following question.
struct AVLTree { AVLTree * left; AVLTree * right; int element; int height; }; int MAX(int a, int b){ if(a>=b) return a; if(a<b) return b; } int height(AVLTree *node) { if (node == NULL) { return -1; } else { return node->height; } } AVLTree * single_rotation_with_left(AVLTree *k2) { AVLTree *k1; k1 = k2->left; k2->left = k1->right; k1->right = k2; k2->height = MAX(height(k2->left), height(k2->right)) + 1; k1->height = MAX(height(k1->left), height(k2->right)) + 1; return k1; } AVLTree * single_rotation_with_right(AVLTree *k2) { AVLTree *k1; k1 = k2->right; k2->right = k1->left; k1->left = k2; k2->height = MAX(height(k2->left), height(k2->right)) + 1; k1->height = MAX(height(k1->right), height(k2->left)) + 1;

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
return k1; } AVLTree *double_rotation_with_left(AVLTree *k3) { k3->left = single_rotation_with_right(k3->left); return single_rotation_with_left(k3); } AVLTree *double_rotation_with_right(AVLTree *k3) { k3->right = single_rotation_with_left(k3->right); return single_rotation_with_right(k3); } void insert(int value, AVLTree **node) { if (*node == NULL) { *node = new AVLTree; if (*node == NULL) { return; } (*node)->element = value; (*node)->height = 0; (*node)->left = (*node)->right = NULL; return; } else if (value < (*node)->element) { insert(value, &((*node)->left)); if (height((*node)->left) - height((*node)->right) == 2) { if (value < (*node)->left->element) { *node = single_rotation_with_left(*node); } else { *node = double_rotation_with_left(*node); } } } else if (value > (*node)->element) { insert(value, &((*node)->right)); if (height((*node)->right) - height((*node)->left) == 2) { if (value > (*node)->right->element) { *node = single_rotation_with_right(*node); } else { *node = double_rotation_with_right(*node); } } }

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

1; }

(*node)->height = MAX(height((*node)->left), height((*node)->right)) +

Consider an input sequence that is provided as an input to the insert method 20,5,15,9,13,2,6,12,14,15,16,17,18,19 How many times method single_rotation_with_left is called while inserting 18 1 0 2 None of these

Question Number 9
Given the following code snippet answer the following question.
struct AVLTree { AVLTree * left; AVLTree * right; int element; int height; }; int MAX(int a, int b){ if(a>=b) return a; if(a<b) return b; } int height(AVLTree *node) { if (node == NULL) { return -1; } else { return node->height; } } AVLTree * single_rotation_with_left(AVLTree *k2) { AVLTree *k1;

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
k1 = k2->left; k2->left = k1->right; k1->right = k2; k2->height = MAX(height(k2->left), height(k2->right)) + 1; k1->height = MAX(height(k1->left), height(k2->right)) + 1; return k1;

AVLTree * single_rotation_with_right(AVLTree *k2) { AVLTree *k1; k1 = k2->right; k2->right = k1->left; k1->left = k2; k2->height = MAX(height(k2->left), height(k2->right)) + 1; k1->height = MAX(height(k1->right), height(k2->left)) + 1; return k1; } AVLTree *double_rotation_with_left(AVLTree *k3) { k3->left = single_rotation_with_right(k3->left); return single_rotation_with_left(k3); } AVLTree *double_rotation_with_right(AVLTree *k3) { k3->right = single_rotation_with_left(k3->right); return single_rotation_with_right(k3); } void insert(int value, AVLTree **node) { if (*node == NULL) { *node = new AVLTree; if (*node == NULL) { return; } (*node)->element = value; (*node)->height = 0; (*node)->left = (*node)->right = NULL; return; } else if (value < (*node)->element) { insert(value, &((*node)->left)); if (height((*node)->left) - height((*node)->right) == 2) { if (value < (*node)->left->element) { *node = single_rotation_with_left(*node); } else { *node = double_rotation_with_left(*node); } }

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
} else if (value > (*node)->element) { insert(value, &((*node)->right)); if (height((*node)->right) - height((*node)->left) == 2) { if (value > (*node)->right->element) { *node = single_rotation_with_right(*node); } else { *node = double_rotation_with_right(*node); } } } 1; } (*node)->height = MAX(height((*node)->left), height((*node)->right)) +

Consider an input sequence that is provided as an input to the insert method 20,5,15,9,13,2,6,12,14,15,16,17,18,19 Which one of the following would be the root node after inserting 16. 16 17 15 9

Question Number 10
Given the following code snippet answer the following question.
struct AVLTree { AVLTree * left; AVLTree * right; int element; int height; }; int MAX(int a, int b){ if(a>=b) return a; if(a<b)

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
return b; } int height(AVLTree *node) { if (node == NULL) { return -1; } else { return node->height; } } AVLTree * single_rotation_with_left(AVLTree *k2) { AVLTree *k1; k1 = k2->left; k2->left = k1->right; k1->right = k2; k2->height = MAX(height(k2->left), height(k2->right)) + 1; k1->height = MAX(height(k1->left), height(k2->right)) + 1; return k1; } AVLTree * single_rotation_with_right(AVLTree *k2) { AVLTree *k1; k1 = k2->right; k2->right = k1->left; k1->left = k2; k2->height = MAX(height(k2->left), height(k2->right)) + 1; k1->height = MAX(height(k1->right), height(k2->left)) + 1; return k1; } AVLTree *double_rotation_with_left(AVLTree *k3) { k3->left = single_rotation_with_right(k3->left); return single_rotation_with_left(k3); } AVLTree *double_rotation_with_right(AVLTree *k3) { k3->right = single_rotation_with_left(k3->right); return single_rotation_with_right(k3); } void insert(int value, AVLTree **node) { if (*node == NULL) { *node = new AVLTree; if (*node == NULL) { return; } (*node)->element = value; (*node)->height = 0; (*node)->left = (*node)->right = NULL;

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
return; } else if (value < (*node)->element) { insert(value, &((*node)->left)); if (height((*node)->left) - height((*node)->right) == 2) { if (value < (*node)->left->element) { *node = single_rotation_with_left(*node); } else { *node = double_rotation_with_left(*node); } } } else if (value > (*node)->element) { insert(value, &((*node)->right)); if (height((*node)->right) - height((*node)->left) == 2) { if (value > (*node)->right->element) { *node = single_rotation_with_right(*node); } else { *node = double_rotation_with_right(*node); } } } 1; } (*node)->height = MAX(height((*node)->left), height((*node)->right)) +

Consider an input sequence that is provided as an input to the insert method 20,5,15,9,13,2,6,12,14,15,16,17,18,19 In the process of inserting the above nodes how many times double_rotation_with_left is being called? 5 0 3 2

Coding Skills (Advanced)

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Question Number 1
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants. A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \

/ + / / "A" / / "B" / /

\ \ / + / \

\ \ "D"

/ \ \ "C"

/ \

Which expression would create a representation of the following tree? IN0 / \

/ / IN1 /

\ \ IN2 / \

/ / "A"

/ / "D"

\ \ IN3 / \

/ / "B"

\ \ "C"

InternalNode tree = new InternalNode( new InternalNode(new TerminalNode("A"), null), new InternalNode(new TerminalNode("D"), new InternalNode( new TerminalNode("B"), new TerminalNode("C"))));

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
InternalNode tree = new InternalNode( new InternalNode(new TerminalNode("D"), new InternalNode( new TerminalNode("B"), new TerminalNode("C"))), new TerminalNode("A")) InternalNode tree = new InternalNode( new InternalNode(new TerminalNode("A")), new InternalNode(new TerminalNode("D"), new InternalNode( new TerminalNode("B"), new TerminalNode("C")))); InternalNode tree = new InternalNode( new InternalNode(new TerminalNode("A", null), null), new InternalNode(new TerminalNode("D", null), new InternalNode( new TerminalNode("B", null), new TerminalNode("C", null))));

Question Number 2
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants. A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \

/ + / / "A" / / /

\ \ / + / \

\ \ "D"

/ \

/ \

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
/ "B" \ "C"

Having created a pathTo(String) method wed like to have the reverse operation, atPath(List). Here is a proposed implementation. (Note that it returns a Node, not a String.) abstract class Node { abstract bool isTerminal(); abstract Node atPath(List lst); } class TerminalNode extends Node { boolean isTerminal { return True; } Node atPath(List lst) { if (lst.isEmpty()) return this; return null; } } class InternalNode extends Node { boolean isTerminal { return False; } Node atPath(List lst) { Node curnode = this; InternalNode ind = null; for (int n = 0; n < lst.size(); n++) { if (curnode.isTerminal()) return null; String dir = lst.get(n); if (!dir.equals("L") && !dir.equals("R")) return null; ind = (InternalNode) curnode; if (dir.equals("L")) curnode = ind.getLeft(); else curnode = ind.getRight(); } return curnode; } } Which of the possible conditions does the code handle correctly?

A. An empty subtree is encountered before the end of the path.

B. The path leads to a TerminalNode.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/ C. The path leads to an InternalNode.

All of them. A but neither B nor C. A and B but not C B and C but not A.

Question Number 3
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants. A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \ / / / "A" / + + / / \ / "B" / \ \ "C" / / \ \ + / \ \ \ "D"

We want to locate the first occurrence of a string in the tree and return a path that shows how to navigate to it from the root. The path will be represented as a list of strings, with L indicating that the left child should be followed and R that the right child should be followed. The list L, R would identify the right child of the left child of the root of the tree. Assume there is a List data structure available that provides a constructor for creating an empty List

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
addLast(String) to add a string to the end of the list returning the (modified) list so that, for example, a series of additions could be chainedfor example:

lst.addLast("a").addLast("b") Similarly, addFirst(String) adds to the front of the list and returns the modified list.

Given an abstract definition in Node: abstract pathTo(String str); and the definition in TerminalNode: List pathTo(String str) { if (value.equals(str)) return new List(); else return null; } Which of the following definitions will work correctly to produce the path as described above (or null if the string was not found in the tree)? List pathTo(String str) { List lst = null; if ((left != null) && (null != (lst = left.pathTo(str)))) return lst.addFirst("L"); if ((right != null) && (null != (lst = right.pathTo(str)))) return lst.addFirst("R"); return null; } List pathTo(String str) { List lst = null; if (left != null) return left.pathTo(str).addFirst("L"); if (right != null) return right.pathTo(str)).addFirst("R"); return null; } List pathTo(String str) { List lst = new List(); if ((left != null) && (null != (lst = left.pathTo(str)))) return lst.addFirst("L"); if ((right != null) && (null != (lst = right.pathTo(str)))) return lst.addFirst("R"); return lst; } List pathTo(String str) { List lst = null; if ((left != null) && (null != (lst = left.pathTo(str)))) return lst.addLast("L"); if ((right != null) && (null != (lst = right.pathTo(str)))) return lst.addLast("R"); return null;

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
}

Question Number 4
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants. A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \ / / / "A" / + + / / \ / "B" / \ \ "C" / / \ \ + / \ \ \ "D"

One problem with the proposed implementation of equals is that two nodes of different types cannot be equal. In the following code which of TerminalNode.equals and InternalNode.equals correct this problem assuming the argument to each method is not null? (The relevant parts of the class definitions are included.)
abstract class Node { abstract boolean isTerminal(); abstract boolean equals(Node); } class TerminalNode { boolean isTerminal() { return true; } boolean equals(Node nd) { return nd.isTerminal() && value.equals(nd.getValue());

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
}

class InternalNode { boolean isTerminal() { return false; } boolean equals(Node nd) { return !nd.isTerminal() && left.equals(nd.getLeft()) && right.equals(nd.getRight()); } }

Neither TerminalNode nor InternalNode


TerminalNode InternalNode

but not InternalNode but not TerminalNode

Both TerminalNode and InternalNode

Question Number 5
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants. A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \

/ + / / "A" / / "B" / /

\ \ / + / \

\ \ "D"

/ \ \ "C"

/ \

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Here is a proposed implementation of equals for the tree structure:


abstract class Node { abstract boolean equals(Node nd); } class TerminalNode { boolean equals(Node nd) { return value.equals(nd.getValue()); } } class InternalNode { boolean equals(Node nd) { return left.equals(nd.getLeft()) && right.equals(nd.getRight()); } }

Which classes contain correctly implemented methods?


A. TerminalNode

B. InternalNode

Neither A B Both

Question Number 6
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants. A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.
http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \ / / / "A" / + + / / \ / "B" / \ \ "C" / / \ \ + / \ \ \ "D"

The problem with the previous definition of InternalNode.equals is that it calls nd.getLeft() and nd.getRight(), but only InternalNode defines those methods and nd could be a TerminalNode. The following code fixes that and will compile.
abstract class Node { abstract boolean isTerminal(); abstract boolean equals(Node); } class TerminalNode { boolean isTerminal() { return true; } boolean equals(Node nd) { return nd.isTerminal() && value.equals(nd.getValue()); } } class InternalNode { boolean isTerminal() { return false; } boolean equals(Node nd) { return !nd.isTerminal() && left.equals(((InternalNode)nd).getLeft()) && right.equals(((InternalNode)nd).getRight()); } }

This version of the code does not check for null in either TerminalNode or InternalNode. If equals is called on an InternalNode with a non-null argument, which of the two methods could end up getting called with a null argument for certain trees? Both methods could ever be called with a null argument with certain trees. TerminalNode.equals Both methods could be called with a null argument with certain trees but not InternalNode.
http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
InternalNode.equals Both trees but not TerminalNode.

methods could be called with a null argument with certain

Neither method could ever be called with a null argument with certain trees.

Question Number 7
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants. A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \

/ + / / "A" / / "B" / /

\ \ / + / \

\ \ "D"

/ \ \ "C"

/ \

It is proposed to add a check for null at the beginning of each method, returning False if the argument is null, since a Node object would never be equal to null. This change is shown in the code below. In which method(s) could nulls other than the argument be a problem?
abstract class Node { abstract boolean isTerminal(); abstract boolean equals(Node); } class TerminalNode { boolean isTerminal() { return true; } boolean equals(Node nd) {

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
return nd != null && nd.isTerminal() && value.equals(nd.getValue()); } }

class InternalNode { boolean isTerminal() { return false; } boolean equals(Node nd) { return nd != null && !nd.isTerminal() && left.equals(nd.getLeft()) && right.equals(nd.getRight()); } }

Neither TerminalNode.equals nor InternalNode.equals they are both correct as is. TerminalNode.equals needs further code to deal with nulls but InternalNode.equals doesnt. InternalNode.equals needs further code to deal with nulls but TerminalNode.equals doesnt. Both TerminalNode.equals and InternalNode.equals need further code to deal with nulls.

Question Number 8
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants. A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \ / / / + / / \ \ + / \ \

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
/ "A" / / "B" / \ \ "C" \ "D"

/ \

We want to define an operation to get the list element at position N (with the first element is at position 0). Which statements are correct in the following implementation?
class SinglyLinkedList { InternalNode first; String nth(int n) { InternalNode nd = first; while (n-- > 0) nd = nd.getRight(); return ((TerminalNode)(nd.getLeft())).getValue(); }

The while statement (both the condition and the action) is correct. The return statement (taking into account all the details of the entire statement). There are problems with both the while and return statements. Both the while and return statements are correct.

Question Number 9
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants. A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \

/ + / / / /

\ \ / + / \

\ \

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
"A" / "B" / + / \ \ \ "C" "D"

We want to define an operation to get the list element at position N (with the first element is at position 0). Which statements are correct in the following implementation, which differs slightly from the previous version?
class SinglyLinkedList { InternalNode first; String nth(int n) { InternalNode nd = first; while (n-- > 0 && nd != null) nd = nd.getRight(); return (null == nd) ? null : ((TerminalNode)(nd.getLeft())).getValue(); } }

The while statement (both the condition and the action) is correct. The return statement (taking into account all the details of the entire statement). There are problems with both the while and return statements. Both the while and return statements are correct.

Question Number 10
The subject of these questions is an unusually simple kind of binary tree, defined by these properties:

Terminal nodes contain a string. Internal nodes have one or two children, called "left" and "right". Either child of an internal node may be null, but not both. Internal nodes contain no other information. By "tree" we simply mean a node and all of its descendants. A tree rooted at a node having left child A and right child B is a different tree than one rooted at a node having left child B and right child A.

Here's an example, with plus signs (+) used to indicate internal nodes:
+ / \ / / / + / / \ \ + / \ \

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/
/ "A" / / "B" / \ \ "C" \ "D"

/ \

Would the following be an adequate implement of an operation to insert a string at the front of the list?
void insert(String str) { first = new InternalNode(new TerminalNode(str), first); }

No, it is not always necessary to create a new TerminalNode. No, it is not always necessary to create a new InternalNode. There circumstances in which executing this method will violate the restrictions imposed on the tree by the general specifications and the specific specifications for its use as a list. It is a valid implementation under all conditions.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Computer Science Knowledge (Basic)

Question Number 1
A program uses a queue to visit each of the nodes of a binary tree, starting at its root. After a node is processed its children are added to the the end of the queue. In what order do nodes get processed? Inorder Postorder Breadth-first Preorder

Question Number 2
What features must a programming language and its runtime environment provide in order to support automatic memory management? 1. Dynamic memory allocation 2. Explicit deallocation of data 3. Garbage collection 1 and 3, but not 2 3 2 1

Question Number 3
From the following options, select a statement that is NOT true about symbol tables. Symbol tables are often implemented using hash tables Symbol tables map the names to their attributes Symbol table is a compile-time data structure

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Symbol table is used during syntactic analysis

Question Number 4
Consider an application that requires inserting and deleting data items in a data structure dynamically. From the following options, select an appropriate data structure for this scenario. Stack Array Queue Linked List

Question Number 5
Which one of the following is NOT a phase of program compilation? Code generation Parsing Macro expansion Lexical analysis

Question Number 6
Consider the following scenarios. - An operating system having a list of processes that are waiting to get access of the CPU. - A list of jobs waiting to access the printer for printing. From the following options, select the ideal data structure that can be used in these scenarios. Array Linked list Queue Stack

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Question Number 7
Select the decimal value of arithmetic shift right by 2 operation on a signed integer -102. +57 -39 +39 -57

Question Number 1
From the following options, select the OOP mechanism, that allows treatment of the derived class members just like the members of their parent class. Encapsulation Polymorphism Abstraction Decoupling

Question Number 2
Select the option that describes a "type" in Object Oriented programming. It indicates the state that an object maintains It describes how an object implements the methods in its interface It defines implementation of an object It is an interface, which is a collection of methods that an object responds to

Question Number 3
Select the sorting that always has a time complexity O(n2), irrespective of the condition of the array.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Quick Sort Merge sort Selection sort Bubble sort

Question Number 4
Select the OOP concept described by the following features. A. Defines the abstract characteristics of a thing (object). B. Defines attributes of the thing. C. Defines the behavior of the thing. D. Represents a blueprint describing the nature of the thing. Class Function Method Instance

Question Number 5
Select the option that shows the correct matching between the function types and the Big O descriptions. I Constant 1 2 3 4 5 6 O(log n) O(1) O(n) O(n3) O(2n) O(n2)

II Logarithmic III Linear IV Quadratic V Cubic VI Exponential

(I,2),(II,1),(III,3),(IV,6),(V,4),(VI,5) (I,3),(II,5),(III,4),(IV,6),(V,2),(VI,I) (I,5),(II,6),(III,2),(IV,1),(V,4),(VI,3) (I,1),(II,2),(III,3),(IV,4),(V,5),(VI,6)

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Question Number 6
Select the option that denotes, "runtime is proportional to five times the input size". O(n5) 5O(n) O(5n)
5*O(n)

Question Number 1
Which one of the following is NOT a referential integrity issue in a relational database where the DEPT column of the EMPLOYEE table is designated as a foreign key into the DEPARTMENT table? Inserting a new row into EMPLOYEE with a DEPT whose value is not the primary key of any of the rows in DEPARTMENT Deleting a row of DEPARTMENT Inserting a new row into DEPARTMENT with a primary key that is not the value of the DEPT column of any row in EMPLOYEE Updating the value of DEPT in a row of EMPLOYEE with a value that is not the primary key of any of the rows in DEPARTMENT

Question Number 2
ABC Housekeeping Forces are responsible for maintaining a building that comprises of 100 floors. The maintenance company decides to use a database to schedule work for its employees and also check the status of the work. When an assigned housekeeper does NOT report for work, an alternate resource is allotted to complete the job. The Housekeeping database in its current form is given below. Housekeeper HouseKeeperID HouseKeeperName HouseKeeperSSN SupervisorID

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Supervisor SupervisorID SupervisorName SupervisorSSN Floor FloorNo FloorName Transaction FloorNo DutyDate HouseKeeperID WorkStatus AlternateTransaction FloorNo DutyDate AlternateHID AlternateWorkSt Select the option that correctly lists the foreign keys for the different entities. Note that the entity names are given in bold. Housekeeper SupervisorID Supervisor HousekeeperID Transaction HousekeeperID AlternateTransaction AlternateHID Housekeeper HousekeeperSSN Supervisor SupervisorSSN Transaction HousekeeperID AlternateTransaction AlternateHID Housekeeper SupervisorID Transaction HousekeeperID AlternateTransaction AlternateHID Housekeeper HousekeeperID Supervisor SupervisorID Floor FloorNo or FloorName Transaction FloorNo AlternateTransaction FloorNo

Question Number 3

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Select the option that correctly describes the database replication concept where two or more replicas synchronize each other through a transaction identifier. Quorum Multimasterslave Master-Slave Multimaster

Question Number 4
You have two relation variables: RelV1 and RelV2. They are NOT necessarily distinct. You have a set K as a key for RelV1. Consider that FK is a subset of the heading of RelV2 that involves exactly the same attributes as K. From the following options, select the option that correctly depicts a scenario where FK can be considered as a foreign key. Every tuple in RelV1 has a K value that is equal to the FK value in some tuple in RelV2 Every tuple in RelV1 has a FK value that is equal to the K value in some tuple in RelV2 Every tuple in RelV2 has a K value that is equal to the FK value in some tuple in RelV1 Every tuple in RelV2 has a FK value that is equal to the K value in some tuple in RelV1

Question Number 5
Select the option that represents the I in ACID rules. Either all the statements in a transaction must be executed, or none of them should be executed Any two simultaneous transactions cannot obstruct each other The completed transactions cannot be aborted later Each transaction must maintain the integrity constraints of the database

ABC Housekeeping Forces are responsible for maintaining a building that comprises of 100 floors. The maintenance company decides to use a database to schedule work for its employees and also check the status of the work. When an assigned housekeeper does NOT report for work, an alternate resource is allotted to complete the job.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

The Housekeeping database in its current form is given below. Housekeeper HouseKeeperID HouseKeeperName HouseKeeperSSN SupervisorID Supervisor SupervisorID SupervisorName SupervisorSSN Floor FloorNo FloorName Transaction FloorNo DutyDate HouseKeeperID WorkStatus AlternateTransaction FloorNo DutyDate AlternateHID AlternateWorkSt Select the option that correctly lists the single field primary keys for the various entities. Note that the entity names are given in bold. Housekeeper HousekeeperID Supervisor SupervisorID Transaction FloorNo AlternateTransaction FloorNo Housekeeper HousekeeperID Supervisor SupervisorID Floor FloorNo Transaction FloorNo AlternateTransaction FloorNo Housekeeper HousekeeperID Supervisor SupervisorID Floor FloorNo Transaction FloorNo AlternateTransaction AlternateHID

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Housekeeper HousekeeperID Supervisor SupervisorID Floor FloorNo

Question Number 7
Select the option that represents the definition of network database model. Represents the entire information content of the database in only one way Organizes the data in the form of a tree of records, with each record having one parent record and many children records Allows each record to have multiple parent and child records, thereby forming a lattice structure Attempts to bring closer interactivity between database administrators and application programmers

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Software Engineering Aptitude


Support ID: 14D760B

Question Number 1
A number when divided by 161 leaves a remainder of 57. Find the remainder if the same number is divided by 7? 1 2 5 4

Question Number 2
A car travels x km at 60 km/hr and another 3x km at 90 km/hr. Find its average over the entire distance? 80 km/hr 72 km/hr 84 km/hr 75 klm/hr

Question Number 3
Provisions are available for a battalion of 2000 soldiers for 35 weeks at the rate of 16 kgs per day per person. If some more soldiers join the battalion, the provisions would last for 20 weeks at the rate of 20 kgs per day per person. Find the number of soldiers joining the battalion? 200 800 1000

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

400

Question Number 4
In an organization, if there 24 more executives, then the number of executives will be three times the number of managers. If there are two more managers, then the number of executives will be twice the number of managers. What is the number of executives? 60 48 36 72

Question Number 5
The price of sugar is increased by 12% and the consumption is decreased by 8%. The net change in the expenditure on this account is __________. 3.04% increase 3.04% decrease 4 % increase 2.64 % decrease

Question Number 6
Find the probability that a number selected at random from the first 25 natural numbers is divisible by 2 or 5? 2/5 3/5 1/6 17/25

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Question Number 7
A man rows downstream and covers 15 km in 3 hours. He covers the same distance upstream in 5 hours. What is the difference in the distance traveled upstream in six hours and that traveled downstream in six hours? 12 km 6 km 4 km 2 km

Question Number 8
Two pipes A and B can fill a tank in 6 hours and 4 hours respectively. If A is opened first, and the pipes are opened alternately for one hour each, in how many hours will the tank be full? 4h 5h 5.5 h 4.5 h

A sum of US $ 30000 is invested is a bank at 12% interest p.a. compounded semi-annually. After one and half year it will amount to __________. US $ 36620.10 US $ 36120.30 US $ 35320.20 US $ 35730.48

Question Number 10

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

A is directly proportional to B when C is constant and inversely proportional to the square of C when B is constant. In a particular instance when A = 18, B = 25 and C = 10, find A if C = 9 and B = 18. 24 12 16 32

Question Number 1
The speed of a boat in still water is S. The speed of the current is C. Which of the following expressions best represents the total time taken by the boat to cover a distance D between two points named A and B, both ways, that is with and against the current? D/2S 2D/S D/(S+C) + D/(S-C) (A-B)/(S+C) + (B-A)/(S-C)

At a salad bar, the cost of a meal is a fixed amount of $X, plus $Y per item selected from a menu of extra items. Six friends eat at the salad bar, selecting 17 extra items. Only four of them pay the entire bill by splitting it equally. The amount to be paid by each person paying the bill is __________. X+Y (6X + 17Y) / 4 (6X+6Y) / 4 (6X + 17Y) / 6

Question Number 3

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

The problem below contains a question and two statements labeled A and B that give data pertaining to the question. Determine whether the information given in statements A and B is sufficient to answer the question, and select the correct answer from the given options. What is Stans age? A. Stans age in 12 years will be twice what it was 8 years ago B. Stans son was born four years ago and will be half Stans age in 20 years. The question can be answered by using one of the statements alone but not the other The question can be answered by using either statement alone The question can be answered by using both the statements together, but not by using either statement alone Neither of the statements, individually or jointly, provides sufficient data to answer the question

N mules carry loads averaging X kilograms (kgs) each. M mules are added to the group, and the average weight carried by the expanded group goes up by Y%. What is the average weight in kgs carried by the added mules? ( X*(1+0.01Y)(N-M) MX ) / M ( X*(1+0.01Y)(N-M) NX ) / M ( X*(1+0.01Y)(N+M) MX ) / M ( X*(1+0.01Y)(N+M) NX ) / M

Question Number 5
The problem below contains a question and two statements labeled A and B that give data pertaining to the question. Determine whether the information given in statements A and B is sufficient to answer the question, and select the correct answer from options 1-4. 1. The question can be answered by using one of the statements alone but not the other. 2. The question can be answered by using either statement alone. 3. The question can be answered by using both the statements together, but not by using either statement alone.
http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

4. Neither of the statements, individually or jointly, provides sufficient data to answer the question. Pipes X, Y and Z flow at different rates and together take 24/13 minutes to fill a bucket. What is the time taken by Y and Z together to fill the bucket? A. The time taken by X & Y is 12/5 minutes B. The time taken by X & Z is 8/3 minutes 1 2 3 4

Question Number 6
An airline assumes that on average each passenger weighs x pounds. It also assumes that 80% of passengers will have luggage which on average weighs y pounds. In addition to passengers, each airplane carries freight and the airline assumes that each container weighs z pounds. How would you calculate the expected weight of a plane scheduled to carry P passengers and F containers of freight. 0.8Px + Py + Fz 0.8(Px + Py) + Fz P(x + .8y)Fz P(x + .8y) + Fz

Question Number 7
The problem below contains a question and two statements labeled A and B that give data pertaining to the question. Determine whether the information given in statements A and B is sufficient to answer the question, and select the correct answer from options 1-4: 1. The question can be answered by using one of the statements alone but not the other. 2. The question can be answered by using either statement alone.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

3. The question can be answered by using both the statements together. 4. Neither of the statements, individually or jointly, provide sufficient data to answer the question. 20 men take 3 hours to build a wall. How long does it take for 15 women to build the wall? A. A woman works at half the pace of a man B. 5 men and 10 women can build the wall in 6 hours 1 2 3 4

Question Number 8
An article is sold after giving discounts of D1% and D2% on the marked price $MRP. What is the profit percentage earned by the article on its cost price $CP? 100*( (1 0.01D1) (1-0.01D2) * CP MRP ) / CP 100 * ( (1 0.01D1) (1 0.01D2) * CP MRP ) / MRP 100 * ( (1 0.01D1) (1 0.01D2) * MRP CP ) / CP 100 * ( (1 0.01D1) (1 0.01D2) * MRP CP ) / MRP

Question Number 9
The problem below contains a question and two statements labeled A and B that give data pertaining to the question. Determine whether the information given in statements A and B is sufficient to answer the question, and select the correct answer from options 1-4. 1. The question can be answered by using one of the statements alone but not the other. 2. The question can be answered by using either statement alone. 3. The question can be answered by using both the statements together.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

4. Neither of the statements, individually or jointly, provides sufficient data to answer the question. Is the average speed of a cheetah more than 70 km/h? A. The cheetah covered the distance of 3 kms in two minutes B. In the second minute the cheetah ran at half the speed in the first minute 1 2 3 4

Question Number 10
The problem below contains a question and two statements labeled A and B that give data pertaining to the question. Determine whether the information given in statements A and B is sufficient to answer the question, and select the correct answer from options 1-4. 1. The question can be answered by using one of the statements alone but not the other. 2. The question can be answered by using either statement alone. 3. The question can be answered by using both the statements together. 4. Neither of the statements, individually or jointly, provides sufficient data to answer the question. In a particular class, each student studies Psychology, Sociology, or both subjects. How many students study only Sociology? A. 30 students study Psychology and 25 students study Sociology B. The class has 50 students, and 5 students study both subjects 1 2 3 4

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Question Number 1
Based on the data in the following table, answer the question below it.

Which one of the following is the correct combination of Part Number and Part Name in the table? Arrow Shirt Cotton sleeves Red stripes Size-42 & 451-TET-KLVB64-154AA/36 Denim Jeans Gents Blue Size 40 & 231-PLK-SEHT96-236AS/62 Killer Jeans Ladies Stretchable Black Size 34 & 125-LKJ-LKEFT55-111VV/18 Denim Jeans Gents Blue Size 40 & 510-TRT-LDKG21-652PF/23

Question Number 2
Based on the data in the following table, answer the question below it.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

The correct credit card details of the customer Fowler, Heather are __________. 4532343207436130 4532343204736130 4532343204736310 4532343204763130

Question Number 3
Based on the data in the following table, answer the question below it.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

Which one of the following is NOT a correct Customer Detail? 2371 Heritage Road, Fresno, CA 93721 10-07-58 2136 Clinton Street, Philadelphia, PA 19108 04-02-52 2291 Melody Lane, Richmond, VA 23324 12-05-59 119 Ridenour Street, Miramar, FL 33025 12-08-50

Question Number 4
Based on the data in the following table, answer the question below it.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

The correct details of the customer Truelove, James is __________. 605-882-2787 4/13/1956 605-822-2877 4/13/1956 605-822-2787 4/13/1956 605-822-2787 4/13/1965

uestion Number 1
Please carefully read the following: The following flowchart computes the sum of the squares of all primes between 1 and N inclusive.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

What is the value of Cell 1? Is X = N? Is X < N? Is X > N? Is X > TEMP?

Question Number 2
Please carefully read the following: The following flowchart computes the sum of the squares of all primes between 1 and N inclusive.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

What is the value of Cell 4? TEMP = TEMP 1 TEMP = TEMP + 1 X=X+1 X=X1

Question Number 3
Please carefully read the following: The following flowchart computes the sum of the squares of all primes between 1 and N inclusive.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

What is the value of Cell 5? X=X1 X=X+1 TEMP = TEMP 1 TEMP = TEMP + 1

Question Number 4
Please carefully read the following: The following flowchart computes the sum of the squares of all primes between 1 and N inclusive.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

What is the value of Cell 3? DIV = N / TEMP DIV = N / X DIV = TEMP / X DIV = X / TEMP

Question Number 5
Please carefully read the following: The following flowchart computes the sum of the squares of all primes between 1 and N inclusive.

http://worldatyou.blogspot.com/

http://worldatyou.blogspot.com/

What is the value of Cell 2? TEMP = 0 TEMP = 1 TEMP = 2 TEMP = TEMP + 1

http://worldatyou.blogspot.com/

You might also like