Self Studies

Computer Science Test - 2

Result Self Studies

Computer Science Test - 2
  • 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

    If transaction T1 reads a change made by transaction T2, then T1 commits only after T2 commits. This property of a transaction schedule is known as:

    Solution

    The correct answer is option 3.

    Concept:

    Schedules in which transactions commit only after all transactions whose changes they read commit are called recoverable schedules. In other words, if some transaction T2 is reading value updated or written by some other transaction T1, then the commit of T1 must occur after the commit of T2.

    Example:

    R1(x), W1(x), R2(x), R1(y), R2(y), W2(x), W1(y), C1, C2;

    T1 T2

    R(X)

    W(X)

     

    R(Y)

     

    W(Y)

    Commit

     

     

    R(X)

     

    W(X)

     

     

    Commit

    Hence the correct answer is recoverable.

    Additional Information

    Strict Schedule:

    A schedule is strict if for any two transactions T1, T2, if a write operation of T1 precedes a conflicting operation of T2 (either read or write), then the commit or abort event of T1 also precedes that conflicting operation of T2.

    In other words, T2 can read or write updated or written values of T1 only after T1 commits/aborts.

    Example:

    T1 T2

    R(X)

     

    W(X)

    Commit

     

     

     

     

    R(X)

     

     

    W(X)

    R(X)

    Commit

    Cascadeless Schedule:

    Schedules in which transactions read values only after all transactions whose changes they are going to read commit are called cascadeless schedules. Avoids that a single transaction abort leads to a series of transaction rollbacks.

    Example:

    T1 T2

    R(X)

    W(X)

     

    Commit

     

     

     

    W(X)

     

    R(X)

    Commit

    Serializable schedule:

    The Serializable schedule is a type of schedule where one transaction is executed completely before starting another transaction.Example: R1(X), W1(X) Commit1, W2(X) ,R2(X), Commit2.

    T1 T2

    R(X)

    W(X)

    Commit 

     

     

     

     

    W(X)

    R(X)

     Commit

    Database Schedules Relationship:

  • Question 2
    2 / -0.66

    Given the following binary number in 32-bit (single precision) IEEE-754 format:

    11000100010101100000000000000000

    The decimal value closest to this floating-point number is

    Solution

  • Question 3
    2 / -0.66

    What shall be the 2’s complement represented of -24 in a 16 bit computer?

    Solution

    Option 1:

    Since 1111 1111 1110 1011 is in 2’ complement number system it can be written as 101011

    Decimal of this binary -32 x 1 + 16 x 0 + 8 x 1 + 4 x 0 + 2 x 1 + 1 x 1 = -32 + 8 + 2 + 1 = -21

    Option 2:

    Since 1111 1111 1110 1001 is in 2’ complement number system it can be written as 10 1001

    Decimal value of above binary: -32 x 1+ 16 x 0 + 8 x 1 + 4 x 0 + 2 x 0 + 1 x 1 = -32 + 8 + 1 = -23

    Option 3:

    Since 1111 1111 1110 0111 is in 2’ complement number system it can be written as 10 0111

    Decimal value of above binary: -32 x 1 + 16 x 0 + 8 x 0 + 4 x 1 + 2 x 1 + 1 x 1 = -32 + 4 + 2 + 1 = -25

    Option 4:

    Since 1111 1111 1110 1000 is in 2’ complement number system it can be written as 101000

    Decimal value of above binary: -32 x 1 + 16 x 0 + 8 x 1 + 0 + 0 + 0 = -32 + 8 = -24

    Therefore option 4 is the correct answer.

  • Question 4
    2 / -0.66

    Consider two relations P and Q. Let M is a primary key of relation Q and N is the foreign key of relation P. N refers to M. Let A be a set of all values of column M and B be a set of all non-NULL values of column N. Which of the following statement is correct ? (Suppose A and B holds in all instances of P and Q)

    Solution

    Let two relations –

    A be a set of all values of column M = {1, 2, 3, 4}

    B be a set of all non-NULL values of column N = {1, 3}

    Or in another example column N can have the same values as column M.

    So A = B

    By taking both the cases –

    B is a subset of A

    B ⊆ A

  • Question 5
    2 / -0.66

    Solution


    Here X denotes it may present or not and pn denotes If (x,y) present then (y,x) is present or not or both not present.

    (x,x)= present  or not = 2 choices.

    (x,y) (y,x) = possible choices are both are present , (x,y) is present and (y,x) is not present, or (y,x) is present and (x,y) is not present = 3 choices.

  • Question 6
    2 / -0.66

    Consider the following recursive C function that takes two arguments

    unsigned int rer (unsigned int n, unsigned int r) {

    if (n > 0) return (n%r + rer (n/r, r));

    else return 0;

    }

    What is the return value of the function rer when it is called as rer (513, 2)?

    Solution

    Concept –

    rer(513, 2) = 1 + rer(256, 2)

    rer(256, 2) = 0 + rer(128, 2)

    rer(128, 2) = 0 + rer(64, 2)

    rer(64, 2) = 0 + rer(32, 2)

    rer(32, 2) = 0 + rer(16, 2)

    rer(16, 2) = 0 + rer(8, 2)

    rer(8, 2) = 0 + rer(4, 2)

    rer(4, 2) = 0 + rer(2, 2)

    rer(2, 2) = 0 + rer(1, 2)

    rer(1, 2) = 1 + rer(0, 2)

    rer(0, 2) = 0

    Now, adding the values in bottom up function after returning from rer(0, 2), we get,

    rer(1, 2) = 1 + 0 = 1

    rer(2, 2) = 0 + 1 = 1

    rer(4, 2) = 0 + 1 = 1

    rer(8, 2) = 0 + 1 = 1

    rer(16, 2) = 0 + 1 = 1

    rer(32, 2) = 0 + 1 = 1

    rer(64, 2) = 0 + 1 = 1

    rer(128, 2) = 0 + 1 = 1

    rer(256, 2) = 0 + 1 = 1

    rer(513, 2) = 1 + 1 = 2

    Hence, the function returns 2 i.e., sum of bits when 513 represented in binary.

  • Question 7
    2 / -0.66

    Consider 10 KBPS IO device interfaced to 32–bit CPU in cycle stealing mode of DMA. Whenever 16 word data is available in the buffer, it is transferred to main memory. Machine cycle time is 100 micro seconds . How much % of CPU time is consumed in this operation?

    Solution

    Concept:

    In cycle stealing mode of DMA, the DMA controller steals the CPU cycles to transfer data between the IO device and the main memory, so the CPU is free to perform other tasks during the data transfer.

    Explanation:

    Data Preparation Time (X):

  • Question 8
    2 / -0.66

    Consider the following statements:

    S1 : ∀x P(x) ∨ ∀xQ(x) and ∀x(P(x) ∨ Q(x)) are not logically equivalent.

    S2 : ∃x P(x) ∧ ∃x Q(x) and ∃x (P(x) ∧ Q(x)) are not logically equivalent

    Which of the following statements is/are correct?

    Solution

    S1: ∀x P(x) ∨ ∀xQ(x) and ∀x(P(x) ∨ Q(x)) are not logically equivalent.

    This statement is correct. Consider an example: x – is a number. P(x) denotes x is even and Q(x) denotes x is odd. 

    ∀x P(x) ∨ ∀xQ(x)- it means for all numbers x is even or for all numbers x is odd.

    ∀x(P(x) ∨ Q(x)) – it means for all x, x is either odd or even.

    From this, it is clear that both these are not logically equivalent.

    S2: ∃x P(x) ∧ ∃x Q(x) and ∃x (P(x) ∧ Q(x)) are not logically equivalent

    This statement is correct.  Consider the same example as of first case.

    ∃x P(x) ∧ ∃x Q(x) – It means there exists a number which is odd and there exists a number which is even also which is true.

    ∃x (P(x) ∧ Q(x))- It means, there exists a number which is both even and odd which is not possible. It is false.

    So, these are not logically equivalent.

  • Question 9
    2 / -0.66

    Directions For Questions

    Consider a pipelined processor operating at 2 GHZ with 5 stages, Instruction fetch (IF), Instruction decode (ID), Execute (EX), Memory access (MEM), and write back (WB). Each stage of the pipeline, except the EX stage, takes one cycle. The EX takes one cycle for ADD and SUB, three cycles for MUL, two cycles for DIV Instruction.

    ...view full instructions

    Consider the following instructions:

    l1 : ADD R1, R2, R3 ;           R1 ← R2 + R3

    l2 : SUB R3, R2, R1 ;          R3 ← R2 - R1

    I3 : MUL R4, R1, R2 ;           R4 ← R5 * R2

    l4 : DIV R3, R4, R3 ;                      R3 ← R4 / R3 

    Find, the number of true data dependences in the above code and the execution time using operand forwarding technique respectively is______.

    Solution


  • Question 10
    2 / -0.66

    Consider the following 6 concurrent processes where the semaphore is initialized to zero.
    A: down(s); cs; up (s);
    B: down(s); cs; up (s);
    C: down (s); cs; up(s);
    D: up(s); cs; down(s);
    E: up(s); cs; down(s);
    F: up(s); cs;down(s);

    What is the maximum value of s?

    Solution

    The correct answer is 3.

    Key Points:

    • Semaphores: Semaphores are integer variables that are utilized to address the critical section problem by utilizing two atomic actions for process synchronization, wait and signal.
    • Wait: If the parameter S is positive, the wait action decrements its value. If S is negative or zero, no operation is carried out.
    • Signal: The signal operation increments the value of its argument S.

    Explanation:

    The given data:

    A: down(s); cs; up (s);
    B: down(s); cs; up (s);
    C: down (s); cs; up(s);
    D: up(s); cs; down(s);
    E: up(s); cs; down(s);
    F: up(s); cs; down(s);

    Processes D, E, and F can do signal (Up) operation without any intermediate down operation and thus S can go up to value 3.

    Hence the correct answer is 3.

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