SlideShare a Scribd company logo
TREE & GRAPH MCQs
How will you find the minimum element in a binary search
tree?
How will you find the minimum element in
a binary search tree?
public void min(Tree root)
{
while(root.left() != null)
{ root = root.left(); }
System.out.println(root.data());
}
What does the following piece of code do?
public void func(Tree root)
{
System.out.println(root.data());
func(root.left());
func(root.right());
}
a) Preorder traversal
b) Inorder traversal
c) Postorder traversal
d) Level order traversal
What does the following piece of code do?
public void func(Tree root)
{
System.out.println(root.data());
func(root.left());
func(root.right());
}
a) Preorder traversal
b) Inorder traversal
c) Postorder traversal
d) Level order traversal
Postorder traversal
 What is the speciality about the inorder traversal of a binary search tree?
a) It traverses in a non increasing order
b) It traverses in an increasing order
c) It traverses in a random fashion
d) It traverses based on priority of the node
 What is the speciality about the inorder traversal of a binary search tree?
a) It traverses in a non increasing order
b) It traverses in an increasing order
c) It traverses in a random fashion
d) It traverses based on priority of the node
 b) It traverses in an increasing order
 What are the worst case and average case complexities of a binary search tree?
a) O(n), O(n)
b) O(logn), O(logn)
c) O(logn), O(n)
d) O(n), O(logn)
 What are the worst case and average case complexities of a binary search tree?
a) O(n), O(n)
b) O(logn), O(logn)
c) O(logn), O(n)
d) O(n), O(logn)
 Answer: d
Explanation: Worst case arises when the tree is skewed(either to the left or right) in which case
you have to process all the nodes of the tree giving O(n) complexity, otherwise O(logn) as you
process only the left half or the right half of the tree.
 Construct a binary search tree with the below information.
 The preorder traversal of a binary search tree
10, 4, 3, 5, 11, 12.
 Construct a binary search tree with the below information.
 The preorder traversal of a binary search tree
10, 4, 3, 5, 11, 12.
 2. The balance factor of a node in a binary tree is defined as _____
a) addition of heights of left and right subtrees
b) height of right subtree minus height of left subtree
c) height of left subtree minus height of right subtree
d) height of right subtree minus one
 2. The balance factor of a node in a binary tree is defined as _____
a) addition of heights of left and right subtrees
b) height of right subtree minus height of left subtree
c) height of left subtree minus height of right subtree
d) height of right subtree minus one
 Answer: c
Explanation: For a node in a binary tree, the difference between the heights of its left subtree and
right subtree is known as balance factor of the node.
 A binary tree is balanced if the difference between left and right subtree of every node is not
more than ____
a) 1
b) 3
c) 2
d) 0
 A binary tree is balanced if the difference between left and right subtree of every node is not
more than ____
a) 1
b) 3
c) 2
d) 0
 Answer: a
Explanation: In a balanced binary tree the heights of two subtrees of every node never differ by
more than 1.
 Which of the following tree data structures is not a balanced binary tree?
a) AVL tree
b) Red-black tree
c) Splay tree
d) B-tree
 Which of the following tree data structures is not a balanced binary tree?
a) AVL tree
b) Red-black tree
c) Splay tree
d) B-tree
 Answer: d
Explanation: All the tree data structures given in options are balanced, but B-tree can have more
than two children.
 Find inorder successor for the given key in a BST

The inorder successor of 8 is ?
The inorder successor of 12 is ?
The inorder successor of 25 ?
 The leaves of an expression tree always contain?
a) operators
b) operands
c) null
d) expression
 The leaves of an expression tree always contain?
a) operators
b) operands
c) null
d) expression
 Answer: b
Explanation: The leaves of an expression tree always contain the result of a given expression
(i.e.) operands.
 ++a*bc*+defg is an?
a) postfix expression
b) infix expression
c) prefix expression
d) invalid expression
 ++a*bc*+defg is an?
a) postfix expression
b) infix expression
c) prefix expression
d) invalid expression
 Answer: c
Explanation: It is a prefix expression obtained from a preorder traversal since it is of the form
operator-operand-operand.
What is the postfix expression for the following
expression tree?
a) abcde++**
b) ab+cde+**
c) abc+de+**
d) abcd+*e+*
What is the postfix expression for the following
expression tree?
a) abcde++**
b) ab+cde+**
c) abc+de+**
d) abcd+*e+*
Answer: b
Explanation: If the given expression tree is evaluated, the postfix
expression ab+cde+** is obtained.
In the given graph identify the cut vertices.
a) B and E
b) C and D
c) A and E
d) C and B
In the given graph identify the cut vertices.
a) B and E
b) C and D
c) A and E
d) C and B
Answer: d
Explanation: After removing either B or C, the graph becomes
disconnected.
For the given graph(G), which of the following
statements is true?
a) G is a complete graph
b) G is not a connected graph
c) The vertex connectivity of the graph is 2
d) The edge connectivity of the graph is 1
For the given graph(G), which of the following
statements is true?
a) G is a complete graph
b) G is not a connected graph
c) The vertex connectivity of the graph is 2
d) The edge connectivity of the graph is 1
Answer: c
Explanation: After removing vertices B and C, the graph becomes
disconnected.
 What is the number of edges present in a complete graph having n vertices?
a) (n*(n+1))/2
b) (n*(n-1))/2
c) n
d) Information given is insufficient
 What is the number of edges present in a complete graph having n vertices?
a) (n*(n+1))/2
b) (n*(n-1))/2
c) n
d) Information given is insufficient
 Answer: b
Explanation: Number of ways in which every vertex can be connected to each other is nC2.
The given Graph is regular.
a) True
b) False
Answer: a
Explanation: In a regular graph, degrees of all the vertices are equal. In
the given graph the degree of every vertex is 3.

More Related Content

Similar to DS MCQS.pptx

Data structure part 2
Data structure part  2Data structure part  2
Data structure part 2
Knowledge Center Computer
 
NET_Solved ans
NET_Solved ansNET_Solved ans
NET_Solved ans
Farhana Sathath
 
Gate Previous Years Papers
Gate Previous Years PapersGate Previous Years Papers
Gate Previous Years Papers
Rahul Jain
 
Data structure
Data structureData structure
Data structure
Vivek Kumar Sinha
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007
Rohit Garg
 
AP PGECET Computer Science 2016 question paper
AP PGECET Computer Science 2016 question paperAP PGECET Computer Science 2016 question paper
AP PGECET Computer Science 2016 question paper
Eneutron
 
Gate-Cs 1996
Gate-Cs 1996Gate-Cs 1996
Gate-Cs 1996
Ravi Rajput
 
AC14 AT11 Database Management Systems OBJECTIVE TYPE QUESTIONS
AC14 AT11 Database Management Systems OBJECTIVE TYPE QUESTIONSAC14 AT11 Database Management Systems OBJECTIVE TYPE QUESTIONS
AC14 AT11 Database Management Systems OBJECTIVE TYPE QUESTIONS
Courtney Esco
 
gate-Cs 2000
gate-Cs 2000gate-Cs 2000
gate-Cs 2000
Ravi Rajput
 
Data structure part 1
Data structure part  1Data structure part  1
Data structure part 1
Knowledge Center Computer
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
Om Prakash
 
Chap 5 Tree.ppt
Chap 5 Tree.pptChap 5 Tree.ppt
Chap 5 Tree.ppt
shashankbhadouria4
 
Technical aptitude questions_e_book1
Technical aptitude questions_e_book1Technical aptitude questions_e_book1
Technical aptitude questions_e_book1
Sateesh Allu
 
Gate-Cs 1998
Gate-Cs 1998Gate-Cs 1998
Gate-Cs 1998
Ravi Rajput
 
for sbi so Ds c c++ unix rdbms sql cn os
for sbi so   Ds c c++ unix rdbms sql cn osfor sbi so   Ds c c++ unix rdbms sql cn os
for sbi so Ds c c++ unix rdbms sql cn os
alisha230390
 
C programming & data structure
C programming & data structureC programming & data structure
C programming & data structure
rajeev_123
 
Ee693 sept2014midsem
Ee693 sept2014midsemEe693 sept2014midsem
Ee693 sept2014midsem
Gopi Saiteja
 
Cs 2003
Cs 2003Cs 2003
Cs 2003
Ravi Rajput
 
Cs 2002
Cs 2002Cs 2002
Cs 2002
Ravi Rajput
 
Dat 305 dat305 dat 305 education for service uopstudy.com
Dat 305 dat305 dat 305 education for service   uopstudy.comDat 305 dat305 dat 305 education for service   uopstudy.com
Dat 305 dat305 dat 305 education for service uopstudy.com
ULLPTT
 

Similar to DS MCQS.pptx (20)

Data structure part 2
Data structure part  2Data structure part  2
Data structure part 2
 
NET_Solved ans
NET_Solved ansNET_Solved ans
NET_Solved ans
 
Gate Previous Years Papers
Gate Previous Years PapersGate Previous Years Papers
Gate Previous Years Papers
 
Data structure
Data structureData structure
Data structure
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007
 
AP PGECET Computer Science 2016 question paper
AP PGECET Computer Science 2016 question paperAP PGECET Computer Science 2016 question paper
AP PGECET Computer Science 2016 question paper
 
Gate-Cs 1996
Gate-Cs 1996Gate-Cs 1996
Gate-Cs 1996
 
AC14 AT11 Database Management Systems OBJECTIVE TYPE QUESTIONS
AC14 AT11 Database Management Systems OBJECTIVE TYPE QUESTIONSAC14 AT11 Database Management Systems OBJECTIVE TYPE QUESTIONS
AC14 AT11 Database Management Systems OBJECTIVE TYPE QUESTIONS
 
gate-Cs 2000
gate-Cs 2000gate-Cs 2000
gate-Cs 2000
 
Data structure part 1
Data structure part  1Data structure part  1
Data structure part 1
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
 
Chap 5 Tree.ppt
Chap 5 Tree.pptChap 5 Tree.ppt
Chap 5 Tree.ppt
 
Technical aptitude questions_e_book1
Technical aptitude questions_e_book1Technical aptitude questions_e_book1
Technical aptitude questions_e_book1
 
Gate-Cs 1998
Gate-Cs 1998Gate-Cs 1998
Gate-Cs 1998
 
for sbi so Ds c c++ unix rdbms sql cn os
for sbi so   Ds c c++ unix rdbms sql cn osfor sbi so   Ds c c++ unix rdbms sql cn os
for sbi so Ds c c++ unix rdbms sql cn os
 
C programming & data structure
C programming & data structureC programming & data structure
C programming & data structure
 
Ee693 sept2014midsem
Ee693 sept2014midsemEe693 sept2014midsem
Ee693 sept2014midsem
 
Cs 2003
Cs 2003Cs 2003
Cs 2003
 
Cs 2002
Cs 2002Cs 2002
Cs 2002
 
Dat 305 dat305 dat 305 education for service uopstudy.com
Dat 305 dat305 dat 305 education for service   uopstudy.comDat 305 dat305 dat 305 education for service   uopstudy.com
Dat 305 dat305 dat 305 education for service uopstudy.com
 

Recently uploaded

RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
manasideore6
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
zwunae
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx
benykoy2024
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
dxobcob
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 

Recently uploaded (20)

RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 

DS MCQS.pptx

  • 2. How will you find the minimum element in a binary search tree?
  • 3. How will you find the minimum element in a binary search tree? public void min(Tree root) { while(root.left() != null) { root = root.left(); } System.out.println(root.data()); }
  • 4. What does the following piece of code do? public void func(Tree root) { System.out.println(root.data()); func(root.left()); func(root.right()); } a) Preorder traversal b) Inorder traversal c) Postorder traversal d) Level order traversal
  • 5. What does the following piece of code do? public void func(Tree root) { System.out.println(root.data()); func(root.left()); func(root.right()); } a) Preorder traversal b) Inorder traversal c) Postorder traversal d) Level order traversal Postorder traversal
  • 6.  What is the speciality about the inorder traversal of a binary search tree? a) It traverses in a non increasing order b) It traverses in an increasing order c) It traverses in a random fashion d) It traverses based on priority of the node
  • 7.  What is the speciality about the inorder traversal of a binary search tree? a) It traverses in a non increasing order b) It traverses in an increasing order c) It traverses in a random fashion d) It traverses based on priority of the node  b) It traverses in an increasing order
  • 8.  What are the worst case and average case complexities of a binary search tree? a) O(n), O(n) b) O(logn), O(logn) c) O(logn), O(n) d) O(n), O(logn)
  • 9.  What are the worst case and average case complexities of a binary search tree? a) O(n), O(n) b) O(logn), O(logn) c) O(logn), O(n) d) O(n), O(logn)  Answer: d Explanation: Worst case arises when the tree is skewed(either to the left or right) in which case you have to process all the nodes of the tree giving O(n) complexity, otherwise O(logn) as you process only the left half or the right half of the tree.
  • 10.  Construct a binary search tree with the below information.  The preorder traversal of a binary search tree 10, 4, 3, 5, 11, 12.
  • 11.  Construct a binary search tree with the below information.  The preorder traversal of a binary search tree 10, 4, 3, 5, 11, 12.
  • 12.  2. The balance factor of a node in a binary tree is defined as _____ a) addition of heights of left and right subtrees b) height of right subtree minus height of left subtree c) height of left subtree minus height of right subtree d) height of right subtree minus one
  • 13.  2. The balance factor of a node in a binary tree is defined as _____ a) addition of heights of left and right subtrees b) height of right subtree minus height of left subtree c) height of left subtree minus height of right subtree d) height of right subtree minus one  Answer: c Explanation: For a node in a binary tree, the difference between the heights of its left subtree and right subtree is known as balance factor of the node.
  • 14.  A binary tree is balanced if the difference between left and right subtree of every node is not more than ____ a) 1 b) 3 c) 2 d) 0
  • 15.  A binary tree is balanced if the difference between left and right subtree of every node is not more than ____ a) 1 b) 3 c) 2 d) 0  Answer: a Explanation: In a balanced binary tree the heights of two subtrees of every node never differ by more than 1.
  • 16.  Which of the following tree data structures is not a balanced binary tree? a) AVL tree b) Red-black tree c) Splay tree d) B-tree
  • 17.  Which of the following tree data structures is not a balanced binary tree? a) AVL tree b) Red-black tree c) Splay tree d) B-tree  Answer: d Explanation: All the tree data structures given in options are balanced, but B-tree can have more than two children.
  • 18.  Find inorder successor for the given key in a BST  The inorder successor of 8 is ? The inorder successor of 12 is ? The inorder successor of 25 ?
  • 19.  The leaves of an expression tree always contain? a) operators b) operands c) null d) expression
  • 20.  The leaves of an expression tree always contain? a) operators b) operands c) null d) expression  Answer: b Explanation: The leaves of an expression tree always contain the result of a given expression (i.e.) operands.
  • 21.  ++a*bc*+defg is an? a) postfix expression b) infix expression c) prefix expression d) invalid expression
  • 22.  ++a*bc*+defg is an? a) postfix expression b) infix expression c) prefix expression d) invalid expression  Answer: c Explanation: It is a prefix expression obtained from a preorder traversal since it is of the form operator-operand-operand.
  • 23. What is the postfix expression for the following expression tree? a) abcde++** b) ab+cde+** c) abc+de+** d) abcd+*e+*
  • 24. What is the postfix expression for the following expression tree? a) abcde++** b) ab+cde+** c) abc+de+** d) abcd+*e+* Answer: b Explanation: If the given expression tree is evaluated, the postfix expression ab+cde+** is obtained.
  • 25. In the given graph identify the cut vertices. a) B and E b) C and D c) A and E d) C and B
  • 26. In the given graph identify the cut vertices. a) B and E b) C and D c) A and E d) C and B Answer: d Explanation: After removing either B or C, the graph becomes disconnected.
  • 27. For the given graph(G), which of the following statements is true? a) G is a complete graph b) G is not a connected graph c) The vertex connectivity of the graph is 2 d) The edge connectivity of the graph is 1
  • 28. For the given graph(G), which of the following statements is true? a) G is a complete graph b) G is not a connected graph c) The vertex connectivity of the graph is 2 d) The edge connectivity of the graph is 1 Answer: c Explanation: After removing vertices B and C, the graph becomes disconnected.
  • 29.  What is the number of edges present in a complete graph having n vertices? a) (n*(n+1))/2 b) (n*(n-1))/2 c) n d) Information given is insufficient
  • 30.  What is the number of edges present in a complete graph having n vertices? a) (n*(n+1))/2 b) (n*(n-1))/2 c) n d) Information given is insufficient  Answer: b Explanation: Number of ways in which every vertex can be connected to each other is nC2.
  • 31. The given Graph is regular. a) True b) False Answer: a Explanation: In a regular graph, degrees of all the vertices are equal. In the given graph the degree of every vertex is 3.