THE GATEBOOK Q&A - Recent questions and answers
http://thegatebook.in/qa/qa
Powered by Question2AnswerDecidability Question
http://thegatebook.in/qa/2332/decidability-question
L ={M |M is a TM and |L(M)| <= 3}<br />
<br />
L is:<br />
<br />
A) Recursive B) Recursively Enumerable C) Not Recursively Enumerable D) Context SensitiveTOChttp://thegatebook.in/qa/2332/decidability-questionThu, 27 Jul 2017 14:44:11 +0000Answered: Question of Sizeof()
http://thegatebook.in/qa/2234/question-of-sizeof?show=2330#a2330
<p>The <em>sizeof</em> operator computes the required memory storage space of its operand. The operand is written following the keyword <em>sizeof</em> and may be the symbol of a storage space, e.g., a variable, type name, or an expression. If it is a type name, it must be enclosed in parentheses. The result of the operation is the size of the operand in bytes, or the size of the memory representation.</p>
<p>For expressions it evaluates to the representation size for the type that would result from evaluation of the expression, which is not performed.</p>
<p>Since the result of the expression is int (why int? see below) so the size of int, which might be 4 bytes in the machine, is printed.</p>
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=4658185562696499950" style="height:171px; width:600px"></p>
<h1><em>From dennis ritchie c book</em></h1>
<p> </p>Data Structures Algorithms and C Programminghttp://thegatebook.in/qa/2234/question-of-sizeof?show=2330#a2330Thu, 27 Jul 2017 12:26:55 +0000Answered: Bellman ford algorithm example in cormen
http://thegatebook.in/qa/2315/bellman-ford-algorithm-example-in-cormen?show=2316#a2316
<p>from t → x cycle weight = 5+(-2) = 3(>0).</p>
<p>so there is no negative weight cycle between t and x.</p>
<p>2nd part</p>
<p>If there is any negative weight cycle in graph then it must be detected because in simple graph G(V,E) shortest path(not equal -<img alt="\infty" src="http://latex.codecogs.com/gif.latex?%5Cinfty">) between any vertex can't have more than V-1 edges.In Bellman ford Algorithm V-1 times edges are releaxed.Then one more time relaxation is done ,if we get any shorter path in this iteration then there is negative weight cycle in the graph.</p>
<p> </p>Data Structures Algorithms and C Programminghttp://thegatebook.in/qa/2315/bellman-ford-algorithm-example-in-cormen?show=2316#a2316Thu, 27 Jul 2017 03:19:06 +0000Answered: String Constants
http://thegatebook.in/qa/2311/string-constants?show=2314#a2314
<p>Q1) What is Difference between NULL and NUL ('\0') ? </p>
<table>
<tbody>
<tr>
<td>
<p><strong>Note:</strong> This answer applies to the C language, not C++.</p>
<hr>
<h2>Null Pointers</h2>
<p>The integer constant literal <code>0</code> has different meanings depending upon the context in which it's used. In all cases, it is still an integer constant with the value <code>0</code>, it is just described in different ways.</p>
<p>If a pointer is being compared to the constant literal <code>0</code>, then this is a check to see if the pointer is a null pointer. This <code>0</code> is then referred to as a null pointer constant. The C standard defines that <code>0</code>cast to the type <code>void *</code> is both a null pointer and a null pointer constant.</p>
<p>Additionally, to help readability, the macro <code>NULL</code> is provided in the header file <code>stddef.h</code>. Depending upon your compiler it might be possible to <code>#undef NULL</code> and redefine it to something wacky.</p>
<p>Therefore, here are some valid ways to check for a null pointer:</p>
<pre>
<code>if (pointer == NULL)</code></pre>
<p><code>NULL</code> is defined to compare equal to a null pointer. It is implementation defined what the actual definition of <code>NULL</code> is, as long as it is a valid null pointer constant.</p>
<pre>
<code>if (pointer == 0)</code></pre>
<p><code>0</code> is another representation of the null pointer constant.</p>
<pre>
<code>if (!pointer)</code></pre>
<p>This <code>if</code> statement implicitly checks "is not 0", so we reverse that to mean "is 0".</p>
<p>The following are INVALID ways to check for a null pointer:</p>
<pre>
<code>int mynull = 0;
<some code>
if (pointer == mynull)</code></pre>
<p>To the compiler this is not a check for a null pointer, but an equality check on two variables. This <em>might</em> work if mynull never changes in the code and the compiler optimizations constant fold the 0 into the if statement, but this is not guaranteed and the compiler has to produce at least one diagnostic message (warning or error) according to the C Standard.</p>
<p>Note that what is a null pointer in the C language. It does not matter on the underlying architecture. If the underlying architecture has a null pointer value defined as address 0xDEADBEEF, then it is up to the compiler to sort this mess out.</p>
<p>As such, even on this funny architecture, the following ways are still valid ways to check for a null pointer:</p>
<pre>
<code>if (!pointer)
if (pointer == NULL)
if (pointer == 0)</code></pre>
<p>The following are INVALID ways to check for a null pointer:</p>
<pre>
<code>#define MYNULL (void *) 0xDEADBEEF
if (pointer == MYNULL)
if (pointer == 0xDEADBEEF)</code></pre>
<p>as these are seen by a compiler as normal comparisons.</p>
<h2>Null Characters</h2>
<p><code>'\0'</code> is defined to be a null character - that is a character with all bits set to zero. This has nothing to do with pointers. However you may see something similar to this code:</p>
<pre>
<code>if (!*string_pointer)</code></pre>
<p>checks if the string pointer is pointing at a null character</p>
<pre>
<code>if (*string_pointer)</code></pre>
<p>checks if the string pointer is pointing at a non-null character</p>
<p>Don't get these confused with null pointers. Just because the bit representation is the same, and this allows for some convenient cross over cases, they are not really the same thing.</p>
<p>Additionally, <code>'\0'</code> is (like all character literals) an integer constant, in this case with the value zero. So <code>'\0'</code> is completely equivalent to an unadorned <code>0</code> integer constant - the only difference is in the <em>intent</em> that it conveys to a human reader ("I'm using this as a null character.").</p>
<h2>References</h2>
<p>See <a rel="nofollow" href="http://c-faq.com/null/ptrtest.html">Question 5.3 of the comp.lang.c FAQ</a> for more. See <a rel="nofollow" href="http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf">this pdf</a> for the C standard. Check out sections 6.3.2.3 Pointers, paragraph 3.</p>
</td>
</tr>
</tbody>
</table>
<p> <strong>credits:</strong> <a rel="nofollow" href="https://stackoverflow.com/questions/1296843/what-is-the-difference-between-null-0-and-0">https://stackoverflow.com/questions/1296843/what-is-the-difference-between-null-0-and-0</a></p>
<p>Q2)</p>
<p>One of the luminaries of computer science -- Edsger Dijkstra -- actually wrote a note in 1982 advocating for zero-based indexing called <em>Why numbering should start at zero</em>.<br>
<br>
The full text can be found here: <a rel="nofollow" href="https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html" target="_blank">Why numbering should start at zero (EWD 831)</a><br>
<br>
To summarize his argument:<br>
</p>
<ol>
<li>When working with sub-sequences of natural numbers, the difference between the upper bound and the lower bound should be the length of the sub-sequence. The indices of an array can be thought of as a special kind of such a sub-sequence.</li>
<li>The lower bound should be inclusive, the upper bound should be exclusive. In other words, the lower bound should be the first index of the array. Otherwise, we risk having to have a lower bound in the unnatural numbers for some sub-sequences.</li>
<li>If we want to maintain conditions (1) and (2), then we effectively have two choices for upper and lower bounds: 1 <= i < N+1 or 0 <= i < N. Clearly, putting N+1 in the range is ugly, so we should prefer indexing starting from 0. </li>
</ol>
<p><strong>Credits: <a rel="nofollow" href="https://www.quora.com/Why-do-array-indexes-start-with-0-zero-in-many-programming-languages">https://www.quora.com/Why-do-array-indexes-start-with-0-zero-in-many-programming-languages</a></strong></p>
<p> </p>Data Structures Algorithms and C Programminghttp://thegatebook.in/qa/2311/string-constants?show=2314#a2314Wed, 26 Jul 2017 04:42:31 +0000Answered: who ever have not written the combinatorics test please don't read the question as it will make your exams less serious
http://thegatebook.in/qa/2310/written-combinatorics-please-question-will-exams-serious?show=2312#a2312
First divide the problem into two case :<br />
<br />
1) four digits not containing zero <br />
<br />
2) four digits containing zero. <br />
<br />
case 1: let take four distinct digit x1,x2,x3,x4 and x1<x2<x3<x4 . now how many combination possible ?<br />
<br />
1) x1x3x2x4 2) x1x4x2x3 3) x2x3x1x4 4)x2x4x1x3 5 )x3x4x1x2 total 5 . now there are 5*9C4= 630 snake like structure are there which donot contain zero.<br />
<br />
case 2 : four digit containing zero. let see how many combination possible ?<br />
<br />
1) x3x40x2 2) x2x40x3 3) x2x30x4 .. so total 3 combinations. snakelike structure = 3*5C3= 252 which not contain zero.<br />
<br />
<br />
<br />
so total = 630+252=882 snake like structuresDiscrete Mathshttp://thegatebook.in/qa/2310/written-combinatorics-please-question-will-exams-serious?show=2312#a2312Tue, 25 Jul 2017 17:15:12 +0000Answered: The number of ways in which this can be done
http://thegatebook.in/qa/2268/the-number-of-ways-in-which-this-can-be-done?show=2308#a2308
your question is similar to given question(click on link)<br />
<br />
<a href="http://thegatebook.in/qa/1945/confusion-in-combination" rel="nofollow">http://thegatebook.in/qa/1945/confusion-in-combination</a>Discrete Mathshttp://thegatebook.in/qa/2268/the-number-of-ways-in-which-this-can-be-done?show=2308#a2308Tue, 25 Jul 2017 11:36:18 +0000Answered: connected components
http://thegatebook.in/qa/2223/connected-components?show=2305#a2305
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=2768314202468850448" style="height:315px; width:600px"></p>
<p>Since there are 2 conditions and or is there between them, at least one condition is satisfied then it is sufficient to draw the edge.</p>
<p>So that's why we draw edges systematically like this.</p>
<p>1. Draw an edge when |i-j| = 8</p>
<p>But still some edges are possible because of the condition |i-j| = 12</p>
<p>we will draw such edges later</p>
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=8146021551527970612" style="height:315px; width:600px"></p>
<p>So far we can see 8 connected components. But still there is another condition which is |i-j| = 12 </p>
<p>If we add edges which satisfy |i-j| = 12 then there would be more edges which will further reduce the no of components. </p>
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=16117575150039287822"></p>
<p> </p>
<p>Because of this condition at least one new edge is added between 2 different components so the components will be reduced further.</p>
<p>In the options we have only one option which is < 8 so 4 could be the answer. ( If you want to quickly answer the question)</p>
<p> </p>
<p> </p>Data Structures Algorithms and C Programminghttp://thegatebook.in/qa/2223/connected-components?show=2305#a2305Tue, 25 Jul 2017 04:26:39 +0000Answered: doubt in c programming
http://thegatebook.in/qa/2294/doubt-in-c-programming?show=2304#a2304
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=5428206169098118919" style="height:142px; width:600px"></p>
<p>The last line says that Right shifting a signed quanitity is machine dependent. </p>Data Structures Algorithms and C Programminghttp://thegatebook.in/qa/2294/doubt-in-c-programming?show=2304#a2304Tue, 25 Jul 2017 04:06:40 +0000Answered: What is equivalence classes?Like Type1 Type2 Type 3
http://thegatebook.in/qa/2299/what-is-equivalence-classes-like-type1-type2-type-3?show=2303#a2303
I don't think it is popular enough to be asked in GATE with out defining it.Discrete Mathshttp://thegatebook.in/qa/2299/what-is-equivalence-classes-like-type1-type2-type-3?show=2303#a2303Tue, 25 Jul 2017 03:36:54 +0000Answered: Relation-Gate 1998
http://thegatebook.in/qa/2300/relation-gate-1998?show=2302#a2302
Why it is not transitive ?Discrete Mathshttp://thegatebook.in/qa/2300/relation-gate-1998?show=2302#a2302Tue, 25 Jul 2017 03:35:11 +0000Answered: can a page fault occur after a tlb hit?
http://thegatebook.in/qa/1532/can-a-page-fault-occur-after-a-tlb-hit?show=2291#a2291
no it won't because page fault happens when a page is searched in page table. while TLB hit gives direct frame number.Operating Systemshttp://thegatebook.in/qa/1532/can-a-page-fault-occur-after-a-tlb-hit?show=2291#a2291Mon, 24 Jul 2017 15:58:24 +0000Answered: gatebook test series question
http://thegatebook.in/qa/2277/gatebook-test-series-question?show=2283#a2283
There is a path called zero length path. From a vertex to same vertex always we will have zero length path. <br />
<br />
Hence it is reflexive.Discrete Mathshttp://thegatebook.in/qa/2277/gatebook-test-series-question?show=2283#a2283Mon, 24 Jul 2017 05:46:44 +0000Answered: i cant see all progate tests, i can only see one test. ie: test on logic
http://thegatebook.in/qa/2274/cant-see-all-progate-tests-can-only-see-one-test-test-on-logic?show=2281#a2281
go bottom of the page you will get combinatorics test and rest are on next page.Discrete Mathshttp://thegatebook.in/qa/2274/cant-see-all-progate-tests-can-only-see-one-test-test-on-logic?show=2281#a2281Mon, 24 Jul 2017 04:50:35 +0000Answered: Propositional Logic gate 1995
http://thegatebook.in/qa/2278/propositional-logic-gate-1995?show=2280#a2280
~p->q means p+q<br />
<br />
So P can be true or false nothing can be said about P<br />
~pV(p-->q) is ~pV(~pVq) => ~pVq<br />
<br />
hence it can also be true/False as we don't say anything about "P". Hence value can not be determined<br />
<br />
<br />
<br />
D)Discrete Mathshttp://thegatebook.in/qa/2278/propositional-logic-gate-1995?show=2280#a2280Mon, 24 Jul 2017 04:49:20 +0000Answered: Propositional logic
http://thegatebook.in/qa/2276/propositional-logic?show=2279#a2279
"All triangle are polygon" can be represnted as "&forall;(T(x)&rarr;P(x))<br />
<br />
<br />
<br />
Negation of "All triangle are polygon" ~(&forall;(T(x)&rarr;P(x)))<br />
<br />
"&exist;(~(T(x)&rarr;P(x)))" Pimpliesq is &not;p &or; q therefore T(x) &and; ~P(x)<br />
<br />
&exist;(T(x)&and; &not;P(x))<br />
<br />
<br />
<br />
"Some triangles are not polygon"Discrete Mathshttp://thegatebook.in/qa/2276/propositional-logic?show=2279#a2279Mon, 24 Jul 2017 04:46:40 +0000Answered: Propositional logic
http://thegatebook.in/qa/2271/propositional-logic?show=2273#a2273
yes you are correct.Discrete Mathshttp://thegatebook.in/qa/2271/propositional-logic?show=2273#a2273Sun, 23 Jul 2017 13:01:45 +0000Answered: gatebook test series
http://thegatebook.in/qa/2270/gatebook-test-series?show=2272#a2272
We should count licence plates which do not contain zeros but contains O's<br />
<br />
We should also count licence plates which do not contain O's but contains zerosDiscrete Mathshttp://thegatebook.in/qa/2270/gatebook-test-series?show=2272#a2272Sun, 23 Jul 2017 12:59:07 +0000Answered: gatebook test series question
http://thegatebook.in/qa/2262/gatebook-test-series-question?show=2267#a2267
it is 9C4. I have corrected the option DDiscrete Mathshttp://thegatebook.in/qa/2262/gatebook-test-series-question?show=2267#a2267Sun, 23 Jul 2017 07:53:49 +0000Answered: english sentence into proposition logic
http://thegatebook.in/qa/2204/english-sentence-into-proposition-logic?show=2264#a2264
<p>Different forms for implication is</p>
<ul>
<li>If p then q</li>
<li>q if p</li>
<li>q whenever p</li>
<li>q when p</li>
<li>q follows from p</li>
<li>p is sufficient for q</li>
<li>a sufficient condition for q is p</li>
<li>q is necessary for p</li>
<li>a necessary condition for p is q</li>
<li>p only if q</li>
<li> p → q (p implies q)</li>
<li>p is sufficient for q</li>
<li>a sufficient condition for q is p</li>
<li>q is necessary for p</li>
<li>a necessary condition for p is q</li>
</ul>
<h3> For hiking on the trail to be safe,<strong> it is necessary</strong> but <strong>not</strong> <strong>sufficient</strong> that berries not be ripe along the trail and for grizzly bears not to have been seen in the area.</h3>
<p><strong>In the statement it is given that B is necessary for A and B is not sufficient for A </strong></p>
<p>Where B = berries not be ripe along the trail and for grizzly bears not to have been seen in the area.</p>
<p>A = hiking on the trail to be safe</p>
<p>B<strong> = <img alt="\sim r\wedge \sim p" src="http://latex.codecogs.com/gif.latex?%5Csim%20r%5Cwedge%20%5Csim%20p"> </strong></p>
<p>A = <img alt="q" src="http://latex.codecogs.com/gif.latex?q"></p>
<p>B is sufficient for A can be written as <img alt="B\rightarrow A" src="http://latex.codecogs.com/gif.latex?B%5Crightarrow%20A"></p>
<p>B is not sufficient for A can be written as <strong>It is false that B is sufficient for A</strong></p>
<p><strong><img alt="\sim (B \rightarrow A)" src="http://latex.codecogs.com/gif.latex?%5Csim%20%28B%20%5Crightarrow%20A%29"></strong></p>
<p>B is necessary for A can be written as <img alt="A\rightarrow B" src="http://latex.codecogs.com/gif.latex?A%5Crightarrow%20B"> </p>
<p>Now we will write complete formula</p>
<p><strong>B is necessary for A and B is not sufficient for A </strong></p>
<p><img alt="(A\rightarrow B)\wedge" src="http://latex.codecogs.com/gif.latex?%28A%5Crightarrow%20B%29%5Cwedge"><strong><img alt="\sim (B \rightarrow A)" src="http://latex.codecogs.com/gif.latex?%5Csim%20%28B%20%5Crightarrow%20A%29"></strong></p>
<p><strong><img alt="(q\rightarrow (\sim r\wedge \sim p)) \wedge ((\sim r\wedge \sim p)\rightarrow q )" src="http://latex.codecogs.com/gif.latex?%28q%5Crightarrow%20%28%5Csim%20r%5Cwedge%20%5Csim%20p%29%29%20%5Cwedge%20%28%28%5Csim%20r%5Cwedge%20%5Csim%20p%29%5Crightarrow%20q%20%29"></strong></p>Discrete Mathshttp://thegatebook.in/qa/2204/english-sentence-into-proposition-logic?show=2264#a2264Sun, 23 Jul 2017 04:55:05 +0000Answered: GATEBOOK (Set & Function test) ( Please dont see question right now if you dont attend this test yet)
http://thegatebook.in/qa/2219/gatebook-function-please-dont-question-right-attend-this-test?show=2263#a2263
Natural numbers can be defined in two ways<br />
<br />
N = {0,1,2,....}<br />
<br />
N = {1,2,3,4...}<br />
<br />
If we assume the first one then f is bijection and if we assume the second definition then f is one to one but not ontoDiscrete Mathshttp://thegatebook.in/qa/2219/gatebook-function-please-dont-question-right-attend-this-test?show=2263#a2263Sun, 23 Jul 2017 03:58:05 +0000Answered: Question on datatypes
http://thegatebook.in/qa/2250/question-on-datatypes?show=2261#a2261
See, You have already written that "int func(){ .... } so, "int" is the return type of the function, so whatever you write like "return (double)(char)5.0;" an integer value will be returned by the function, so answer is option B.Data Structures Algorithms and C Programminghttp://thegatebook.in/qa/2250/question-on-datatypes?show=2261#a2261Sat, 22 Jul 2017 16:50:14 +0000Answered: middle elemt of a Link List
http://thegatebook.in/qa/2232/middle-elemt-of-a-link-list?show=2256#a2256
<p><strong>This can be solved in 2 ways</strong><br>
<br>
<strong> <br>
<br>
Way 1</strong><br>
<br>
Use "Count" function. travers the linked list, thus it will cont number of node till last node. and then we will do ceil(count/2) it will return middle element .<br>
<br>
This will take O(n) time.<br>
<br>
<br>
<br>
<br>
<br>
<strong>Way2</strong><br>
<br>
Take 2 friends let's say Akash and Arun<br>
<br>
increment Akash by 1<br>
<br>
Increment Arun by 2<br>
<br>
When Arun will reach at end of list automatically Akash will be at middle and then return Akash.<br>
<br>
example..<br>
<br>
Let list is 1 2 3 4 5 6 7 8 9 10<br>
<br>
Akash round: 1,2,3,4,5<br>
<br>
Arun round: 2,4,6,8,10<br>
<br>
Automatically akash is at middle (5).</p>
<p>It will also take O(n) as we are traversing linked list but take space more for two pointer. </p>Data Structures Algorithms and C Programminghttp://thegatebook.in/qa/2232/middle-elemt-of-a-link-list?show=2256#a2256Sat, 22 Jul 2017 08:32:56 +0000Answered: Sir, Please have a look at this ?
http://thegatebook.in/qa/2222/sir-please-have-a-look-at-this?show=2255#a2255
After seeing the tape symbol because of the code tape head is either moved LEFT or RIGHT. This is called one step. <br />
<br />
What is infinite loop is running for infinite steps ( no of steps is no more a natural number)<br />
<br />
Assumption: To take one step your turing machine takes finite time. ( 1000 years is even finite time)<br />
<br />
Now run such TM for exactly 100 steps ( Simulate this TM code with another TM U, Universal TM.)<br />
<br />
Then it halts then you will know otherwise also you will very well know.TOChttp://thegatebook.in/qa/2222/sir-please-have-a-look-at-this?show=2255#a2255Sat, 22 Jul 2017 07:36:09 +0000Answered: GATEBOOK (Set & Function test) ( Please dont see question right now if you dont attend this test yet)
http://thegatebook.in/qa/2218/gatebook-function-please-dont-question-right-attend-this-test?show=2231#a2231
8 is correct answer. Why is this incorrect answer?Discrete Mathshttp://thegatebook.in/qa/2218/gatebook-function-please-dont-question-right-attend-this-test?show=2231#a2231Fri, 21 Jul 2017 16:11:27 +0000Answered: GATEBOOK (Set & Function test) ( Please dont see question right now if you dont attend this test yet)
http://thegatebook.in/qa/2220/gatebook-function-please-dont-question-right-attend-this-test?show=2226#a2226
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=14175478157516867826" style="height:382px; width:600px"></p>
<p>why ?</p>
<p><img alt="\propto -1" src="http://latex.codecogs.com/gif.latex?%5Cpropto%20-1"> can be still <img alt="\propto" src="http://latex.codecogs.com/gif.latex?%5Cpropto"></p>
<p>Example </p>
<p> </p>
<p> <img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=10176574487531155547" style="height:523px; width:600px"></p>
<p>Answer is D</p>Discrete Mathshttp://thegatebook.in/qa/2220/gatebook-function-please-dont-question-right-attend-this-test?show=2226#a2226Fri, 21 Jul 2017 12:37:52 +0000Answered: propostional logic
http://thegatebook.in/qa/2205/propostional-logic?show=2221#a2221
<h2>Your answer is (¬s→r)→¬q.</h2>
<p>When s is true (¬s→r)→¬q is (F→r)→¬q = T→ ¬q = ¬q</p>
<p>That means according to your representation </p>
<p>when S is true then ¬q </p>
<p>When You are older than 16 years old is true then you can ride the roller caster car </p>
<p>But that is not the meaning of given english statement</p>Discrete Mathshttp://thegatebook.in/qa/2205/propostional-logic?show=2221#a2221Fri, 21 Jul 2017 05:21:57 +0000Answered: regarding PROGATE test questions
http://thegatebook.in/qa/2203/regarding-progate-test-questions?show=2216#a2216
you can ask that questions here. Please tag them properly.<br />
<br />
Example. Discrete, test 2, Combinatorics<br />
<br />
In the title aslo you mention that.<br />
<br />
who ever have not written the test please don't read the question as it will make your exams less seriousDiscrete Mathshttp://thegatebook.in/qa/2203/regarding-progate-test-questions?show=2216#a2216Thu, 20 Jul 2017 12:32:16 +0000Answered: difficult problem
http://thegatebook.in/qa/2202/difficult-problem?show=2213#a2213
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=16943357035503961215" style="height:393px; width:600px"></p>
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=9159002075526746703" style="height:436px; width:600px"></p>
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=16196377212215540550" style="height:450px; width:600px"></p>
<p>why is there one statement which is to be true ?</p>
<p>if every statement is fasle then the 5th statement which says " exactly 5 statements are false" would become true. which is ofcourse not possible as already we have proved it. </p>
<p>So only possibility we have that all statements except 4th statement is false.</p>
<p>Same reasoning can be applied to 100 statements too.</p>
<p>Try to answer 2nd and 3rd part</p>
<p> </p>Discrete Mathshttp://thegatebook.in/qa/2202/difficult-problem?show=2213#a2213Thu, 20 Jul 2017 05:24:06 +0000Answered: set theory question
http://thegatebook.in/qa/2209/set-theory-question?show=2210#a2210
<p><img alt="A\cup B\cup C" src="http://latex.codecogs.com/gif.latex?A%5Ccup%20B%5Ccup%20C"> = 21 (given)</p>
<p>A = 9,B = 10 ,C = 7 and <img alt="A \cap B \cap C" src="http://latex.codecogs.com/gif.latex?A%20%5Ccap%20B%20%5Ccap%20C"> = 5 (given)</p>
<p>Now,</p>
<p><img alt="A\cup B\cup C = A+B+C-A\cap B-A\cap C-B\cap C+A \cap B \cap C" src="http://latex.codecogs.com/gif.latex?A%5Ccup%20B%5Ccup%20C%20%3D%20A&plus;B&plus;C-A%5Ccap%20B-A%5Ccap%20C-B%5Ccap%20C&plus;A%20%5Ccap%20B%20%5Ccap%20C"></p>
<h3 style="font-style: italic;"> (using inclusion exclusion principle)</h3>
<p><img alt="A\cap B+A\cap C+B\cap C = A+B+C+A \cap B \cap C-A\cup B\cup C" src="http://latex.codecogs.com/gif.latex?A%5Ccap%20B&plus;A%5Ccap%20C&plus;B%5Ccap%20C%20%3D%20A&plus;B&plus;C&plus;A%20%5Ccap%20B%20%5Ccap%20C-A%5Ccup%20B%5Ccup%20C"></p>
<h3 style="font-style: italic;"> = 9 + 10 + 7 + 5- 21 = 10.</h3>
<p>persons eat at least two out of the three dishes = </p>
<p> <img alt="(A\cap B+A\cap C+B\cap C )" src="http://latex.codecogs.com/gif.latex?%28A%5Ccap%20B&plus;A%5Ccap%20C&plus;B%5Ccap%20C%20%29"> (eat two out of the three dishes) </p>
<p> +<img alt="(A\cap B\cap C)" src="http://latex.codecogs.com/gif.latex?%28A%5Ccap%20B%5Ccap%20C%29"> (eat all three dishes)</p>
<h3 style="font-style: italic;"> = 10(calculated above) + 5 (given ) = 15 .</h3>Discrete Mathshttp://thegatebook.in/qa/2209/set-theory-question?show=2210#a2210Thu, 20 Jul 2017 01:05:16 +0000Answered: Are such questions in syllabus?
http://thegatebook.in/qa/2069/are-such-questions-in-syllabus?show=2198#a2198
It is related to micro processor. I don't think such questions will be asked now.Computer Organizationhttp://thegatebook.in/qa/2069/are-such-questions-in-syllabus?show=2198#a2198Wed, 19 Jul 2017 06:12:36 +0000Answered: partial order
http://thegatebook.in/qa/2171/partial-order?show=2196#a2196
<p>we already know that x R y iff x divides y is partial order relation. </p>
<p>every finite subset of N has least upper bound and greatest lower bound.</p>
<p>example: finite subset is {2,4,5} then least upper bound is LCM(2,4,5) and reatest lower bound is GCD(2,4,5)</p>
<p>we can prove it for any finite subset S. LCM(S) and GCD(S)</p>
<p>That's why it is lattice.</p>
<p>A poset is called a <strong>complete lattice</strong> if <em>all</em> its subsets have LUB and GLB</p>
<p>when it comes to infinite subsets condition would fail.</p>
<p>Example: {2,4,6,8,10............} </p>
<p>There is no LUB </p>
<p>Option e is the correct answer. </p>Discrete Mathshttp://thegatebook.in/qa/2171/partial-order?show=2196#a2196Wed, 19 Jul 2017 05:28:15 +0000Answered: general doubt
http://thegatebook.in/qa/2178/general-doubt?show=2195#a2195
Here in the question they have mentioned that partitions are unordered. If nothing is mentioned then we should get the details from the question. <br />
<br />
Example: objects are flowers of same type (Like all are roses or all are sunflowers) then we can assume them similar.<br />
<br />
If objects are books or people then we can treat them as different.Discrete Mathshttp://thegatebook.in/qa/2178/general-doubt?show=2195#a2195Wed, 19 Jul 2017 05:02:20 +0000Answered: Find Regular expression for the complement of the languange
http://thegatebook.in/qa/2188/find-regular-expression-for-the-complement-of-the-languange?show=2194#a2194
<p>Even no of zeroes followed by odd number of ones</p>
<p><img alt="(aa)^{*}b(bb)^{*}" src="http://latex.codecogs.com/gif.latex?%28aa%29%5E%7B*%7Db%28bb%29%5E%7B*%7D"></p>
<p><strong>Step1: </strong>Construct NFA then covert it to DFA D or Construct DFA D directly</p>
<p><strong>Step2: </strong>Construct commplement of D, <img alt="\bar{}" src="http://latex.codecogs.com/gif.latex?%5Cbar%7B%7D"><img alt="\bar{D}" src="http://latex.codecogs.com/gif.latex?%5Cbar%7BD%7D"></p>
<p><strong>Step 3: Construct r.e from </strong><img alt="\bar{D}" src="http://latex.codecogs.com/gif.latex?%5Cbar%7BD%7D"></p>TOChttp://thegatebook.in/qa/2188/find-regular-expression-for-the-complement-of-the-languange?show=2194#a2194Wed, 19 Jul 2017 04:58:18 +0000Answered: Sir, how to solve such questions ?
http://thegatebook.in/qa/2190/sir-how-to-solve-such-questions?show=2192#a2192
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=11873428811010123913"></p>
<p>similarly you can check other options.</p>Discrete Mathshttp://thegatebook.in/qa/2190/sir-how-to-solve-such-questions?show=2192#a2192Wed, 19 Jul 2017 04:25:44 +0000Answered: A queue is implemented using singly linked list
http://thegatebook.in/qa/2186/a-queue-is-implemented-using-singly-linked-list?show=2191#a2191
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=4279805030054115527" style="height:519px; width:600px"></p>
<p>Some students think that not linking front and rear in either way also can make insertion and Deletion happen in O(1) time. you are correct. But still that fact wouldn't deny that statment (I) is false. </p>
<p> </p>Data Structures Algorithms and C Programminghttp://thegatebook.in/qa/2186/a-queue-is-implemented-using-singly-linked-list?show=2191#a2191Wed, 19 Jul 2017 04:16:52 +0000Answered: partial order
http://thegatebook.in/qa/2172/partial-order?show=2189#a2189
<p>what is total order ?</p>
<p>A total order (or "totally ordered set," or "linearly ordered set") is a <a rel="nofollow" href="http://mathworld.wolfram.com/Set.html">set</a> plus a relation on the set (called a <a rel="nofollow" href="http://mathworld.wolfram.com/TotalOrder.html">total order</a>) that satisfies the conditions for a <a rel="nofollow" href="http://mathworld.wolfram.com/PartialOrder.html">partial order</a> plus an additional condition known as the comparability condition. A <a rel="nofollow" href="http://mathworld.wolfram.com/Relation.html">relation</a> <img alt="<=" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline1.gif" style="height:14px; width:9px"> is a total order on a <a rel="nofollow" href="http://mathworld.wolfram.com/Set.html">set</a> <img alt="S" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline2.gif" style="height:14px; width:7px"> ("<img alt="<=" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline3.gif" style="height:14px; width:9px"> totally orders <img alt="S" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline4.gif" style="height:14px; width:7px">") if the following properties hold.</p>
<p>1. Reflexivity: <img alt="a<=a" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline5.gif" style="height:14px; width:29px"> for all <img alt="a in S" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline6.gif" style="height:14px; width:29px">.</p>
<p>2. Antisymmetry: <img alt="a<=b" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline7.gif" style="height:14px; width:29px"> and <img alt="b<=a" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline8.gif" style="height:14px; width:29px"> implies <img alt="a=b" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline9.gif" style="height:14px; width:31px">.</p>
<p>3. Transitivity: <img alt="a<=b" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline10.gif" style="height:14px; width:29px"> and <img alt="b<=c" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline11.gif" style="height:14px; width:28px"> implies <img alt="a<=c" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline12.gif" style="height:14px; width:28px">.</p>
<p>4. Comparability (<a rel="nofollow" href="http://mathworld.wolfram.com/TrichotomyLaw.html">trichotomy law</a>): For any <img alt="a,b in S" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline13.gif" style="height:14px; width:44px">, either <img alt="a<=b" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline14.gif" style="height:14px; width:29px"> or <img alt="b<=a" src="http://mathworld.wolfram.com/images/equations/TotallyOrderedSet/Inline15.gif" style="height:14px; width:29px">.</p>
<p><a rel="nofollow" href="http://mathworld.wolfram.com/TotallyOrderedSet.html">** From mathworld **</a></p>
<p>take 2 sequences <strong>s1:</strong>1,2 and<strong> s2:</strong>3,4 </p>
<p>neither s1 is related to s2 nor s2 is related to s1</p>
<p> </p>Discrete Mathshttp://thegatebook.in/qa/2172/partial-order?show=2189#a2189Tue, 18 Jul 2017 14:23:54 +0000Answered: how to identify duplicate might occur??
http://thegatebook.in/qa/2180/how-to-identify-duplicate-might-occur?show=2183#a2183
One more way to solve this is just select positions of 1's in string of 10 rest will be 0's(it will make all combination of three 1's and seven 0's).<br />
<br />
<br />
<br />
Similarly C(10,3)+C(10,3)+C(10,4)+C(10,5)+C(10,6)+C(10,7) // remember there one more condition of atleast three 0's so max. we can choose seven 1's.Discrete Mathshttp://thegatebook.in/qa/2180/how-to-identify-duplicate-might-occur?show=2183#a2183Mon, 17 Jul 2017 13:42:23 +0000Answered: A queue is implemented using two stacks.
http://thegatebook.in/qa/2181/a-queue-is-implemented-using-two-stacks?show=2182#a2182
for each insertion 1 push<br />
<br />
for each deletion 2 pop + 1 push<br />
<br />
so ,total operation = 3 push(for insertion)+3*2[1pop then 1 push](for ordering the element so that FIFO element is deleted)+2 pop(for deletion) = 11Data Structures Algorithms and C Programminghttp://thegatebook.in/qa/2181/a-queue-is-implemented-using-two-stacks?show=2182#a2182Mon, 17 Jul 2017 13:35:48 +0000Answered: Errata for Discrete-Logic-Test1: Don't click this if you have not written the test
http://thegatebook.in/qa/2079/errata-discrete-logic-test1-dont-click-this-have-written-test?show=2177#a2177
Sir, what is this exactly? I searched about what is errata but not able understand this post.Discrete Mathshttp://thegatebook.in/qa/2079/errata-discrete-logic-test1-dont-click-this-have-written-test?show=2177#a2177Mon, 17 Jul 2017 03:48:38 +0000Answered: rosen exercise combinatorics problem
http://thegatebook.in/qa/2175/rosen-exercise-combinatorics-problem?show=2176#a2176
Your answer is correct as 90720.Discrete Mathshttp://thegatebook.in/qa/2175/rosen-exercise-combinatorics-problem?show=2176#a2176Mon, 17 Jul 2017 02:18:11 +0000Answered: doubt in COA
http://thegatebook.in/qa/2168/doubt-in-coa?show=2173#a2173
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=413074523095893905" style="height:248px; width:600px"></p>
<p>lemme me know if i m wrong...</p>Computer Organizationhttp://thegatebook.in/qa/2168/doubt-in-coa?show=2173#a2173Sun, 16 Jul 2017 14:45:33 +0000Answered: Is this Proposition is correct for the given statements ?
http://thegatebook.in/qa/2162/is-this-proposition-is-correct-for-the-given-statements?show=2169#a2169
<p>No above proposition is wrong, it should be as given below:</p>
<p><br>
<img alt="G \rightarrow\forall x(W(x)\rightarrow (\sim A(x)\rightarrow \sim L(x)))" src="http://latex.codecogs.com/gif.latex?G%20%5Crightarrow%5Cforall%20x%28W%28x%29%5Crightarrow%20%28%5Csim%20A%28x%29%5Crightarrow%20%5Csim%20L%28x%29%29%29"></p>Discrete Mathshttp://thegatebook.in/qa/2162/is-this-proposition-is-correct-for-the-given-statements?show=2169#a2169Sun, 16 Jul 2017 08:10:07 +0000Answered: What is the output of the following Program??
http://thegatebook.in/qa/2163/what-is-the-output-of-the-following-program?show=2166#a2166
A would be answer.<br />
<br />
#ifdef check if the macro is defined and execute the whatever follow afterwards.<br />
<br />
So, here it will check If THIS was defined (It will not check for THAT, I think multiple check are nor allowed).<br />
<br />
To check for both you could use following code :-<br />
<br />
#include<stdio.h><br />
<br />
#define THIS<br />
#define THAT<br />
int main() { <br />
#ifdef THIS<br />
#ifdef THAT<br />
printf("This & That are present"); <br />
#else <br />
printf("that is not prsent"); <br />
#endif<br />
#else <br />
printf("This is not present") ;<br />
#endif<br />
<br />
<br />
return 0;<br />
}Data Structures Algorithms and C Programminghttp://thegatebook.in/qa/2163/what-is-the-output-of-the-following-program?show=2166#a2166Sun, 16 Jul 2017 05:11:14 +0000Answered: FUNCTION -TIFR
http://thegatebook.in/qa/2158/function-tifr?show=2161#a2161
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=7419852519508708613" style="height:345px; width:600px"></p>
<p>Same problem can be solved with eliminating other options.<img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=3852102517470330259" style="height:483px; width:432px"></p>
<p>with above example we can eliminate option A and C.</p>
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=9145253476957966406" style="height:344px; width:600px"></p>
<p>with above example we can eliminate D and E</p>Discrete Mathshttp://thegatebook.in/qa/2158/function-tifr?show=2161#a2161Sat, 15 Jul 2017 14:36:03 +0000Q. f(x) = x^5 + 1 is a bijection from R to R?
http://thegatebook.in/qa/2152/q-f-x-x-5-1-is-a-bijection-from-r-to-r
Discrete Mathshttp://thegatebook.in/qa/2152/q-f-x-x-5-1-is-a-bijection-from-r-to-rSat, 15 Jul 2017 02:37:01 +0000Test Series Question discussion
http://thegatebook.in/qa/2147/test-series-question-discussion
Hello Sir,<br />
Why Test Series question are not open for discussion ??Discrete Mathshttp://thegatebook.in/qa/2147/test-series-question-discussionFri, 14 Jul 2017 17:49:34 +0000doubt in COA
http://thegatebook.in/qa/2126/doubt-in-coa
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=9512044670902057024" style="height:419px; width:600px"></p>
<p>The answer given for this question is 3 clock-cycles .</p>
<p>S <- R0 ...... 1st cycle , </p>
<p>T <- R1 ...... 2nd cycle , </p>
<p>R0 <- R0 + R1 ..... 3rd cycle</p>
<p>But the diagram which you have taught us, </p>
<p><img alt="" src="http://thegatebook.in/qa/?qa=blob&qa_blobid=6016140422250738213" style="height:364px; width:310px"></p>
<p>According to this,</p>
<p>Read R0 --> 1 CLOCK-CYCLE.</p>
<p>Read R1 --> 1 CLOCK-CYCLE</p>
<p>ADD R1,R2 which is an ALU operation ---> 1 CLOCK-CYCLE</p>
<p>Store the result in REGSITER-FILE ----> 1 CLOCK-CYCLE.</p>
<p>Totally 4 clock-cycles</p>
<p>Which means we do ALU in 1 clock-cycle and we do WRITE-BACK in 1 clock-cycle, But they have given both in 1 clock-cycle ..am not able to understand can you please explain what is the difference between both ...why we are doing this ..</p>Computer Organizationhttp://thegatebook.in/qa/2126/doubt-in-coaFri, 14 Jul 2017 09:00:43 +0000Doubt - Computer Organization
http://thegatebook.in/qa/2124/doubt-computer-organization
<p>What if an interrupt occurs <strong>while </strong>a HALT instruction is being executed, then what address would be stored on the stack?</p>
<p>Is it a special case for HALT instruction or will it be the same for all instructions?</p>
<p>In the context of the question : <a href="http://gateoverflow.in/1058/gate2004-63" rel="nofollow">http://gateoverflow.in/1058/gate2004-63</a></p>Computer Organizationhttp://thegatebook.in/qa/2124/doubt-computer-organizationFri, 14 Jul 2017 07:48:43 +0000Sir, please check this ?
http://thegatebook.in/qa/2123/sir-please-check-this
<p>L2 = { w | w contains some x as a substring and x belongs to L1 }</p>
<ul>
<li>If L1 is regular then L2 is also regular ?</li>
</ul>
<hr>
<p>I know that I can use concatenation property here. So, if L1 is regular then L2 is also regular.</p>
<p>But I am confused in this example, let me take L1 = { e } and L2 = { a^nb^n }. Now, here also, the above property is satisfied,i.e epsilon(x) belongs to L1 and every w of a^nb^n has epsilon as a substring .</p>
<p>Where am I interpreting wrong ? </p>TOChttp://thegatebook.in/qa/2123/sir-please-check-thisFri, 14 Jul 2017 05:03:20 +0000Consider the directed graph shown in the figure below.
http://thegatebook.in/qa/2116/consider-the-directed-graph-shown-in-the-figure-below
<p>Consider the directed graph shown in the figure below. There are multiple shortest paths between vertices S and T. Which one will be reported by Dijstra?s shortest path algorithm? Assume that, in any iteration, the shortest path to a vertex v is updated only when a strictly shorter path to v is discovered.</p>
<p> </p>
<p><img src="http://www.geeksforgeeks.org/wp-content/uploads/gat2012.png" style="height:312px; width:500px" alt="image"></p>
<p>Graph</p>
<p><br>
<strong>(A)</strong> SDT<br>
<strong>(B)</strong> SBDT<br>
<strong>(C)</strong> SACDT<br>
<strong>(D)</strong> SACET</p>Data Structures Algorithms and C Programminghttp://thegatebook.in/qa/2116/consider-the-directed-graph-shown-in-the-figure-belowThu, 13 Jul 2017 07:01:37 +0000