Search Previous Year Questions

Find real questions from previous competitive exam papers with answers and solutions.

Leave the keyword blank to browse saved questions for your selected exam, newest papers first. Add a keyword, year or topic to narrow the results.

Browse complete papers
Showing 10 question(s)
Clear

Question 91

HPCL Engineer 2017• Professional Knowledge

The prefix equivalent of the following infix expression is:

a/b – c + d * e – a * c

  1. AOption (a)
        • / a b c * d e * a c
  2. BOption (b)
        • / a b c * d e * a c
  3. COption (c)
        • / a b c * d e * a c
  4. DOption (d)
      • / a b c - * d e * a c 
View answer & explanation

Correct answer

Answer: (a)A.
      • / a b c * d e * a c

Why this answer is correct

Algorithm for conversion from prefix to infix:

STEP 1:

Start scanning the expression from RHS. Push the operators on the top of the stack by ensuring that only high priority operator can be pushed over a low priority operator.

STEP 2:

If a low priority operator is encountered in expression and if top of stack is high priority operator, then pop it and after that push low priority operator on the top of stack.

STEP 3:

Print each operand.

Given expression is : a/b – c + d * e – a * c

⇒ /ab-c+de-ac

⇒ -/abc+de-ac 

⇒ +-/abcde-ac

⇒ +-/abcde-ac

⇒ +-/abc*de-*ac

⇒ -+-/abcdeac

Question 92

HPCL Engineer 2017• Professional Knowledge

Match the following.

List-1List -2
(I) (X’)’(A) De Morgan law
(II) (X + Y)’=X’.Y’(B) Involution
(III) X(X+Y) = X(C) Distributive
(IV) X + YZ = (X +Y) (X+Z)(D) Absorption
  1. AOption (a)

    I – D, II – A, III – B, IV - C

  2. BOption (b)

    I – B, II – A, III –D, IV - C

  3. COption (c)

    I – B, II – D, III – A, IV - C

  4. DOption (d)

    I – C, II – A, III – D, IV - B

View answer & explanation

Correct answer

Answer: (b)B.

I – B, II – A, III –D, IV - C

Why this answer is correct

(X’)’ = X → involution law.

X + Y)’=X’.Y’ → De Morgan Law

X(X+Y) = X + XY = X → Absorption law

X + YZ = (X +Y) (X+Z) → Distributive law

Question 93

HPCL Engineer 2017• Professional Knowledge

Which of the following attributes can be considered as composite, single-valued and key attribute?

  1. AOption (a)

    Age

  2. BOption (b)

    Date of birth

  3. COption (c)

    Enrolment number 

  4. DOption (d)

    Gender 

View answer & explanation

Correct answer

Answer: (c)C.

Enrolment number 

Why this answer is correct

Simple attribute:

These are atomic values which cannot be divided further.

Composite attribute:

These are made up of more than one simple attribute.

Single valued:

These attributes contain only single value.

Key – attribute:

Attribute that uniquely identifies an entity among entity set. Here, enrolment number can be considered as composite, single- valued and key attribute.

Question 94

HPCL Engineer 2017• Professional Knowledge

Which of the following is the every-case time complexity of dynamic programming algorithm for ‘Traversing salesperson’ problem to traverse ‘n’ cities?

  1. AOption (a)

    Θ(n2 22)

  2. BOption (b)

    Θ(2n)

  3. COption (c)

    Θ(log n2n)

  4. DOption (d)

    Θ(n2n)

View answer & explanation

Correct answer

Answer: (d)D.

Θ(n2n)

Why this answer is correct

Travelling salesman problem is to find the shortest possible route that visits every city exactly once and returns to the starting point.

To calculate the cost of TSP using dynamic programming algorithm, there are some recursive relation in terms of sub problems.

Recurrence relation for this problem:

C(S,j)=minC(S−{j},i)+d(i,j)where i∈S and i≠j

C(S,j)=minC(s−{j},i)+d(i,j) where i∈ S and i≠j

In case of dynamic programming approach, there are at most 2n.n subproblems and each problem takes linear time to solve.

So, overall time complexity for this is O(2n.n2).

But we have to find the every case time complexity which will be: O(2n.n)

Question 95

HPCL Engineer 2017• Professional Knowledge

Maximum number of edges in a simple graph with ‘n’ vertices and ‘k’ components is:

  1. AOption (a)

    n2

  2. BOption (b)

    \(\frac{{\left( {n - k} \right)\left( {n - k + 1} \right)}}{2}\)

  3. COption (c)

    \(\frac{{\left( n \right)\left( {n - 1} \right)}}{2}\)

  4. DOption (d)

    \(\frac{{\left( {n - 2} \right)\left( {n - 1} \right)}}{2} + 1\)

View answer & explanation

Correct answer

Answer: (b)B.

\(\frac{{\left( {n - k} \right)\left( {n - k + 1} \right)}}{2}\)

Why this answer is correct

Let G be a graph with k components. Let ni  be the number of vertices in the ith component., where 1<=i<=k, then the number of edges in the graph is equal to the sum of the edges in each of its components. Thus, G has the maximum number of edges if each component is a complete graph.

Hence, the maximum possible number of edges in the graph is \(\mathop \sum \limits_{i = 1}^k \frac{{{n_i}\left( {{n_i} - 1} \right)}}{2}\)

After expanding, the maximum number of edges: \(\frac{{\left( {n - k} \right)\left( {n - k + 1} \right)}}{2}\)

Example:

n = 6 and k = 3

maximum number of edges = 6

Using Formula:

\(\frac{{\left( {n - k} \right)\left( {n - k + 1} \right)}}{2} = \frac{(6 -3)(6-3+1)}{2}= 6\)

Question 96

HPCL Engineer 2017• Professional Knowledge

Consider a memory unit of size 96 K × 16, where first component represents the number of words and that the second component represents the number of bits per word. What will be the number of address lines and input-output data lines?

  1. AOption (a)

    16 address lines, 17 data lines

  2. BOption (b)

    7 address lines, 16 data lines

  3. COption (c)

    17 address lines, 16 data lines

  4. DOption (d)

    16 address lines, 7 data lines

View answer & explanation

Correct answer

Answer: (c)C.

17 address lines, 16 data lines

Why this answer is correct

Concept:

Address line: An address line is basically refers to a physical connection between a CPU/Chipset and memory. They specify which addresses to access in memory. When there are k address lines, then 2k memory word can be accessed.

Data line: Data lines provides the information to be stored in memory. It represents the number of bits in the word.

Calculation:

Here, it is given that memory unit size = 96 K × 16

Where, 96 K represents the number of words.

16 represents the number of bits per word.

As, 96 > 128 so, we have to take 128 i.e. 27.

Number of words = 96 K = 27 × 210 = 2 17

It means address line to access those words are 17.

Number of input – output data lines = number of bits in a word = 16

Question 97

HPCL Engineer 2017• Professional Knowledge

If T is a binary tree with N nodes, then the numbers of levels is at least;

  1. AOption (a)

    ⌈log2 (N + 1)⌉

  2. BOption (b)

    N

  3. COption (c)

    N - 1

  4. DOption (d)

    ⌊log2 (N + 1)⌋

View answer & explanation

Correct answer

Answer: (a)A.

⌈log2 (N + 1)⌉

Why this answer is correct

Let us consider a full binary tree with 3 levels:

Here, at level 0 we have only 1 node.

At level 1, maximum 2 nodes are possible.

At level 2, maximum 4 nodes are possible.

i.e. for every level k, there are no more than 2k nodes possible.

Also, total nodes in the tree are 7. With 3 levels, maximum 7 nodes are possible.

i.e. with h levels maximum 2h-1 nodes are possible.

Here, we have given n nodes, and we have to find the number of levels.

Number of levels is at least \(\left\lceil {{{\log }_2}\left( {N; + ;1} \right)} \right\rceil \)

Question 98

HPCL Engineer 2017• Professional Knowledge

Match the following.

List-1List-2
I) Class - A IP addressA) 8 bit host id and 24 bit network id
II) Class - B IP addressB) 16 bit host id and 16 bit network id
III) Class - C IP addressC) 24 bit host id and 8 bit network id
  1. AOption (a)

    I – B, II – C, III – A

  2. BOption (b)

    I – C, II – B, III – A

  3. COption (c)

    I – A, II – B, III – C

  4. DOption (d)

    I – C, II – A, III – B

View answer & explanation

Correct answer

Answer: (b)B.

I – C, II – B, III – A

Why this answer is correct

IP address is an address having information about how to reach a specific host. The 32 bit IP address is divided into five sub classes. These are:

  1. Class A

  2. Class B

  3. Class C

  4. Class D

  5. Class E

Class D and E are reserved for multicast and experimental purposes.

IPv4 addresses are divided into two parts: a) Network ID b) Host ID

Question 99

HPCL Engineer 2017• Professional Knowledge

Total number of spanning tree of a complete graph of 4 vertices K4 is:

  1. AOption (a)

    15

  2. BOption (b)

    3

  3. COption (c)

    16

  4. DOption (d)

    17

View answer & explanation

Correct answer

Answer: (c)C.

16

Why this answer is correct

Concept:

A spanning tree is a subset of Graph G, which has all the vertices covered with minimum possible number of edges. Spanning tree doesn’t have cycles and it cannot be disconnected.

Formula:

Number of spanning trees possible with n nodes = nn-2

Calculation:

Here, number of vertices are 4.

So, number of spanning trees possible = 44-2 = 42 = 16

Question 100

HPCL Engineer 2017• Professional Knowledge

If every production is of the form α → β where |α| ≤ |β| or of the form α → λ, then the grammar is said to be of:

  1. AOption (a)

    Type 1

  2. BOption (b)

    Type 3

  3. COption (c)

    Type 0

  4. DOption (d)

    Type 2

View answer & explanation

Correct answer

Answer: (a)A.

Type 1

Why this answer is correct

Type 3 grammar: These generate regular languages. These languages are accepted by a finite state automaton. Type 3 is the most restricted form of grammar.

Type 2 grammars: These grammars generate the context-free languages. These are accepted by pushdown automata. In type 2, the Left-hand side of the production must have only one variable. Grammar production is in the form of α → β where |α| = 1 for type 2 grammar. No restriction on β.

Type 1 grammar: This type of grammar generates context-sensitive language. These languages are accepted by linear bounded automata. Grammar production is in the form of α → β where |α| ≤ |β| or α → λ

Type 0 grammar: These are Turing recognizable language. These languages are also called recursively enumerable languages.

Production is of the form of α → β where α is (V + T)+  and β is (V + T)*, V is variable and T is terminal.