TCS Papers: Sample Questions 303 - 304 of 502

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

Question number: 303

» Basic CS » Data Structures

Essay Question▾

Describe in Detail

What is data structure?

Explanation

A data structure:

  • Organizes data based on their relationship to each other.

  • Uses knowledge about the relationship between data items for designing efficient algorithms for the manipulation.

  • Provides a scheme for organizing related pieces of information.

  • Provides convenient mechanism for storing, accessing, transferring, and archiving data.

  • Ensures efficient processing for example, in lists, arrays, stacks, queues or trees.

  • Primitive types line Integer, Float, Boolean, Char etc. are called Primitive Data Structures.

  • On the other hand, Complex Data Structures store large and connected data. Such Abstract Data Structure include:

  • Linked List

  • Tree

  • Graph

  • Stack, Queue etc.

Data structure in image

Data Structure in Image

Given the image is define the data structure and types of operations

Question number: 304

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

What is null pointer?

Explanation

  • There are times when its necessary to have a pointer that doesn’t point to anything- Null pointer is this special reserved value of pointer.

  • The macro NULL has a value that’s guaranteed to be different from any valid pointer.

  • NULL is a literal zero, possibly cast to void * or char*.

  • Some people, notably C++ programmers, prefer to use 0 rather than NULL. The null pointer is used in three ways: 1) To stop indirection in a recursive data structure. 2) As an error value. 3) As a sentinel value.

  • Example:

  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int *ptr=NULL;
  5.     printf(“The value of ptr is %u”,ptr);
  6.     return 0;
  7. }

Output:

The value of ptr is 0