Redpine Infotech Papers: Sample Questions 2 - 3 of 19

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

Question number: 2

» Basic CS » Data Structures

Essay Question▾

Describe in Detail

Explain two problems related to in order and post order traversal.

Explanation

Given order travel

Given Order Travel

Given order travel, root, left subtree and right subtree

Inorder Traversal:

  • Algorithm:

    • Traverse the left sub tree, i. e. , call inorder (left-sub tree)

    • Visit the root

    • Traverse the right sub tree, i. e. , call inorder (right-sub tree)

  • Uses of Inorder

    • Binary search trees, inorder traversal provides nodes in non-decreasing order.

    • To get nodes of BST in non-increasing order, a variation of inorder traversal where inorder traversal is reversed can be used.

    Ex:

In order travel (left, root, right)

In Order Travel (Left, Root, Right)

In order travel (left, root, right)

  • In order travel (left, root, right): 4,2, 5,1, 3

Post order:

  • Algorithm:

    • Traverse the left sub tree, i. e. , call Postorder (left-sub tree)

    • Traverse the right sub tree, i. e. , call Postorder (right-sub tree)

    • Visit the root.

  • Use of Postorder:

    • Used to delete the tree.

    • To get the postfix expression of expression tree.

Ex:

Postorder (Left, Right, Root)

Postorder (Left, Right, Root)

Postorder (Left, Right, Root)

Postorder (Left, Right, Root): 4 5 2 3 1

Question number: 3

» Basic CS » Operating System

MCQ▾

Question

What are the different types of IPC mechanisms?

Choices

Choice (4) Response

a.

Synchronous/Asynchronous communication (Naming. ).

b.

Indirect communication (mailbox)

c.

Context switching

d.

Direct communication (messages)

Answer

d.

Explanation

  • IPC mechanisms are a set of programming interfaces that allow a programmer to coordinate activities among different program processes or threads.

  • Threads can run concurrently in an operating system.

  • For example, they allow a program to handle many user requests at the same time each with different thread.

  • Direct communication is an IPC mechanism.

  • Each process that wants to communicate must name the recipient or sender of the communication.

  • Send and receive primitives are defined as bellow:

    • Send (P, message) - send a message to process P.

    • Receive (Q, message) - Receive a message from process Q.