Basic CS-Data Structures [3i Infotech Placement]: Sample Questions 21 - 22 of 52

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 21

Data Structures
Edit

Describe in Detail

Essay▾

What is the algorithm used in solving the 8 queens problem?

Explanation

Understanding of Backtracking
  • Backtracking is the type of the algorithm used in solving the 8 Queens problem.
  • Considers searching every possible combination in order to solve an optimization problem.
  • Also known as depth-first search.

Algorithm of backtracking:

  • Boolean solve (Node n)

    {

    If n is a leaf node

    {

    If the leaf is goal node, return true

    Else return false

    }

    Else

    {

    For each child c of n

    {

    If solve (c) succeeds, return true

    }

    Return false

    }

    }

  • The algorithm is expressed as a Boolean function.

Question 22

Data Structures
Edit

Write in Short

Short Answer▾

If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

Explanation

  • The heterogeneous linked list contains different data types in its nodes and need a link, pointer to connect them.
  • Not possible to use ordinary pointers.
  • Void pointer is capable of storing pointer to type as a generic pointer type- which in linked list can be in-built data type or user defined structure.
  • Storing pointer in a void in not a problem.
  • Problem when the time of accessing - when we require to know data structure type.

Developed by: