Question 2

(a)  What is an Interface? How is it different from a class?

(b)  A matrix ARR[ – 4…6, 3….8] is stored in the memory with each element requiring

4 bytes of storage. If the base address is 1430, find the address of ARR[3][6] when the matrix is stored in Row Major Wise.

(c) Convert the following infix notation to postfix form:

(A + B * C ) – ( E * F / H ) + J

(d) Compare the two complexities O(n2) and O(2n) and state which is better and why.

(e) State the difference between internal nodes and external nodes of a binary tree structure.

Answer

(a) Interface: An interface is a blueprint of a class having static constants and abstract methods. An interface is a reference type in Java.

A class that contains public static final data types and declaration of abstract method only. Class contains static or non-static data members with methods defined. Interface support multiple inheritance, where as a class does not. Interfaces are implemented by classes whereas sub classes are extended from super class.

(b) Row Major Wise: ARR[i][j] = BA + W [ (i – lr )* col + (j – lc]

Putting the values:

= 1430 + 4[ (3 –(-4)) * 6 + (6-3)]

= 1430 + 4[ 42 + 3]

= 1430 + 180

= 1610

(c) Infix to Postfix: ( A + B * C ) – ( E * F / H ) + J

= ( A + BC* ) – ( EF* / H ) + J

= ( ABC*+) – (EF*H/) +J

= ( ABC*+EF*H/-) + J

This entry was posted in ISC2019. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *