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 31

UP police programmer Grade 2 2013• Part 1: Information Technology

The XOR operator is NOT 

  1. AOption (a)

    Commutative 

  2. BOption (b)

    Associative 

  3. COption (c)

    Distributive over AND 

  4. DOption (d)

    None of the above

View answer & explanation

Correct answer

Answer: (d)D.

None of the above

Why this answer is correct

The correct answer is Option 4: None of the above

Key Points

  • Commutative Property: ✅ XOR is commutative, which means A XOR B is the same as B XOR A. For example, 1 XOR 0 = 0 XOR 1 = 1.
  • Associative Property: ✅ XOR is associative, which means (A XOR B) XOR C is the same as A XOR (B XOR C). For example, (1 XOR 0) XOR 1 = 1 XOR (0 XOR 1) = 0.
  • Distributive Property over AND: ✅ XOR is distributive over AND. For example, A XOR (B AND C) = (A XOR B) AND (A XOR C).

Additional Information

  • XOR Operator: The XOR (exclusive OR) operator returns true if the number of true inputs is odd, and false otherwise.
  • Truth Table:
ABA XOR B
000
011
101
110
  • Why the Answer is None of the Above: All the properties listed in the options (commutative, associative, distributive over AND) are valid for the XOR operator. Hence, the correct answer is Option 4: None of the above.

Hence, the correct answer is: Option 4: None of the above

Question 32

UP police programmer Grade 2 2013• Part 1: Information Technology

The SQL Data Definition Language (DDL) provides commands for

  1. AOption (a)

    Defining relation schemas

  2. BOption (b)

    Deleting relations

  3. COption (c)

    ​Modifying relation schemas

  4. DOption (d)

    All of the above

View answer & explanation

Correct answer

Answer: (d)D.

All of the above

Why this answer is correct

The correct answer is Option 4) All of the above

Key Points

  • Defining relation schemas: ✅ The SQL Data Definition Language (DDL) provides commands such as CREATE TABLE to define the schema of a relation (table).
  • Deleting relations: ✅ DDL includes commands like DROP TABLE, which is used to delete relations (tables) from the database.
  • Modifying relation schemas: ✅ DDL allows modifying the schema of a relation using commands such as ALTER TABLE to add, modify, or delete columns in a table.

Additional Information

  • Definition: DDL is a subset of SQL that is responsible for defining and managing database schemas. Common DDL commands include CREATE, DROP, and ALTER.
  • Purpose: The primary purpose of DDL is to define the structure of the database and manage changes to it.

Hence, the correct answer is: Option 4) All of the above

Question 33

UP police programmer Grade 2 2013• Part 1: Information Technology

Time complexity to search an element in linked list and in an ordered linked list in worst case is as follows 

  1. AOption (a)

    O(1) , O(1) 

  2. BOption (b)

    O(n) , O(1)

  3. COption (c)

    O(1) , O(n)

  4. DOption (d)

    O(n) , O(n)

View answer & explanation

Correct answer

Answer: (d)D.

O(n) , O(n)

Why this answer is correct

The correct answer is option 4) O(n) , O(n)

Key Points

  • Linked List (Unordered):
  • To search for an element, we must traverse node by node from the head.
  • In the worst case, the element is at the end or not present.
  • Time complexity: O(n)
  • Ordered Linked List:
  • Even though the list is sorted, we cannot apply binary search as random access is not possible in linked lists.
  • We still need to go node by node until the element is found or passed.
  • Time complexity: O(n)

Additional Information

  • Arrays vs Linked Lists: Arrays allow binary search (O(log n)) on sorted data, but linked lists do not due to lack of direct access.
  • Ordered list benefit: We may stop search early if the current node value exceeds target (slight average-case improvement), but worst-case remains O(n).
  • Best case: Element at head → O(1), but that’s not worst case.

Hence, the correct answer is: option 4) O(n), O(n)

Question 34

UP police programmer Grade 2 2013• Part 1: Information Technology

The output of lexical analyzer is

  1. AOption (a)

    A set of regular expressions

  2. BOption (b)

    Syntax tree

  3. COption (c)

    Set of tokens

  4. DOption (d)

    Strings of character

View answer & explanation

Correct answer

Answer: (c)C.

Set of tokens

Why this answer is correct

The correct answer is Set of tokens

Key Points

  • Lexical Analyzer: The lexical analyzer is the first phase of a compiler. Its primary job is to read the source code and convert it into a sequence of tokens.
  • Token: A token represents the smallest unit of a program, such as keywords, identifiers, literals, operators, and punctuations.
  • Output: The output of the lexical analyzer is a set of tokens that are passed to the next phase, the syntax analyzer, for further processing.

Additional Information

  • Regular Expressions: Regular expressions are used to define the patterns for tokens but are not the output of the lexical analyzer.
  • Syntax Tree: The syntax tree is generated in the syntax analysis phase, not the lexical analysis phase.
  • Strings of Characters: The lexical analyzer processes strings of characters, but the output is not raw strings; it converts them into meaningful tokens.

Hence, the correct answer is: option 3) Set of tokens

Question 35

UP police programmer Grade 2 2013• Part 1: Information Technology

If (123)5 = (A3)B then the number of possible values A can take is

  1. AOption (a)

    4

  2. BOption (b)

    1

  3. COption (c)

    3

  4. DOption (d)

    2

View answer & explanation

Correct answer

Answer: (c)C.

3

Why this answer is correct

The correct answer is option 3) 3

Key Points

  • Given: (123)5 = (A3)B
  • Step 1: Convert (123)5 to decimal:

(123)5 = 1×5² + 2×5¹ + 3×5⁰ = 25 + 10 + 3 = 38

  • Step 2: Now, (A3)B = 38 in decimal

→ A×B + 3 = 38 ⇒ A×B = 35

  • Step 3: Find integer pairs (A, B) such that A×B = 35
  • (1, 35)
  • (5, 7)
  • (7, 5)

But we must check valid digits and base:

  • In base B, digit A must be < B

Let’s validate:

  • (A=1, B=35) → 1<35 ✅
  • (A=5, B=7) → 5<7 ✅
  • (A=7, B=5) → 7<5 ❌ Invalid
  • Valid A values: A = 1, 5 (from 2 valid pairs)
  • But: A can also be 35, B=1 ⇒ not valid since base ≥ 2 and digits < base
  • So, A can take values: 1, 5, 35 → but only if A < B and B ≥ 6
  • Only valid combinations → A = 1, 5, 35 with B = 35, 7, 1 respectively
  • But in base 1, no number system defined ⇒ remove (35, 1)

So valid values A can take are: 1, 5, 7 → Total = 3

Additional Information

  • When converting between number systems, always convert to decimal first to simplify comparison.
  • Digits used in any base must be less than the base.
  • B must always be ≥ A+1

Hence, the correct answer is: option 3) 3

Question 36

UP police programmer Grade 2 2013• Part 1: Information Technology

Which one of the following is not a mode of vi editor in Unix ? 

  1. AOption (a)

    Command mode

  2. BOption (b)

    Insert mode

  3. COption (c)

    Delete mode

  4. DOption (d)

    Ex modes

View answer & explanation

Correct answer

Answer: (c)C.

Delete mode

Why this answer is correct

The correct answer is Delete mode

Key Points

  • Command mode: ✅ This is one of the primary modes in the vi editor. It is used to navigate and perform operations such as saving, searching, and exiting.
  • Insert mode: ✅ This mode allows you to edit and insert text into the file. You can enter this mode by pressing i, a, or other related keys.
  • Delete mode: ❌ There is no specific "Delete mode" in the vi editor. Deletion of text is performed while in command mode using commands like dd (delete a line) or x (delete a character).
  • Ex mode: ✅ This is a mode in the vi editor where you can enter extended commands by typing a colon (:) in command mode. For example, :wq saves and exits the editor.

Additional Information

  • The vi editor operates in three main modes:
  • Command mode: Used for navigation and performing editor actions.
  • Insert mode: Used for text input.
  • Ex mode: Used for extended commands like saving, quitting, or searching.
  • There is no separate "Delete mode" in the vi editor. Deletion of text is performed using commands within the command mode.

Hence, the correct answer is: Option 3) Delete mode

Question 37

UP police programmer Grade 2 2013• Part 1: Information Technology

Shift reduce parsers are

  1. AOption (a)

    Top down parser

  2. BOption (b)

    Bottom up parser

  3. COption (c)

    May be top down or bottom up parser 

  4. DOption (d)

    None of the above

View answer & explanation

Correct answer

Answer: (b)B.

Bottom up parser

Why this answer is correct

The correct answer is Bottom up parser

Key Points

  • Shift-Reduce Parser: ✅ A shift-reduce parser is a type of Bottom-Up Parser, which attempts to construct the parse tree for an input string by starting from the leaves (tokens) and working up to the root (start symbol).
  • Top-Down Parsers: ❌ These parsers start from the root and attempt to derive the input string by expanding non-terminals. Examples include recursive descent parsers and LL parsers, which are not applicable here.
  • May be top-down or bottom-up: ❌ A parser cannot be both top-down and bottom-up simultaneously. The shift-reduce parser specifically belongs to the bottom-up category.
  • None of the above: ❌ This option is incorrect as shift-reduce parsers clearly belong to the bottom-up parsing family.

Additional Information

  • Shift Operation: During the shift operation, the parser shifts the next input symbol onto the stack.
  • Reduce Operation: During the reduce operation, the parser replaces a sequence of stack symbols (matching the right-hand side of a production rule) with the corresponding non-terminal on the left-hand side.
  • LR Parsers: Many shift-reduce parsers are implemented as LR parsers (e.g., SLR, LALR, and CLR), which are powerful and handle a wide variety of grammars.

Hence, the correct answer is: option 2) Bottom up parser

Question 38

UP police programmer Grade 2 2013• Part 1: Information Technology

Which of the following is the most powerful parser ?

  1. AOption (a)

    SLR 

  2. BOption (b)

    LALR 

  3. COption (c)

    Canonical LR

  4. DOption (d)

    Operator precedence

View answer & explanation

Correct answer

Answer: (c)C.

Canonical LR

Why this answer is correct

The correct answer is Canonical LR

Key Points

  • SLR Parser: ✅ Simple LR (SLR) parser is the simplest type of LR parser and works with a smaller set of items. It is less powerful as it cannot handle all grammars that are LR(1).
  • LALR Parser: ✅ Look-Ahead LR (LALR) parser is more powerful than SLR and is widely used in practice due to its efficiency. However, it is still less powerful than Canonical LR.
  • Canonical LR Parser: ✅ The Canonical LR parser is the most powerful among LR parsers. It uses the full set of LR(1) items and can handle a larger class of grammars compared to SLR and LALR.
  • Operator Precedence: ❌ Operator precedence parsers are specialized parsers for handling operator grammars. They are not as general or powerful as LR parsers.

Additional Information

  • SLR: Uses fewer states and is less computationally expensive but cannot handle all LR(1) grammars.
  • LALR: Combines states with similar look-ahead sets to reduce the number of states, making it more space-efficient.
  • Canonical LR: Uses the full LR(1) item set, making it the most powerful but computationally expensive due to the larger number of states.

Hence, the correct answer is: option 3) Canonical LR

Question 39

UP police programmer Grade 2 2013• Part 1: Information Technology

If you apply quick sort on the following array :

1 7 9 11 35 67 99 102

It will be the

  1. AOption (a)

    Best case of quick sort

  2. BOption (b)

    Worst case of quick sort

  3. COption (c)

    Average case of quick sort

  4. DOption (d)

    None of the above

View answer & explanation

Correct answer

Answer: (b)B.

Worst case of quick sort

Why this answer is correct

The correct answer is option 2) Worst case of quick sort

Key Points

  • Quick Sort: A divide-and-conquer algorithm that picks a "pivot" and partitions the array into elements less than and greater than the pivot.
  • Time Complexity:
  • Best case: O(n log n) → Pivot divides array into two equal halves.
  • Worst case: O(n²) → Pivot is always the smallest or largest element, creating unbalanced partitions.
  • Given array: 1 7 9 11 35 67 99 102 → already sorted in ascending order.
  • In standard Quick Sort (pivot as first or last element):
  • The pivot will always create one empty sub-array and one with (n-1) elements.
  • This leads to a recursion depth of n → worst-case performance.

Additional Information

  • This issue can be avoided using randomized Quick Sort or choosing the median as pivot.
  • In exams, if pivot choice isn’t mentioned, assume standard pivot (first/last), which makes sorted arrays the worst case.
  • Important Note: Sorted or reverse sorted arrays are common examples of Quick Sort's worst-case input if pivot is not well chosen.

Hence, the correct answer is: option 2) Worst case of quick sort

Question 40

UP police programmer Grade 2 2013• Part 1: Information Technology

The following algorithm requires all the edges to be ordered before making the minimum spanning tree

  1. AOption (a)

    Dijkstra algorithm

  2. BOption (b)

    Kruskal algorithm

  3. COption (c)

    Prim algorithm

  4. DOption (d)

     None of the above

View answer & explanation

Correct answer

Answer: (b)B.

Kruskal algorithm

Why this answer is correct

The correct answer is Kruskal Algorithm

Key Points

  • Kruskal Algorithm: ✅ Kruskal's algorithm is a greedy algorithm for finding the Minimum Spanning Tree (MST) of a graph. It requires all the edges to be sorted in non-decreasing order of their weights before starting the process of building the MST.
  • Dijkstra Algorithm: ❌ Dijkstra's algorithm is used for finding the shortest path from a single source to all vertices in a graph. It does not require sorting edges beforehand.
  • Prim Algorithm: ❌ Prim's algorithm builds the MST by starting from any vertex and does not require sorting edges before execution.
  • None of the above: ❌ This option is incorrect because Kruskal’s algorithm indeed requires sorting edges.

Additional Information

  • Edge Sorting: Kruskal's algorithm starts by sorting all edges based on their weights in non-decreasing order. It then adds edges one by one to the MST, ensuring no cycles are formed.
  • Greedy Approach: Kruskal's algorithm is a classic example of the greedy approach in computer science, as it chooses the smallest edge at every step.
  • Time Complexity: Sorting the edges takes O(E log E), where E is the number of edges. The total time complexity depends on the graph representation and union-find operations.

Hence, the correct answer is: option 2) Kruskal Algorithm