Which one is the key thing in backtracking? Insertion Recursion Submission   In what manner is a state-space tree for a backtracking algorithm constructed? Depth-first search Breadth-first search Twice around the tree Nearest neighbour first   What does the following function do? int fun(int x, int y) {     if (y == 0)   return 0;     return (x + fun(x, y-1)); } x + y x + x*y x*y xy

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Which one is the key thing in backtracking?

Insertion

Recursion

Submission

 

In what manner is a state-space tree for a backtracking algorithm constructed?

Depth-first search

Breadth-first search

Twice around the tree

Nearest neighbour first

 

What does the following function do?

int fun(int x, int y)

{

    if (y == 0)   return 0;

    return (x + fun(x, y-1));

}

x + y

x + x*y

x*y

xy

 

 

Consider the following recursive function fun(x, y). What is the value of fun(4, 3)

int fun(int x, int y)

{

  if (x == 0)

    return y;

  return fun(x - 1,  x + y);

}

10

9

13

12

 

Predict output of following program

 

16

4

Runtime Error

8

 

Assume you have the following backtracking based sorting algorithm:
bool Backtracking_Sort(sorted_list, unsorted_list, index, length) {
    if (index == length) {
        return true;
    }
    Potential_values = []; 
    If (index != 0) {
Potential_values = get_larger_unused_values(sorted_list, unsorted_list, index);
} else {
    Potential_values = copy(unsorted_list);
}
    While(NotEmpty(potential_values) {
        Next_value = Choose_Random_Element(potential_values);
        Sorted_list[index] = next_value;
        If(Backtracking_Sort(sorted_list, unsorted_list, index + 1, length) == true){
            Return true;

Potential_Values.Remove(next_value);
    }
    return false;
}

Assume that you have an array of length 20, what is the base case for this recursive algorithm?

When Index = 19

When Index == 20

When Index = 21

When Index == 0

When Index = 10

 

What is the “dead end” condition in this algorithm which forces the backtrack?

 

When index == length

When NotEmpty(potential_values) is true

When Index != 0

When Index == 0

When NotEmpty(potential_values) is false

 

Assume you have the unsorted list [10, 3, 9, 5, 8] and have a partially created sorted list equal to [3, 8] index==2, what are the potential values for the next value in the sorted list?

9

10

9, 10

5, 3, 8

10, 9, 5, 8

 

Assume you have a list of 100 elements, in the first call of the algorithm how many potential candidates are there for the first element of the sorted list?

100

50

99

101

98

 

Which of the following lines of code prevents the algorithm from choosing already explored candidate values twice?

Next_value = Choose_Random_Element(potential_values);

Potential_values = get_larger_unused_values(sorted_list, unsorted_list, index);

Sorted_list[index] = next_value;

Potential_values = copy(unsorted_list)

Potential_Values.Remove(next_value); 

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of trees
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education