3i Infotech Papers: Sample Questions 838 - 839 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 838

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

  1. main ()
  2. {
  3.     printf ( “%d” out);
  4. }
  5. int out = 100;

Explanation

Compiler error: undefined symbol out in function main.

In a program

Table showing the program

Table showing the program

  1. main ()
  2. {
  3.     printf ( “%d” out);
  4. }
  5. int out = 100;

Print the value of out

The rule is that a variable is available for use from the point of declaration.

Even though is a global variable, it is not available for main.

Hence an error.

Question number: 839

» Basic CS » Data Structures

Essay Question▾

Describe in Detail

Draw the balanced B-tree of order 3 created by inserting the following data arriving in sequence 92 24 6 7 11 8 22 4 5 16 19 20 78

Explanation

For creating balanced Binary Tree read the first array element, create a new node with data and put it in queue. Do the below operations until the queue is empty.

  • Dequeue the data (Node) from queue and populate its left and Right child with data from array.

  • put the Left and Right child created in step 1 in Queue.

    For solving the problem, sort the array first now on this sorted array:

  • Get the middle element of the array and make it as Root of Binary Search Tree:

  • After getting the middle of array, it is divided into 2 parts, left half and right half.

    • Middle element of Left half will become Left child of Root Node (created in step 1)

    • Middle element of Right half will become Right child of Root Node (created in step 1)

  • Do above step recursively for left half and right half.

    • Get the middle of left half and make it left child of the root created in step 1.

    • Get the middle of right half and make it right child of the root created in step 1.

The balanced B-tree of order 3

The Balanced B-Tree of Order 3

The balanced B-tree of order 3

Image of the balanced Binary Tree

Image of the Balanced Binary Tree

Image of the balanced Binary Tree