Coding Skills (Advanced) : Skipped: Question Number 2
This document describes the properties of a simple binary tree data structure. Terminal nodes contain a string, internal nodes have one or two child nodes (left and right), and either child can be null but not both. It provides an example tree and asks questions about implementing classes like Node and TerminalNode based on the tree specifications.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
74 views38 pages
Coding Skills (Advanced) : Skipped: Question Number 2
This document describes the properties of a simple binary tree data structure. Terminal nodes contain a string, internal nodes have one or two child nodes (left and right), and either child can be null but not both. It provides an example tree and asks questions about implementing classes like Node and TerminalNode based on the tree specifications.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 38
Coding Skills (Advanced)
Support ID: F12DE8
Skipped: Question Number 2 The subject of these questions is an unusually simple kin of binary tree! efine by these properties: Terminal noes contain a strin"# Internal noes ha$e one or t%o chilren! calle &left& an &ri"ht&# Either chil of an internal noe may be null! but not both# Internal noes contain no other information# 'y &tree& %e simply mean a noe an all of its escenants# ( tree roote at a noe ha$in" left chil ( an ri"ht chil ' is a ifferent tree than one roote at a noe ha$in" left chil ' an ri"ht chil (# )ere*s an e+ample! %ith plus si"ns ,-. use to inicate internal noes: + / \ / \ / \ + + / / \ / / \ / / \ "A" + "D" / \ / \ / \ "B" "C" /hat constructors could TerminalNode efine consistent %ith the specifications0 (# TerminalNode() '# TerminalNode(Node) 1# TerminalNode(String) ( an 1 but not ' ' an 1 but not ( 1 only (ll of them %oul be acceptable# Answer Skip End Section Coding Skills (Advanced) Support ID: F12DE' Skipped: Question Number 3 The subject of these questions is an unusually simple kin of binary tree! efine by these properties: Terminal noes contain a strin"# Internal noes ha$e one or t%o chilren! calle &left& an &ri"ht&# Either chil of an internal noe may be null! but not both# Internal noes contain no other information# 'y &tree& %e simply mean a noe an all of its escenants# ( tree roote at a noe ha$in" left chil ( an ri"ht chil ' is a ifferent tree than one roote at a noe ha$in" left chil ' an ri"ht chil (# )ere*s an e+ample! %ith plus si"ns ,-. use to inicate internal noes: + / \ / \ / \ + + / / \ / / \ / / \ "A" + "D" / \ / \ / \ "B" "C" abstract class Node { } /hat constructors shoul Node ha$e accorin" to the specifications for the tree structure0 A. Node(Node) B. Node(String) ( ' 'oth 2one of the abo$e Coding Skills (Advanced) Support ID: F12DEA Skipped: Question Number 4 The subject of these questions is an unusually simple kin of binary tree! efine by these properties: Terminal nodes contain a string. Internal nodes have one or two children, called le!t and right. Either child o! an internal node ma" #e null, #ut not #oth. Internal nodes contain no other in!ormation. $" tree we simpl" mean a node and all o! its descendants. A tree rooted at a node having le!t child A and right child $ is a di%erent tree than one rooted at a node having le!t child $ and right child A. )ere*s an e+ample! %ith plus si"ns ,-. use to inicate internal noes: + / \ / \ / \ + + / / \ / / \ / / \ "A" + "D" / \ / \ / \ "B" "C" class nternalNode e!tends Node { Node le"t# rig$t% nternalNode(node l# node r) { le"t & l% rig$t & r% } } /hich of the constructor3s ar"uments can be n'll accorin" the specifications of the tree structure0 Either can be n'll but not both# 2either can be n'll# l cannot be n'll e$en if r is not n'll# The ans%er cannot be euce from the specifications# Coding Skills (Advanced) Support ID: F12DED Skipped: Question Number 5 The subject of these questions is an unusually simple kin of binary tree! efine by these properties: Terminal noes contain a strin"# Internal noes ha$e one or t%o chilren! calle &left& an &ri"ht&# Either chil of an internal noe may be null! but not both# Internal noes contain no other information# 'y &tree& %e simply mean a noe an all of its escenants# ( tree roote at a noe ha$in" left chil ( an ri"ht chil ' is a ifferent tree than one roote at a noe ha$in" left chil ' an ri"ht chil (# )ere*s an e+ample! %ith plus si"ns ,-. use to inicate internal noes: + / \ / \ / \ + + / / \ / / \ / / \ "A" + "D" / \ / \ / \ "B" "C" Shoul nternalNode ha$e simple 4setters5! as follo%s0 (oid set)e"t(Node nd) { le"t & nd% } (oid set*ig$t(Node nd) { rig$t & nd% } Node remo(e*ig$t() { Node node & rig$t% rig$t & n'll% ret'rn node% } nternalNode remo(e*ig$t() { nternalNode node & rig$t% rig$t & n'll% ret'rn node% } Node remo(e*ig$t() { rig$t & n'll% ret'rn rig$t% } 2one of these options! since uner some circumstances remo$in" the ri"ht subtree of an nternalNode %oul $iolate the specifications# Answer Skip End Section Coding Skills (Advanced) Support ID: F12DE1 Skipped: Question Number The subject of these questions is an unusually simple kin of binary tree! efine by these properties: Terminal noes contain a strin"# Internal noes ha$e one or t%o chilren! calle &left& an &ri"ht&# Either chil of an internal noe may be null! but not both# Internal noes contain no other information# 'y &tree& %e simply mean a noe an all of its escenants# ( tree roote at a noe ha$in" left chil ( an ri"ht chil ' is a ifferent tree than one roote at a noe ha$in" left chil ' an ri"ht chil (# )ere*s an e+ample! %ith plus si"ns ,-. use to inicate internal noes: + / \ / \ / \ + + / / \ / / \ / / \ "A" + "D" / \ / \ / \ "B" "C" Suppose nternalNode implements get)e"t an get*ig$t as part of its public interface to allo% e+ternal coe to na$i"ate the tree# Their return type must be Node! because they may return either an internal or a terminal noe# /hich of the follo%in" is true: Node an TerminalNode must both pro$ie concrete implementations of get)e"t an get*ig$t# It is sufficient to implement get)e"t an get*ig$t in TerminalNode# It is sufficient to implement get)e"t an get*ig$t in Node# 2one of these options Coding Skills (Advanced) Support ID: F12DEE Skipped: Question Number ! The subject of these questions is an unusually simple kin of binary tree! efine by these properties: Terminal noes contain a strin"# Internal noes ha$e one or t%o chilren! calle &left& an &ri"ht&# Either chil of an internal noe may be null! but not both# Internal noes contain no other information# 'y &tree& %e simply mean a noe an all of its escenants# ( tree roote at a noe ha$in" left chil ( an ri"ht chil ' is a ifferent tree than one roote at a noe ha$in" left chil ' an ri"ht chil (# )ere*s an e+ample! %ith plus si"ns ,-. use to inicate internal noes: + / \ / \ / \ + + / / \ / / \ / / \ "A" + "D" / \ / \ / \ "B" "C" abstract class Node { Node +arent% (oid remo(e() { +arent.remo(eC$ild(t$is)% } 1onsier the follo%in" implementation of class nternalNode e!tends Node { (oid remo(eC$ild(Node nd) t$ro,s -!ce+tion { // ... } } (ssume that all the other methos for constructin" an moifyin" the tree are correctly implemente! so that no 4impossible5 situation e+ists %hen remo(eC$ild is calle# 1onsier each of the follo%in" conitions at the start of remo(eC$ild3s coe# /hat must the coe o for each of these conitions0 (# both chilren are n'll '# one chil is n'll 1# neither chil is n'll 1heck for ( an 1 an thro% an e+ception if either occurs! an for ' just set the non6n'll chil to n'll# ( can be i"nore! thro% an e+ception if 1 occurs! an for ' just set the non6n'll chil to n'll# ( can be i"nore! thro% an e+ception if 1 occurs! an for ' set the non6n'll chil to n'll an call +arent.remo(eC$ild(t$is)# ( can be i"nore# For '! set the non6n'll chil to n'll an call +arent.remo(eC$ild(t$is)# For 1! compare the ientity of nd %ith le"t an rig$t an set the one that matches to n'll# Coding Skills (Advanced) Support ID: F12DE1 Skipped: Question Number " The subject of these questions is an unusually simple kin of binary tree! efine by these properties: Terminal noes contain a strin"# Internal noes ha$e one or t%o chilren! calle &left& an &ri"ht&# Either chil of an internal noe may be null! but not both# Internal noes contain no other information# 'y &tree& %e simply mean a noe an all of its escenants# ( tree roote at a noe ha$in" left chil ( an ri"ht chil ' is a ifferent tree than one roote at a noe ha$in" left chil ' an ri"ht chil (# )ere*s an e+ample! %ith plus si"ns ,-. use to inicate internal noes: + / \ / \ / \ + + / / \ / / \ / / \ "A" + "D" / \ / \ / \ "B" "C" abstract class Node { abstract (oid remo(e()% } class TerminalNode e!tends Node { Node le"t# rig$t% } class nternalNode e!tends Node { String (al'e% } /e %ant to implement remo(e in TerminalNode so that it is remo$e from the tree an in nternalNode so that the entire subtree startin" at nternalNode is remo$e from the tree# /hich of the follo%in" %oul be require to implement this chan"e0 (# a to TerminalNode a reference to its parent '# a to nternalNode a reference to its parent 1# a to Node a reference to its parent ( ' Either ( an ' to"ether! or 1 alone! %oul be require# (ll three %oul be require# Support ID: F12DE2 Question Number 2 7i$en the follo%in" coe snippet ans%er the follo%in" question# str'ct A.)Tree { A.)Tree / le"t% A.)Tree / rig$t% int element% int $eig$t% }% int 0A1(int a# int b){ i"(a2&b) ret'rn a% i"(a3b) ret'rn b% } int $eig$t(A.)Tree /node) { i" (node && N4))) { ret'rn 56% } else { ret'rn node52$eig$t% } } A.)Tree / single7rotation7,it$7le"t(A.)Tree /89) { A.)Tree /86% 86 & 8952le"t% 8952le"t & 8652rig$t% 8652rig$t & 89% 8952$eig$t & 0A1($eig$t(8952le"t)# $eig$t(8952rig$t)) + 6% 8652$eig$t & 0A1($eig$t(8652le"t)# $eig$t(8952rig$t)) + 6% ret'rn 86% } A.)Tree / single7rotation7,it$7rig$t(A.)Tree /89) { A.)Tree /86% 86 & 8952rig$t% 8952rig$t & 8652le"t% 8652le"t & 89% 8952$eig$t & 0A1($eig$t(8952le"t)# $eig$t(8952rig$t)) + 6% 8652$eig$t & 0A1($eig$t(8652rig$t)# $eig$t(8952le"t)) + 6% ret'rn 86% } A.)Tree /do'ble7rotation7,it$7le"t(A.)Tree /8:) { 8:52le"t & single7rotation7,it$7rig$t(8:52le"t)% ret'rn single7rotation7,it$7le"t(8:)% } A.)Tree /do'ble7rotation7,it$7rig$t(A.)Tree /8:) { 8:52rig$t & single7rotation7,it$7le"t(8:52rig$t)% ret'rn single7rotation7,it$7rig$t(8:)% } (oid insert(int (al'e# A.)Tree //node) { i" (/node && N4))) { /node & ne, A.)Tree% i" (/node && N4))) { ret'rn% } (/node)52element & (al'e% (/node)52$eig$t & ;% (/node)52le"t & (/node)52rig$t & N4))% ret'rn% } else i" ((al'e 3 (/node)52element) { insert((al'e# <((/node)52le"t))% i" ($eig$t((/node)52le"t) 5 $eig$t((/node)52rig$t) && 9) { i" ((al'e 3 (/node)52le"t52element) { /node & single7rotation7,it$7le"t(/node)% } else { /node & do'ble7rotation7,it$7le"t(/node)% } } } else i" ((al'e 2 (/node)52element) { insert((al'e# <((/node)52rig$t))% i" ($eig$t((/node)52rig$t) 5 $eig$t((/node)52le"t) && 9) { i" ((al'e 2 (/node)52rig$t52element) { /node & single7rotation7,it$7rig$t(/node)% } else { /node & do'ble7rotation7,it$7rig$t(/node)% } } } (/node)52$eig$t & 0A1($eig$t((/node)52le"t)# $eig$t((/node)52rig$t)) + 6% } 1onsier an input sequence that is pro$ie as an input to the insert metho 28!9!19!:!1;!2!<!12!1=!19!1<!1>!18!1: ?et*s "i$e the root noe of the resultin" tree as input to the follo%in" coe snippet int "'nc(A.)Tree //+) { i" (/+=&;) ret'rn "'nc (<(/+)52rig$t) + "'nc (<(/+)52le"t) + 6% else ret'rn ;% } /hat %oul be the return $alue after e+ecution of the abo$e coe snippet0 1; 1= 19 2one of these Support ID: F12DE9 Question Number 3 7i$en the follo%in" coe snippet ans%er the follo%in" question# str'ct A.)Tree { A.)Tree / le"t% A.)Tree / rig$t% int element% int $eig$t% }% int 0A1(int a# int b){ i"(a2&b) ret'rn a% i"(a3b) ret'rn b% } int $eig$t(A.)Tree /node) { i" (node && N4))) { ret'rn 56% } else { ret'rn node52$eig$t% } } A.)Tree / single7rotation7,it$7le"t(A.)Tree /89) { A.)Tree /86% 86 & 8952le"t% 8952le"t & 8652rig$t% 8652rig$t & 89% 8952$eig$t & 0A1($eig$t(8952le"t)# $eig$t(8952rig$t)) + 6% 8652$eig$t & 0A1($eig$t(8652le"t)# $eig$t(8952rig$t)) + 6% ret'rn 86% } A.)Tree / single7rotation7,it$7rig$t(A.)Tree /89) { A.)Tree /86% 86 & 8952rig$t% 8952rig$t & 8652le"t% 8652le"t & 89% 8952$eig$t & 0A1($eig$t(8952le"t)# $eig$t(8952rig$t)) + 6% 8652$eig$t & 0A1($eig$t(8652rig$t)# $eig$t(8952le"t)) + 6% ret'rn 86% } A.)Tree /do'ble7rotation7,it$7le"t(A.)Tree /8:) { 8:52le"t & single7rotation7,it$7rig$t(8:52le"t)% ret'rn single7rotation7,it$7le"t(8:)% } A.)Tree /do'ble7rotation7,it$7rig$t(A.)Tree /8:) { 8:52rig$t & single7rotation7,it$7le"t(8:52rig$t)% ret'rn single7rotation7,it$7rig$t(8:)% } (oid insert(int (al'e# A.)Tree //node) { i" (/node && N4))) { /node & ne, A.)Tree% i" (/node && N4))) { ret'rn% } (/node)52element & (al'e% (/node)52$eig$t & ;% (/node)52le"t & (/node)52rig$t & N4))% ret'rn% } else i" ((al'e 3 (/node)52element) { insert((al'e# <((/node)52le"t))% i" ($eig$t((/node)52le"t) 5 $eig$t((/node)52rig$t) && 9) { i" ((al'e 3 (/node)52le"t52element) { /node & single7rotation7,it$7le"t(/node)% } else { /node & do'ble7rotation7,it$7le"t(/node)% } } } else i" ((al'e 2 (/node)52element) { insert((al'e# <((/node)52rig$t))% i" ($eig$t((/node)52rig$t) 5 $eig$t((/node)52le"t) && 9) { i" ((al'e 2 (/node)52rig$t52element) { /node & single7rotation7,it$7rig$t(/node)% } else { /node & do'ble7rotation7,it$7rig$t(/node)% } } } (/node)52$eig$t & 0A1($eig$t((/node)52le"t)# $eig$t((/node)52rig$t)) + 6% } 1onsier an input sequence that is pro$ie as an input to the insert metho 28!9!19!:!1;!2!<!12!1=!19!1<!1>!18!1: In the process of insertin" the abo$e noes ho% many times ouble@rotation@%ith@ri"ht is bein" calle ; 2 8 9 Question Number 4 1onsier an (A? Tree has a follo%in" noe structure: str'ct A.)Tree { A.)Tree / le"t# A.)Tree / rig$t% int element% int $eig$t% }% 1onsier a binary search tree ha$in" 2 noes say 188 an 18#Insert a ne% noe 98 into the binary tree#(fter insertin" the noe! tree has to be balance A.)Tree / >'nc6(A.)Tree /node9) { A.)Tree / node6% node6 & node952le"t% node952le"t & node652rig$t% node652rig$t & node9% ret'rn node6% } A.)Tree / >'nc9(A.)Tree /node9) { A.)Tree / node6% node6 & node952rig$t% node952rig$t & node652le"t% node652le"t & node9% ret'rn node6% } (bo$e t%o functions are efine! %hich one of the abo$e t%o can be use to balance the tree after the insertion of noe 980 If both the functions has to be use specify the orer in %hich it has to be use# Func1 ! Func2 Func2 ! Func1 Func2 Func1 Support ID: F12DE> Question Number 5 1onsier an (A? Tree has a follo%in" noe structure: str'ct A.)Tree { A.)Tree / le"t# A.)Tree / rig$t% int element% int $eig$t% }% 1onsier a binary tree %ith an array representation of 7i$en the follo%in" coe snippet A.)Tree / >'nc(A.)Tree /node9) { A.)Tree / node6% node6 & node952rig$t% node952rig$t & node652le"t% node652le"t & node9% ret'rn node6% } Func is calle only if any of the noe is not hei"ht balance# If the tree is unbalance! consier noe 18 is passe as an ar"ument to Func# %hat %oul be the root noe of the resultin" binary tree0 18 28 9 Func %oul not be calle as the abo$e binary tree is hei"ht balance# Question Number 1onsier an (A? Tree has a follo%in" noe structure: str'ct A.)Tree { A.)Tree / le"t# A.)Tree / rig$t% int element% int $eig$t% }% 1onsier a binary tree %ith an array representation of 7i$en the follo%in" coe snippet (A?Tree B Func,(A?Tree Bnoe2. C (A?Tree B noe1D noe1 E noe26FleftD noe26Fleft E noe16Fri"htD noe16Fri"ht E noe2D return noe1D G 1onsier root noe of the abo$e binary tree is passe to Func#Func is calle only if any of the noe is not hei"ht balance#/ill Func be calle for the abo$e binary tree!if yes! %hat %oul be the root noe of the resultin" binary tree0 Hes! 9 Hes! 18 2o Hes! 28 Question Number # 1onsier an (A? Tree has a follo%in" noe structure: str'ct A.)Tree { A.)Tree / le"t# A.)Tree / rig$t% int element% int $eig$t% }% 1onsier that you ha$e a hei"ht balance binary search tree %ith the follo%in" array representation 1onsier that you ha$e to enter a ne% noe > into the abo$e hei"ht balance binary search tree A.)Tree / >'nc6(A.)Tree /node9) { A.)Tree / node6% node6 & node952le"t% node952le"t & node652rig$t% node652rig$t & node9% ret'rn node6% } A.)Tree / >'nc9(A.)Tree /node9) { A.)Tree / node6% node6 & node952rig$t% node952rig$t & node652le"t% node652le"t & node9% ret'rn node6% } In %hich of the follo%in" sequence Func1 an Func2 is use to balance the tree after insertin" the ne% noe into the hei"ht balance binary search tree0 Func2! Func1 Func1! Func2 Func1! Func1 Func2! Func2 Support ID: F12DD8 Question Number ! 7i$en the follo%in" coe snippet ans%er the follo%in" question# Follo%in" is the escription of a tree Threae binary tree: The noe of a binary tree ha$in" both the left link an the ri"ht link pointin" to null or one of the links pointin" to null# If the left link of the noe is empty point it to the inorer preecessor an if the ri"ht link is empty point it to the in orer successor of the noe# str'ct tNode{ str'ct tNode /+)e"t% int data% str'ct tNode /+*ig$t% int le"t"lag% int rig$t"lag% } )ere leftfla" an ri"htfla" are use to ecie if the noe is pointin" to the inorer preecessor an the inorer successor respecti$ely or to the subtree# If the fla"s are 8 noes point to the subtree# 7i$en a coe snippet Tra(erse(tNode //node){ tNode /c'r% c'r & (/node)52+)e"t% ,$ile(c'r=&/node){ std??co't33c'r52data33std??endl% ,$ile(c'r52le"t"lag&&;) c'r & c'r52+)e"t% else i"(c'r52+*ig$t&&;) c'r & c'r52+*ig$t% else{ ,$ile(c'r52rig$t"lag && 6) c'r & c'r52+*ig$t% i"((c'r52rig$t"lag&&N4))node)<<(c'r&&root)) brea8% c'r & c'r52+*ig$t% } } } (bo$e coe snippet is use to tra$erse a threae binary tree#Fin out the type of tra$ersal implemente in the abo$e coe snippet0 Ireorer Iostorer Inorer ?e$elorer Question Number " 7i$en the follo%in" coe snippet ans%er the follo%in" question# /hich one of the follo%in" %ill not make the mirror ima"e of the tree0 (oid >'nc(tNode //node){ i"(/node=&N4))){ >'nc(<(/node)52+)e"t)% >'nc(<(/node)52+*ig$t)% tNode /tem+% tem+ & (/node)52+)e"t% (/node)52+)e"t& (/node)52+*ig$t% (/node)52+*ig$t & tem+% } } (oid >'nc(tNode //node){ i"(/node=&N4))){ >'nc(<(/node)52+)e"t)% tNode /tem+% tem+ & (/node)52+)e"t% (/node)52+)e"t& (/node)52+*ig$t% (/node)52+*ig$t & tem+% >'nc(<(/node)52+*ig$t)% } } (oid >'nc(tNode //node){ i"(/node=&N4))){ tNode /tem+% tem+ & (/node)52+)e"t% (/node)52+)e"t& (/node)52+*ig$t% (/node)52+*ig$t & tem+% >'nc(<(/node)52+)e"t)% >'nc(<(/node)52+*ig$t)% } } 2one of these Support ID: F12DD( Question Number $% 7i$en the follo%in" coe snippet ans%er the follo%in" question# Follo%in" is the escription of a tree Threae binary tree: The noe of a binary tree ha$in" both the left link an the ri"ht link pointin" to null or one of the links pointin" to null# If the left link of the noe is empty point it to the inorer preecessor an if the ri"ht link is empty point it to the in orer successor of the noe# str'ct tNode{ str'ct tNode /+)e"t% int data% str'ct tNode /+*ig$t% int le"t"lag% int rig$t"lag% } )ere leftfla" an ri"htfla" are use to ecie if the noe is pointin" to the inorer preecessor an the inorer successor respecti$ely or to the subtree# If the fla"s are 8 noes point to the subtree# 7i$en a coe snippet Tra(erse(tNode //node){ tNode /c'r% c'r & (/node)52+)e"t% ,$ile(c'r=&/node){ ,$ile(c'r52le"t"lag&&;) c'r & c'r52+)e"t% std??co't33c'r52data33std??endl% ,$ile(c'r52rig$t"lag && 6){ c'r & c'r52+*ig$t% i"(c'r&&node) brea8% std??co't33c'r52data33std??endl% } c'r & c'r52+*ig$t% } } (bo$e coe snippet is use to tra$erse a threae binary tree#Fin out the type of tra$ersal implemente in the abo$e coe snippet0 Ireorer Iostorer Inorer ?e$elorer So&t'are (ngineering Aptitude Section )nstructions This is the Jath Keasonin" section# It is esi"ne to test your ability to unerstan an implement mathematical principles %ithin concrete circumstances# Lse the information presente in each question to sol$e the problem# Hou %ill ha$e 18 minutes to complete the 18 questions in this section# 1ontinue uestion Number 2 ( an ' start opposite ens M I an N respecti$ely M of s%immin" pool# They meet at 1= m from I for the first time an 2 m from N for the secon time# /hat is the len"th of the pool if both ( an ' s%im %ith constant but ifferent spees an the spee of no neither is more than t%ice the spee of the other0 =9 m == m ;< m =8 m Answer Skip Question Number 4 Sol$e for +# 2 = 1 ; Support ID: F1;F;F Question Number 5 In an e+amination! ( "ot 18O marks less than 'D' "ot 29O marks more than 1 an 1 "ot 28O less than D# If ( "ot ;<8 marks out of 988! the percenta"e of marks obtaine by D %as0 >8 88 89 >9 Answer Skip Support ID: F1;F;1 Question Number # ( plane tra$els 2!988 km! 1!288 km! 988 km at the rate of 988 kmPhr! =88 kmPhr! 298 kmPhr respecti$ely# The a$era"e spee is @@@@@@@@@@0 =89 kmPhr =18 kmPhr 9>9 kmPhr =28 kmPhr Support ID: F1;F;8 Question Number ! (ny is 29O more efficient than 'arry %ho is 28O more efficient than 1olin# 'arry takes 12 ays more than (ny to complete a project if either %orks alone# If 1olin %orks alone on that project for ;< ays an (ny then %orks alone on it for 1< ays! then ho% many ays %oul 'arry %orkin" alone take to complete it0 8 18 12 1< So&t'are (ngineering Aptitude Section )nstructions This is the IT Keasonin" section# It is esi"ne to test your unerstanin" of the principles of lo"ic# Hou %ill be presente %ith a $ariety of questions that you must sol$e usin" principles of lo"ic# Hou %ill ha$e 18 minutes to complete the 18 questions in this section# 1ontinue Support ID: F1;F;9 Question Number $ ( %holesaler offers a scheme %here if a shopkeeper orers a oQen,12. bottles of a certain ener"y rink! he "ets ;< complementary "lasses to be "i$en to customers# The shopkeeper ecies to "i$e t%o "lasses per bottle purchase by customers# If he purchases R oQen bottles from the %holesaler an sells t%o6thirs of those to customers! the number of "lasses remainin" %ith him is represente by @@@@@@@@@@# R B ;< M 2 B R B 2P; R B ;< M 12 B R B 2P; R B ;< M 2 B 12 B R R B ;< M 2 B 1 Question Number 2 (n airline assumes that on a$era"e each passen"er %ei"hs + pouns# It also assumes that 88O of passen"ers %ill ha$e lu""a"e %hich on a$era"e %ei"hs y pouns# In aition to passen"ers! each airplane carries frei"ht an the airline assumes that each container %ei"hs Q pouns# )o% %oul you calculate the e+pecte %ei"ht of a plane scheule to carry I passen"ers an F containers of frei"ht# 8#8I+ - Iy - FQ 8#8,I+ - Iy. - FQ I,+ - #8y.FQ I,+ - #8y. - FQ Question Number 3 The problem belo% contains a question an t%o statements labele ( an ' that "i$e ata pertainin" to the question# Determine %hether the information "i$en in statements ( an ' is sufficient to ans%er the question! an select the correct ans%er from the "i$en options# Does Ienny earn more than Fanny0 (# If Ienny "ets a raise of 18O then she %ill earn S288 more than Fanny '# If Fanny "ets a raise of 18O she %ill earn S288 more than Ienny The question can be ans%ere by usin" one of the statements alone but not the other The question can be ans%ere by usin" either statement alone The question can be ans%ere by usin" both the statements to"ether! but not by usin" either statement alone 2either of the statements! ini$iually or jointly! pro$ies sufficient ata to ans%er the question The sum of t%o natural numbers is *a* an the ifference is *b*# The smaller number is @@@@@@@@@@# ,a-b.P2 2,a6b. a-b ,a6b.P2 Question Number 5 The problem belo% contains a question an t%o statements labele ( an ' that "i$e ata pertainin" to the question# Determine %hether the information "i$en in statements ( an ' is sufficient to ans%er the question! an select the correct ans%er from options 16=# 1# The question can be ans%ere by usin" one of the statements alone but not the other# 2# The question can be ans%ere by usin" either statement alone# ;# The question can be ans%ere by usin" both the statements to"ether# =# 2either of the statements! ini$iually or jointly! pro$ies sufficient ata to ans%er the question# If Kay is oler than Iat! %hat is the present a"e of each0 (# The sum of the squares of their a"es is a quarter more than the ifference of the squares of their a"es# '# Iat is not yet 18! an the sum of their a"es is more than ;9# 1 Question Number ( thousan men are typin" essays ,each essay consists of H %ors. at a rate of R %ors per minute# E$ery hour a hunre of the ori"inal thousan men stop typin"! an fifty ne% men! %ho type at the rate of RP2 %ors per minute! join the "roup# (fter four hours the number of essays that ha$e been type is @@@@@@@@@@# ;>98 B R B H P <8 ;998 B R B H P <8 ;>98 B R B <8 P H ;998 B R B <8 P H Support ID: F1;F2' Question Number # The follo%in" problem consists of a question follo%e by information in three statements# Ientify the statement,s. that isPare 2TT neee to ans%er the question# The a$era"e price of three objects (! ' U 1 is LS S1;# /hat are their ini$iual prices0 (# The sum of the prices of ( U ' is LS S;8 '# The sum of the prices of ' U 1 is LS S2> 1# The sum of the prices of ( U 1 is LS S21 ( ' 1 (ny one of the three statements Question Number $% The problem belo% contains a question an t%o statements labele ( an ' that "i$e ata pertainin" to the question# Determine %hether the information "i$en in statements ( an ' is sufficient to ans%er the question! an select the correct ans%er from the "i$en options# 'et%een (ny an 'arry! %ho score more on a test they both took0 (# 1oy! %ho score less than (ny! also score less than 'arry '# (ny score more than Danny! %ho score more than 'arry The question can be ans%ere by usin" one of the statements alone but not the other The question can be ans%ere by usin" either statement alone The question can be ans%ere by usin" both the statements to"ether! but not by usin" either statement alone 2either of the statements! ini$iually or jointly! pro$ies sufficient ata to ans%er the question So&t'are (ngineering Aptitude Section )nstructions This is the (ttention to Detail section# It is esi"ne to test your ability to ahere to etail %ithin a lar"e $olume of information# For the follo%in" ten questions you %ill be presente %ith one table of information as %ell as a line of information from that table# Lsin" the table! ientify if the line of information presente is correct or not# Hou %ill ha$e 9 minutes to complete the 18 questions in this section# 1ontinue Section )nstructions This is the ?o"ic Dia"rammin" section# It is esi"ne to test your ability to follo% a %orkflo% in a lo"ical manner# For the follo%in" fi$e questions you %ill be presente %ith one ia"ram epictin" a %orkflo%# Kefer to the ia"ram in orer to ans%er each of the questions# Hou %ill ha$e 18 minutes to complete the 9 questions in this section# 1ontinue estion Number 2 Ilease carefully rea the follo%in": The follo%in" flo%chart represents the process escribe belo%# Tnce you ha$e rea the escription of the process! ans%er the question belo% the flo%chart# ( "ame is playe by t%o players %ith a bo+ containin" a lar"e number of marbles! each of %hich is one of four ifferent colors# The "ame is score as follo%s: 1# Tn each turn! each player ra%s t%o marbles# 2# (fter each turn! a player may make an offer to e+chan"e an equal number of marbles ,2. of any one color ,11. %ith an equal number of marbles ,2. of any other color ,12. %ith the other player# ;# ( player %ins the "ame by "ettin" a score of one hunre first# Each player "ains one point for each marble of the ominant color ,the color %ith the most number of marbles %ith that player. that hePshe has an loses 1 point for e$ery marble of another color that hePshe has# The number of marbles of each color that each player has is tracke by the $ariables J,I! 1T?TK.! %here I is either 1 or 2 for each player an 1T?TK may be 1! 2! ; or = for the respecti$e colors# The score is tracke by the $ariable S1TKE,I.# (ll $ariables start at 8! e+cept I %hich starts at 1# /hat is the $alue of 1ell =0 Is S1TKE,I. F ::0 Is S1TKE,I. E 1880 Is S1TKE,I. F 1880 Is S1TKE,I. E 1810 Question Number 3 Ilease carefully rea the follo%in": The follo%in" flo%chart represents the process escribe belo%# Tnce you ha$e rea the escription of the process! ans%er the question belo% the flo%chart# ( "ame is playe by t%o players %ith a bo+ containin" a lar"e number of marbles! each of %hich is one of four ifferent colors# The "ame is score as follo%s: 1# Tn each turn! each player ra%s t%o marbles# 2# (fter each turn! a player may make an offer to e+chan"e an equal number of marbles ,2. of any one color ,11. %ith an equal number of marbles ,2. of any other color ,12. %ith the other player# ;# ( player %ins the "ame by "ettin" a score of one hunre first# Each player "ains one point for each marble of the ominant color ,the color %ith the most number of marbles %ith that player. that hePshe has an loses 1 point for e$ery marble of another color that hePshe has# The number of marbles of each color that each player has is tracke by the $ariables J,I! 1T?TK.! %here I is either 1 or 2 for each player an 1T?TK may be 1! 2! ; or = for the respecti$e colors# The score is tracke by the $ariable S1TKE,I.# (ll $ariables start at 8! e+cept I %hich starts at 1# /hat is the $alue of 1ell 20 S1TKE,I. E S1TKE,I.6J,I! R. S1TKE,I. E S1TKE,I.-J,I! R. S1TKE,I. E S1TKE,I.6J,I! J(R. S1TKE,I. E S1TKE,I.-J,I! J(R. So&t'are (ngineering Aptitude Support ID: F1;F11 Question Number 4 Ilease carefully rea the follo%in": The follo%in" flo%chart represents the process escribe belo%# Tnce you ha$e rea the escription of the process! ans%er the question belo% the flo%chart# ( "ame is playe by t%o players %ith a bo+ containin" a lar"e number of marbles! each of %hich is one of four ifferent colors# The "ame is score as follo%s: 1# Tn each turn! each player ra%s t%o marbles# 2# (fter each turn! a player may make an offer to e+chan"e an equal number of marbles ,2. of any one color ,11. %ith an equal number of marbles ,2. of any other color ,12. %ith the other player# ;# ( player %ins the "ame by "ettin" a score of one hunre first# Each player "ains one point for each marble of the ominant color ,the color %ith the most number of marbles %ith that player. that hePshe has an loses 1 point for e$ery marble of another color that hePshe has# The number of marbles of each color that each player has is tracke by the $ariables J,I! 1T?TK.! %here I is either 1 or 2 for each player an 1T?TK may be 1! 2! ; or = for the respecti$e colors# The score is tracke by the $ariable S1TKE,I.# (ll $ariables start at 8! e+cept I %hich starts at 1# /hat is the $alue of 1ell 10 Is J,I!R. F R0 Is J,I!R. F S1TKE,I.0 Is J,I!R. V J(R0 Is J,I!R. F J(R0 Support ID: F1;F1F Question Number 5 Ilease carefully rea the follo%in": The follo%in" flo%chart represents the process escribe belo%# Tnce you ha$e rea the escription of the process! ans%er the question belo% the flo%chart# ( "ame is playe by t%o players %ith a bo+ containin" a lar"e number of marbles! each of %hich is one of four ifferent colors# The "ame is score as follo%s: 1# Tn each turn! each player ra%s t%o marbles# 2# (fter each turn! a player may make an offer to e+chan"e an equal number of marbles ,2. of any one color ,11. %ith an equal number of marbles ,2. of any other color ,12. %ith the other player# ;# ( player %ins the "ame by "ettin" a score of one hunre first# Each player "ains one point for each marble of the ominant color ,the color %ith the most number of marbles %ith that player. that hePshe has an loses 1 point for e$ery marble of another color that hePshe has# The number of marbles of each color that each player has is tracke by the $ariables J,I! 1T?TK.! %here I is either 1 or 2 for each player an 1T?TK may be 1! 2! ; or = for the respecti$e colors# The score is tracke by the $ariable S1TKE,I.# (ll $ariables start at 8! e+cept I %hich starts at 1# /hat is the $alue of 1ell 90 Is I E 10 Is I E 20 Is R F =0 Is R F J(R0 Computer Science *no'ledge (+asic) Ilease rea all instructions $ery carefully before you be"in# This is the I(1 M 1omputer Science Wno%le"e ,'asic ?e$el. assessment# It is compose of 28 questions# Hou %ill ha$e 28 minutes to complete this assessment# Ilease note that once you ha$e complete a question you %ill 2TT be able to return to it in orer to make chan"es# (ll questions carry equal points an no points are eucte for %ron" ans%ers# Assessment +reakdo'n Section ,ime Questions TS 1oncepts an Data Structures > Jinutes > 'i" T notations an TT(D Funamentals < Jinutes < D'JS an 1TDD*s Funamentals > Jinutes > ,otals 2% -inutes 2% Questio Computer Science *no'ledge (+asic) Support ID: F18E9( Question Number 3 Select the ecimal $alue of lo"ical shift ri"ht by ; operation on a si"ne inte"er 628# -8; 6; -; -28; Support ID: F18E9D Question Number 4 1onsier an application that requires insertin" an eletin" ata items in a ata structure ynamically# From the follo%in" options! select an appropriate ata structure for this scenario# Stack Nueue ?inke ?ist (rray /hat is the primary a$anta"e of usin" bytecoe interpreters or $irtual machines for pro"ram e+ecution0 Security Keuce memory use Spee Iortabili Question Number Select the option that escribes the hea6tail linke list# (llo%s aition of elements to only one en an remo$al from the other (llo%s ain" or remo$in" the elements from the front or back (llo%s eletion of elements from both ens! but restriction of input from only one en (llo%s takin" input at both ens! but restricts the output to be mae from only one en Question Number # Select the ecimal $alue of arithmetic shift ri"ht by 2 operation on a si"ne inte"er 6182# 6;: 69> -9> -;: Question Number 2 From the follo%in" options! select the TTI mechanism! that allo%s treatment of the eri$e class members just like the members of their parent class# Encapsulation Iolymorphism (bstraction Decouplin" Question Number 3 Select the sortin" that al%ays has a time comple+ity T,n 2 .! irrespecti$e of the conition of the array# Selection sort 'ubble sort Nuick Sort Jer"e sort Support ID: F18E92 Question Number 4 Select the TTI concept escribe by the follo%in" features# (# Defines the abstract characteristics of a thin" ,object.# '# Defines attributes of the thin"# 1# Defines the beha$ior of the thin"# D# Kepresents a blueprint escribin" the nature of the thin"# Instance Jetho Function 1lass Support ID: F18E99 Question Number 5 Select the option that sho%s the correct matchin" bet%een the function types an the 'i" T escriptions# I 1onstant 1 T,lo" n. II ?o"arithmic 2 T,1. III ?inear ; T,n. IA Nuaratic = T,n ; . A 1ubic 9 T,2 n . AI E+ponential < T,n 2 . ,I!;.!,II!9.!,III!=.!,IA!<.!,A!2.!,AI!I. ,I!1.!,II!2.!,III!;.!,IA!=.!,A!9.!,AI!<. ,I!9.!,II!<.!,III!2.!,IA!1.!,A!=.!,AI!;. ,I!2.!,II!1.!,III!;.!,IA!<.!,A!=.!,AI!9. Question Number Select the option that enotes! &runtime is proportional to fi$e times the input siQe&# @/A(n) 9T,n. T,n 9 . T,9n. Question Number $ /hich one of the follo%in" is 2TT a referential inte"rity issue in a relational atabase %here the DEIT column of the EJI?THEE table is esi"nate as a forei"n key into the DEI(KTJE2T table0 Insertin" a ne% ro% into DEI(KTJE2T %ith a primary key that is not the $alue of the DEIT column of any ro% in EJI?THEE Lpatin" the $alue of DEIT in a ro% of EJI?THEE %ith a $alue that is not the primary key of any of the ro%s in DEI(KTJE2T Insertin" a ne% ro% into EJI?THEE %ith a DEIT %hose $alue is not the primary key of any of the ro%s in DEI(KTJE2T Deletin" a ro% of DEI(KTJE2T Question Number 2 ('1 )ousekeepin" Forces are responsible for maintainin" a builin" that comprises of 188 floors# The maintenance company ecies to use a atabase to scheule %ork for its employees an also check the status of the %ork# /hen an assi"ne housekeeper oes 2TT report for %ork! an alternate resource is allotte to complete the job# The )ousekeepin" atabase in its current form is "i$en belo%# .ousekeeper )ouseWeeperID )ouseWeeper2ame )ouseWeeperSS2 Super$isorID Supervisor Super$isorID Super$isor2ame Super$isorSS2 /loor Floor2o Floor2ame ,ransaction Floor2o DutyDate )ouseWeeperID /orkStatus Alternate,ransaction Floor2o DutyDate (lternate)ID (lternate/orkSt Select the option that correctly lists the composite primary keys for the $arious entities# 2ote that the entity names are "i$en in bol# .ousekeeper M )ousekeeperSS2 Supervisor M Super$isorSS2 /loor M Floor2o ,ransaction M Floor2o! DutyDate! (lternate)ID Alternate,ransaction M Floor2o! DutyDate! )ouseWeeperID .ousekeeper M )ousekeeperID Supervisor M Super$isorID /loor M Floor2o ,ransaction M Floor2o! DutyDate! (lternate)ID Alternate,ransaction M Floor2o! DutyDate! )ouseWeeperID ,ransaction M Floor2o! DutyDate! (lternate)ID Alternate,ransaction M Floor2o! DutyDate! )ouseWeeperID .ousekeeper M )ousekeeperID Supervisor M Super$isorID /loor M Floor2o ,ransaction M Floor2o Alternate,ransaction M Floor2o Question Number 3 Select the option that correctly escribes the atabase replication concept %here t%o or more replicas synchroniQe each other throu"h a transaction ientifier# Jultimastersla$e Jultimaster Nuorum Jaster6Sla$e Support ID: F18E=' Question Number 5 Select the option that represents the efinition of net%ork atabase moel# (llo%s each recor to ha$e multiple parent an chil recors! thereby formin" a lattice structure (ttempts to brin" closer interacti$ity bet%een atabase aministrators an application pro"rammers Kepresents the entire information content of the atabase in only one %ay Tr"aniQes the ata in the form of a tree of recors! %ith each recor ha$in" one parent recor an many chilren recors Question Number Hou ha$e t%o relation $ariables: KelA1 an KelA2# They are 2TT necessarily istinct# Hou ha$e a set W as a key for KelA1# 1onsier that FW is a subset of the heain" of KelA2 that in$ol$es e+actly the same attributes as W# From the follo%in" options! select the option that correctly epicts a scenario %here FW can be consiere as a forei"n key# E$ery tuple in KelA2 has a FW $alue that is equal to the W $alue in some tuple in KelA1 E$ery tuple in KelA1 has a W $alue that is equal to the FW $alue in some tuple in KelA2 E$ery tuple in KelA2 has a W $alue that is equal to the FW $alue in some tuple in KelA1 E$ery tuple in KelA1 has a FW $alue that is equal to the W $alue in some tuple in KelA2 Support ID: F18E=D Question Number # Select the option that represents the XI3 in (1ID rules# Each transaction must maintain the inte"rity constraints of the atabase (ny t%o simultaneous transactions cannot obstruct each other Either all the statements in a transaction must be e+ecute! or none of them shoul be e+ecute The complete transactions cannot be aborte later