functions (3.papers)

loops (1.papers)

Conditional statements (2.papers)

arrays (2.papers)

structures (3.papers)

unions (1.papers)

Enums and TypeDefs (3.papers)

pointers (7.papers)

null pointers (1.papers)

strings (2.papers)

misc c concepts (1.papers)

Data structures (5.papers)

linked lists (3.papers)

trees (1.papers)

basics (5.papers)

bitwise operators (1.papers)

1

what is below data structure representing to? class sibtreenode{ object item; sibtreenode parent; sibtreenode firstchild; //first left node sibtreenode nextsibling;//immediate next right sibling node for this node. }

it is representing a non rooted binary tree

it is representing rooted binary tree

it is representing rooted tree

it is both a binary tree and normal tree, both are rooted.

Show Answer

2

What is a tree? Which of the below statements are true about a tree? i. tree is a set of nodes with edges connecting the nodes ii. a tree can be empty also. iii. every tree should have root node. iv. between two nodes of a tree there can be more than on path

i

i & ii

i, ii, & iii

i, ii, iii, & iv

Show Answer

Show Answer

Show Answer

Show Answer

6

example code for finding a node in a tree in c: what is below function doing? public Object find(Object k){ BinaryTreeNode node = root; while(node != null){ int comp = k.comparedTo(node.entry.key()); if(comp <0){ node = node.left; }else if(comp>0){ node = node.right; }else{ return node.entry; } } return null; }

it is trying to find if a value is available in a binary tree.

it is trying to find if a value is available in a binary search tree.

it is trying to find if a value is available in a non binary tree.

all are correct

Show Answer

7

how to remove a node with key k in a binary search tree? Assumption 1: that node has only maximum one child. Assumption 2: that node is n which is having key k.

if n has no children, detach it from its parent.

if n has one child, move n's child up to take n's place.

both option 1 and 2 are correct.

both option 1 and 2 are reversed.

Show Answer

8

how to remove a node with key k in a binary search tree? Assumption: that node has 2 children.

if n has 2 children, let x be node in n's left sub tree with the smallest key. remove x (since x has no left child and is easily rmvd). and now replace n's key with x's key.

if n has 2 children, let x be node in n's right sub tree with the largest key. remove x (since x has no left child and is easily rmvd). and now replace n's key with x's key.

if n has 2 children, let x be node in n's right sub tree with the smallest key. remove x (since x has no left child and is easily rmvd). and now replace n's key with x's key.

if n has 2 children, let x be node in n's left sub tree with the largest key. remove x (since x has no left child and is easily rmvd). and now replace n's key with x's key.

Show Answer

9

What is the time complexity of inserting set of elements into a binary search tree in the same order? Assumption 1: n is the no of nodes in that tree. Assumption 2: set of elements which are to be inserted are already in sorted order

if we have set of elements which are already sorted, and try to insert them into the binary search tree in the same order, complexity is O(n)

if we have set of elements which are already sorted, and try to insert them into the binary search tree in the same order, complexity is O(log n)

if we have set of elements which are already sorted, and try to insert them into the binary search tree in the same order, complexity is O(n log n)

if we have set of elements which are already sorted, and try to insert them into the binary search tree in the same order, complexity is O(n^2)

Show Answer

10

What is a rooted tree? Which of the below are properties of a rooted tree? i. rooted tree will have root node. ii. every node will have a parent node except root node. iii. a node can have n number of children iv. a tree can have a cycle (or circular path)

i

i & ii

i, ii, & iii

i, ii, iii, & iv

Show Answer

11

Which of the below properties are true about a rooted tree? i. leaf node : will not have children ii. siblings : two nodes having same parent

i

ii

option i is right option ii is wrong

both option i and ii are correct.

Show Answer

Show Answer

13

Which of the below is not a property of a rooted binary tree? i. a given node can't contain more than 2 children ii. a child of a node can be either left child or right child iii. a rooted non binary tree can contain more than 2 children also

i

ii

option ii is wrong if we have only child to a given node

iii

Show Answer

14

Tree traversal: which of the below statements are wrong about a rooted tree traversal?

tree traversal means : visiting each node in the tree

tree traversal means : visiting each node only once in the tree

traversal takes O(n) time complexity

inorder traversal is applicable to only binary trees.

Show Answer

Show Answer

16

preorder traversal example in c: which of the below algorithms is correct for preorder traversal in c?

public void order(){ if(firstchild != null){ firstchild.order(); } this.visit();//print this node if(nextsibling != null){ nextsibling.order(); } }

public void order(){ if(firstchild != null){ firstchild.order(); } if(nextsibling != null){ nextsibling.order(); } this.visit();//print this node }

public void order(){ this.visit();//print this node if(nextsibling!= null){ nextsibling.order(); } if(firstchild!= null){ firstchild.order(); } }

public void order(){ this.visit();//print this node if(firstchild != null){ firstchild.order(); } if(nextsibling != null){ nextsibling.order(); } }

Show Answer

17

postorder traversal example in c: which of the below algorithms is correct for postorder traversal in c?

public void postorder(){ this.visit();//print this node if(firstchild != null){ firstchild.postorder(); } if(nextsibling != null){ nextsibling.postorder(); } } }

public void postorder(){ if(firstchild != null){ firstchild.postorder(); } this.visit();//print this node if(nextsibling != null){ nextsibling.postorder(); } } }

public void postorder(){ if(firstchild != null){ firstchild.postorder(); } if(nextsibling != null){ nextsibling.postorder(); } this.visit();//print this node } }

public void postorder(){ if(nextsibling != null){ nextsibling.postorder(); } if(firstchild != null){ firstchild.postorder(); } this.visit();//print this node } }

Show Answer

Show Answer

Show Answer

20

tree structure declaration in c: what the below data structure represents? public class BinaryTreeNode{ Object item; BinaryTreeNode parent; BinaryTreeNode left; BinaryTreeNode right; ..... }

binary tree

linked list

rooted non binary tree

graph

Show Answer

Read more papers :
1