Advanced Algorithm (Eldan) 2 (11) Dan

Description

Quiz on Advanced Algorithm (Eldan) 2 (11) Dan, created by Alex Q on 24/12/2017.
Alex Q
Quiz by Alex Q, updated more than 1 year ago
Alex Q
Created by Alex Q over 6 years ago
47
2

Resource summary

Question 1

Question
Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited in a postorder, inorder and preorder traversal, respectively, of a complete binary tree. Which of the following is always true?
Answer
  • LASTIN = LASTPOST
  • LASTIN = LASTPRE
  • LASTPRE = LASTPOST
  • None of the above

Question 2

Question
Which one of the following binary trees has its inorder and preorder traversals as BCAD and ABCD, respectively?
Answer
  • A
  • B
  • C
  • D

Question 3

Question
The numbers 1, 2, .... n are inserted in a binary search tree in some order. In the resulting tree, the right subtree of the root contains p nodes. The first number to be inserted in the tree must be
Answer
  • p
  • p + 1
  • n - p
  • n - p + 1

Question 4

Question
A binary search tree contains the numbers 1, 2, 3, 4, 5, 6, 7, 8. When the tree is traversed in pre-order and the values in each node printed out, the sequence of values obtained is 5, 3, 1, 2, 4, 6, 8, 7. If the tree is traversed in post-order, the sequence obtained would be
Answer
  • 8, 7, 6, 5, 4, 3, 2, 1
  • 1, 2, 3, 4, 8, 7, 6, 5
  • 2, 1, 4, 3, 6, 7, 8, 5
  • 2, 1, 4, 3, 7, 8, 6, 5

Question 5

Question
If all the edge weights of an undirected graph are positive, then any subset of edges that connects all the vertices and has minimum total weight is a
Answer
  • Hamiltonian cycle
  • grid
  • hypercube
  • tree

Question 6

Question
When searching for the key value 60 in a binary search tree, nodes containing the key values 10, 20, 40, 50, 70 80, 90 are traversed, not necessarily in the order given. How many different orders are possible in which these key values can occur on the search path from the root to the node containing the value 60?
Answer
  • 35
  • 64
  • 5040
  • 128

Question 7

Question
The following three are known to be the preorder, inorder and postorder sequences of a binary tree. But it is not known which is which. MBCAFHPYK KAMCBYPFH MABCKYFPH Pick the true statement from the following.
Answer
  • I and II are preorder and inorder sequences, respectively
  • I and III are preorder and postorder sequences, respectively
  • II is the inorder sequence, but nothing more can be said about the other two sequences
  • II and III are the preorder and inorder sequences, respectively

Question 8

Question
Consider the following sequence of nodes for the undirected graph given below. a b e f d g c a b e f c g d a d g e b c f a d b c g e f A Depth First Search (DFS) is started at node a. The nodes are listed in the order they are first visited. Which all of the above is (are) possible output(s)?
Answer
  • 1 and 3 only
  • 2 and 3 only
  • 2, 3 and 4 only
  • 1, 2, and 3

Question 9

Question
Which of the following statement is false?
Answer
  • A tree with n nodes has (n-1) edges.
  • A labeled rooted binary tree can be uniquely constructed given its postorder and preorder traversal results.
  • A complete binary tree with n internal nodes has (n+1) leaves.
  • The maximum number of nodes in a binary tree of height h is (2^(k+1) -1)

Question 10

Question
A complete n-ary tree is one in which every node has 0 or n sons. If x is the number of internal nodes of a complete n-ary tree, the number of leaves in it is given by
Answer
  • x(n-1)+1
  • xn-1
  • xn+1
  • x(n+1)

Question 11

Question
Which of the following sequences denotes the post order traversal sequence of the given tree? a / \ b e / \ / c d f / g
Answer
  • f e g c d b a
  • g c b d a f e
  • g c d b f e a
  • f e d g c b a
Show full summary Hide full summary

Similar

AQA GCSE Biology genetic variation
Olivia Phillips
Suffragettes and Suffragists
Amula
English Language Terms
ekimlauretta
Pe - Principles of Training
Beccadf 1
An Inspector Calls
Georgia 27
AQA AS Biology Unit 2 The Cell cycle
elliedee
The Strange Case of Dr. Jekyll and Mr. Hyde
K d
Marketing and Distributing
Shannon Clarke
Treaty of Versailles
Krista Mitchell
2PR101 1.test - 7. část
Nikola Truong
Část 4.
Gábi Krsková