Basic CS-Data Structures [TCS Placement]: Sample Questions 27 - 28 of 28

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 27

Data Structures
Edit

Describe in Detail

Essay▾

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

Explanation

  • A linked list is known as heterogeneous when nodes of linked list can contain different type of information.
  • A void pointer can point to any type of data either in-built data type or user defined structure.
  • We can do this by creating an array or linked list of elements that encode both the data and the type of data.
  • We could use a struct that includes a type indicator and a union of the various types that we want to handle, and the create an array or linked list of that struct:

typedef struct {int type_indi; union {float f; int i; double d; void ⚹ p; char c;} } item;

item array [10] ;

  • For a linked list instead of an array, we would also need to add a item ⚹ next pointer.

Question 28

Data Structures
Edit

Write in Short

Short Answer▾

Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes?

Explanation

  • No.
  • The Minimal spanning tree assures that the total weight of the tree is kept at its minimum.
  • But it does not guarantee minimum distance between any two nodes involved in the minimum-spanning tree.

Developed by: