Self Studies

Computer Science Test - 5

Result Self Studies

Computer Science Test - 5
  • Score

    -

    out of -
  • Rank

    -

    out of -
TIME Taken - -
Self Studies

SHARING IS CARING

If our Website helped you a little, then kindly spread our voice using Social Networks. Spread our word to your readers, friends, teachers, students & all those close ones who deserve to know what you know now.

Self Studies Self Studies
Weekly Quiz Competition
  • Question 1
    2 / -0.66

    Consider three processes P1, P2 and P3 with arrival time of 0,1 and 2 time units respectively, and  total execution time of 20, 30 and 40 units respectively. Each process spends the first 30% of execution time doing I/O, then next 60% doing CPU and remaining 10% time doing I/O again. The operating uses a First come first serve scheduling algorithm and schedules a new process either when the running process gets blocked on I/O or when the running process finishes its compute burst. For what percentage of time does the CPU remain idle?

    NOTE:
    Ideal time at the start and at the end is counted.

    Solution

    Table representation of the processes burst time, CPU and I/O time is shown as :

  • Question 2
    2 / -0.66

    Suppose that a code has the following four valid codewords:

    11001100

    00110011

    11111111

    00000000

    What is the maximum number of errors that can be detected for this code?

    Solution

    The correct answer is 3

    To determine the maximum number of errors that can be detected for the given code, we need to find the minimum Hamming distance between any pair of the valid codewords. The Hamming distance between two codewords is the number of positions at which the corresponding bits are different.

    Let's calculate the Hamming distance between each pair of codewords:

    • 11001100 and 00110011: The Hamming distance is 8 (since all bits are different).
    • 11001100 and 11111111: The Hamming distance is 4 (first, second, seventh, and eighth bits differ).
    • 11001100 and 00000000: The Hamming distance is 4 (third, fourth, fifth, and sixth bits differ).
    • 00110011 and 11111111: The Hamming distance is 4 (first, second, seventh, and eighth bits differ).
    • 00110011 and 00000000: The Hamming distance is 4 (third, fourth, fifth, and sixth bits differ).
    • 11111111 and 00000000: The Hamming distance is 8 (since all bits are different).

    The minimum Hamming distance among the codewords is 4.

    To determine the maximum number of errors that can be detected, we can use the property that a code with a minimum Hamming distance (d) can detect up to (d-1) errors.

    Since the minimum Hamming distance (d) is 4, the maximum number of errors that can be detected is: [d - 1 = 4 - 1 = 3]

    Thus, the maximum number of errors that can be detected for this code is: [ 3 ]

  • Question 3
    2 / -0.66

    Solution

  • Question 4
    2 / -0.66

    Consider the below given code

    #include<stdio.h>

    int main()

    {

    int k, i = 1;

    while(i < k)

    i = i * 3;

    }

    The number of times while loop runs is _____.

    Solution

    Take: k = 9

    while(1 < 9 )

    i= 1 * 3 = 3  (1st time)

    while(3 < 9 )

    i= 3 * 3 = 9  (2nd time)

    while(3 < 9 )  // while will not be executed

    For k = 9 while loop runs 2 times

    Take: k = 10

    while(1 < 10 )

    i = 1 * 3 = 3  (1st time)

    while(3 < 10 )

    i = 3 * 3 = 9  (2nd time)

    while(9 < 10 )

    i = 9 * 3 = 27  (3rd time)

    while(27 < 10 )  // while will not be executed

    For k = 10 while loop runs 3 times

    Option 2:

    For k = 9, ⌈log3k⌉ = 2

    For k = 10, ⌈log3k⌉ = 3

     Hence option 2 is correct

    Important Points:

    To verify the answer, execute the code:

    #include<stdio.h>

    int main()

    {

    int c = 0;

    int k=9, i = 1; // also put k = 10 to verify the options

    while(i < k)

    {

    c++;

    i = i * 3;

    }

    printf("%d",c);

    }

  • Question 5
    2 / -0.66

    A system uses 3 physical page frames which are initially empty. What is the absolute difference between the no. of page faults using the Least recently used(LRU) and Most recently used(MRU) page replacement policies while processing the page reference string given below ?

    7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1

    Solution

    LRU:

    In this event of page fault, replace the page which is Least recently used

    7

    0

    1

    2

    0

    3

    0

    4

    2

    3

    0

    3

    2

    1

    2

    0

    1

    7

    0

    1

     

     

    1

    1

    1

    3

    3

    3

    2

    2

    2

    2

    2

    2

    2

    2

    2

    7

    7

    7

     

    0

    0

    0

    0

    0

    0

    0

    0

    3

    3

    3

    3

    3

    3

    0

    0

    0

    0

    0

    7

    7

    7

    2

    2

    2

    2

    4

    4

    4

    0

    0

    0

    1

    1

    1

    1

    1

    1

    1

    M

    M

    M

    M

     

    M

     

    M

    M

    M

    M

     

     

    M

     

    M

     

    M

     

     

    No. of page faults using LRU = 12

    MRU:

    In this event of page fault, replace the page which is Most recently used

    7

    0

    1

    2

    0

    3

    0

    4

    2

    3

    0

    3

    2

    1

    2

    0

    1

    7

    0

    1

     

     

    1

    2

    2

    2

    2

    2

    2

    3

    0

    3

    2

    1

    2

    0

    1

    1

    1

    1

     

    0

    0

    0

    0

    3

    0

    4

    4

    4

    4

    4

    4

    4

    4

    4

    4

    4

    4

    4

    7

    7

    7

    7

    7

    7

    7

    7

    7

    7

    7

    7

    7

    7

    7

    7

    7

    7

    0

    0

    M

    M

    M

    M

     

    M

    M

    M

     

    M

    M

    M

    M

    M

    M

    M

    M

     

    M

     

    No. of page faults using LRU = 16

    Difference between the page faults using LRU and MRU is 16 – 12 = 4

  • Question 6
    2 / -0.66

    If there are m input lines and n output lines for a decoder that is used to uniquely address a byte addressable 4 KB RAM, then the minimum value of m + n is ______.

    Solution

    Concept:

    A decoder with k input lines has 2k output lines.

    Calculation:

    The memory is byte addressable. So 4 KB = 212 B.

    12 × 210 decoder.

    So, the number of input lines (m) = 12

    Number of output lines (n) = 2m = 212 = 4096

    Hence, (m + n) = 12 + 4096 = 4108

  • Question 7
    2 / -0.66

    Consider the following two sets of LR(1) items of an LR(1) grammar.

    Which of the following statements related to merging of the two sets in the corresponding LALR

    parser is/are FALSE?

    1. Cannot be merged since look aheads are different.

    2. Can be merged but will result in S-R conflict.

    3. Can be merged but will result in R-R conflict.

    4. Cannot be merged since goto on c will lead to two different sets.

    Solution

    The correct answer is option 4.

    Key Points

    1. Cannot be merged since lookaheads are different.

    False, We can find the LALR stage by merging LR(1) states that have the same set of the first component. We can take the union of lookahead symbol of the respective item. The given LR (1) items can be merged as, 

    X → c.X, c/d/$

    X → .cX, c/d/$  

    X → .x, c/d/$   

    2. Can be merged but will result in S-R conflict.

    3. Can be merged but will result in R-R conflict.

    The given items have no reduced entry(means dot at end of the production) then there is no S-R conflict and R-R conflict in the given grammar. So clearly it says both option 2 and 3 are false. 

    4. Cannot be merged since goto on c will lead to two different sets. 

    False, Because goto is carried on Non-terminals symbols, not on terminal symbols, and c is a terminal symbol.

    Hence the correct answer is 1, 2, 3 and 4.

    Additional Information

    Checking LALR conflicts:

    Shortcut:

    Let's consider the production A → αaβ and B→α and a,b are lookaheads of the grammar. Then S-R conflicts will occur when one production with reducing production and another one is a shift production. This will make the conflict when shifting terminal and lookahead are same then parsing table has multiple entries. And R-R conflicts have two productions with the same lookaheads.

    • If there is no S-R conflict in LR(1) state it never be reflected in the LALR(1) parser.
    • If there is no R-R conflict in LR(1) state it may be R-R conflict in LALR(1) parser.
    • The parse generates tool 'YAAC' uses LALR(1) parsing algorithm.
  • Question 8
    2 / -0.66

    Let x be the value of a counting semaphore at a particular time of computation. 14 signal operation 23 wait operation is performed on the counting semaphore variable. If resulting value of the semaphore is -3 then the value of x is ________.

    Solution

    Concepts:

    V(S): signal operation will increment the semaphore variable, that is, S++.

    P(S): wait operation will decrement the semaphore variable., that is, S--. 

    Calculation:

    Initial counting semaphore (I) = x

    Signal operation = 14 V

    Wait operation = 23 P

    Final counting semaphore (F) = -3

    F = x + 14V + 23P

    -3 = x + 14(+1) + 23(-1)

    ∴ x = 6

  • Question 9
    2 / -0.66

    The number of substrings that can be formed from string given by “ABCDEFGH.....Z” is

    Solution

    Concepts:

    A substring is a contiguous sequence of characters within a string.

    Example:

    String: “GATE”

    Substring: G, A, T, E, GA, AT, TE, GAT, ATE, GATE and Λ (empty string or null string)

    Therefore, number of substrings = 11

    Formula:

    If character is not repeated, then

  • Question 10
    2 / -0.66

    The POST-order traversal of a binary search tree is given by 117, 126, 108, 131, 157, 182, 163, 148, 195 and 129. Then the PRE-order traversal of this tree is:

    Solution

    POST-order traversal: 117, 126, 108, 131, 157, 182, 163, 148, 195 and 129

    In a binary search tree, in-order traversal is sorted

    In-order traversal: 108, 117, 126, 129, 131, 148, 157, 163, 182 and 195

    Required Binary Search Tree:

    PRE-order traversal: 129, 108, 126, 117, 195, 148, 131, 163, 157, 182

Self Studies
User
Question Analysis
  • Correct -

  • Wrong -

  • Skipped -

My Perfomance
  • Score

    -

    out of -
  • Rank

    -

    out of -
Re-Attempt Weekly Quiz Competition
Self Studies Get latest Exam Updates
& Study Material Alerts!
No, Thanks
Self Studies
Click on Allow to receive notifications
Allow Notification
Self Studies
Self Studies Self Studies
To enable notifications follow this 2 steps:
  • First Click on Secure Icon Self Studies
  • Second click on the toggle icon
Allow Notification
Get latest Exam Updates & FREE Study Material Alerts!
Self Studies ×
Open Now