TCS Papers: Sample Questions 356 - 357 of 502

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

Question number: 356

» Languages » C & C Plus Plus

MCQ▾

Question

Which of the following is correct about function overloading?

Choices

Choice (4) Response

a.

The types of arguments are different.

b.

The order of argument is different.

c.

The number of argument is same

d.

Both a. and b. are correct

Answer

d.

Explanation

  • Overloaded functions have same name but accessed function depends on the number and type of arguments so, answer is option A & B.

  • C++ allows specification of more than one function of the same name in the same scope. These are called overloaded functions.

  • Overloaded functions enable different functional executions at run-time, depending on the types and number of arguments.

Function overloading

Function Overloading

Given the image is define the function overloading

Question number: 357

» Basic CS » Data Structures

Essay Question▾

Describe in Detail

What are the methods available in storing sequential files?

Explanation

  • The methods available in storing sequential files are:

  • Straight merging

    • Perhaps the most straightforward sorting technique is the straight merge.

    • Distributes the initial records onto two tapes, a and b, so that they contain the same number of records, or so that one tape contains only one more record than the other.

    • Straight merge sorts elements by recursion by merging first lists of size 1 into list of size 2, then lists of size 2 into lists of size 4, etc.

Straight merging

Straight Merging

Given the image is define the how straight mergeshort works

  • Polyphase sort

  • The main difficulty in implementing a polyphase merge is to determine how to distribute the initial runs.

  • It is not difficult to see how to build the table above by working backwards:

  • Take the largest number in each column, make it zero, and add it to each of the other numbers to get the previous column

  • This corresponds to defining the highest-order merge for the previous column which could give the present column.

  • This technique works for any number of tapes (at least three)

    The numbers which arise are “generalized Fibonacci numbers” which have many interesting properties.

Polyphase merge

Polyphase Merge

Given the image is define the polyphase merge

  • Natural merging

  • Sorts a constant number of input merge files to one merged output file.

  • A distribution phase redistributes the merge runs to the input file for remerging

  • All merge runs are written to the same file

Natural merge sort

Natural Merge Sort

Given the image is define the natural merge sort

Distribution of initial runs

  • A process of distributing ordered run lists of predetermined size on to the tapes and continuously merging these runlists in multiple phases is the polyphase merge.

  • The initial distribution of runlists on the working of tapes affects the performance of sorting.

  • It is found that the Fibonacci distribution of initial runlists produces better performance

Initial merge in image

Initial Merge in Image

Given the image is define the distribution of initial merge